VideoTools/vendor/github.com/jeandeaual/go-locale/locale_android.go
Stu Leak 68df790d27 Fix player frame generation and video playback
Major improvements to UnifiedPlayer:

1. GetFrameImage() now works when paused for responsive UI updates
2. Play() method properly starts FFmpeg process
3. Frame display loop runs continuously for smooth video display
4. Disabled audio temporarily to fix video playback fundamentals
5. Simplified FFmpeg command to focus on video stream only

Player now:
- Generates video frames correctly
- Shows video when paused
- Has responsive progress tracking
- Starts playback properly

Next steps: Re-enable audio playback once video is stable
2026-01-07 22:20:00 -05:00

116 lines
3.0 KiB
Go

//go:build android
package locale
/*
#cgo LDFLAGS: -landroid -llog
#include <stdlib.h>
const char *getLocales(uintptr_t java_vm, uintptr_t jni_env, uintptr_t ctx);
const char *getLocale(uintptr_t java_vm, uintptr_t jni_env, uintptr_t ctx);
const char *getLanguage(uintptr_t java_vm, uintptr_t jni_env, uintptr_t ctx);
const char *getRegion(uintptr_t java_vm, uintptr_t jni_env, uintptr_t ctx);
*/
import "C"
import (
"errors"
"strings"
"unsafe"
)
var (
errRunOnJVMNotSet error = errors.New("you first need to call SetRunOnJVM")
runOnJVM func(fn func(vm, env, ctx uintptr) error) error
)
// SetRunOnJVM sets the RunOnJVM function that will be called by this library.
// This can either be "golang.org/x/mobile/app".RunOnJVM or "github.com/fyne-io/mobile/app".RunOnJVM,
// depending on the mobile framework you're using (both can't be imported at the same time).
//
// RunOnJVM runs fn on a new goroutine locked to an OS thread with a JNIEnv.
//
// RunOnJVM blocks until the call to fn is complete. Any Java
// exception or failure to attach to the JVM is returned as an error.
//
// The function fn takes vm, the current JavaVM*,
// env, the current JNIEnv*, and
// ctx, a jobject representing the global android.context.Context.
func SetRunOnJVM(fn func(fn func(vm, env, ctx uintptr) error) error) {
runOnJVM = fn
}
// GetLocale retrieves the IETF BCP 47 language tag set on the system.
func GetLocale() (string, error) {
if runOnJVM == nil {
return "", errRunOnJVMNotSet
}
locale := ""
err := runOnJVM(func(vm, env, ctx uintptr) error {
chars := C.getLocale(C.uintptr_t(vm), C.uintptr_t(env), C.uintptr_t(ctx))
locale = C.GoString(chars)
C.free(unsafe.Pointer(chars))
return nil
})
return locale, err
}
// GetLocales retrieves the IETF BCP 47 language tags set on the system.
func GetLocales() ([]string, error) {
if runOnJVM == nil {
return nil, errRunOnJVMNotSet
}
locales := ""
err := runOnJVM(func(vm, env, ctx uintptr) error {
chars := C.getLocales(C.uintptr_t(vm), C.uintptr_t(env), C.uintptr_t(ctx))
locales = C.GoString(chars)
C.free(unsafe.Pointer(chars))
return nil
})
return strings.Split(locales, ","), err
}
// GetLanguage retrieves the IETF BCP 47 language tag set on the system and
// returns the language part of the tag.
func GetLanguage() (string, error) {
if runOnJVM == nil {
return "", errRunOnJVMNotSet
}
language := ""
err := runOnJVM(func(vm, env, ctx uintptr) error {
chars := C.getLanguage(C.uintptr_t(vm), C.uintptr_t(env), C.uintptr_t(ctx))
language = C.GoString(chars)
C.free(unsafe.Pointer(chars))
return nil
})
return language, err
}
// GetRegion retrieves the IETF BCP 47 language tag set on the system and
// returns the region part of the tag.
func GetRegion() (string, error) {
if runOnJVM == nil {
return "", errRunOnJVMNotSet
}
region := ""
err := runOnJVM(func(vm, env, ctx uintptr) error {
chars := C.getRegion(C.uintptr_t(vm), C.uintptr_t(env), C.uintptr_t(ctx))
region = C.GoString(chars)
C.free(unsafe.Pointer(chars))
return nil
})
return region, err
}