VideoTools/vendor/github.com/fyne-io/glfw-js/context_webgl_wasm.go
Stu Leak bdc27c2253 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

61 lines
1.8 KiB
Go

//go:build wasm
package glfw
import (
"errors"
"syscall/js"
)
func newContext(canvas js.Value, ca *contextAttributes) (context js.Value, err error) {
if js.Global().Get("WebGLRenderingContext").Equal(js.Undefined()) {
return js.Value{}, errors.New("Your browser doesn't appear to support WebGL.")
}
attrs := map[string]any{
"alpha": ca.Alpha,
"depth": ca.Depth,
"stencil": ca.Stencil,
"antialias": ca.Antialias,
"premultipliedAlpha": ca.PremultipliedAlpha,
"preserveDrawingBuffer": ca.PreserveDrawingBuffer,
"preferLowPowerToHighPerformance": ca.PreferLowPowerToHighPerformance,
"failIfMajorPerformanceCaveat": ca.FailIfMajorPerformanceCaveat,
}
if gl := canvas.Call("getContext", "webgl", attrs); !gl.Equal(js.Null()) {
debug := js.Global().Get("WebGLDebugUtils")
if debug.Equal(js.Undefined()) {
return gl, errors.New("No debugging for WebGL.")
}
gl = debug.Call("makeDebugContext", gl)
return gl, nil
} else if gl := canvas.Call("getContext", "experimental-webgl", attrs); gl.Equal(js.Null()) {
return gl, nil
} else {
return js.Value{}, errors.New("Creating a WebGL context has failed.")
}
}
type contextAttributes struct {
Alpha bool
Depth bool
Stencil bool
Antialias bool
PremultipliedAlpha bool
PreserveDrawingBuffer bool
PreferLowPowerToHighPerformance bool
FailIfMajorPerformanceCaveat bool
}
func defaultAttributes() *contextAttributes {
return &contextAttributes{
Alpha: false,
Depth: true,
Stencil: false,
Antialias: false,
PremultipliedAlpha: false,
PreserveDrawingBuffer: false,
}
}