VideoTools/vendor/fyne.io/fyne/v2/canvas/animation.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

92 lines
2.8 KiB
Go

package canvas
import (
"image/color"
"time"
"fyne.io/fyne/v2"
)
const (
// DurationStandard is the time a standard interface animation will run.
//
// Since: 2.0
DurationStandard = time.Millisecond * 300
// DurationShort is the time a subtle or small transition should use.
//
// Since: 2.0
DurationShort = time.Millisecond * 150
)
// NewColorRGBAAnimation sets up a new animation that will transition from the start to stop Color over
// the specified Duration. The colour transition will move linearly through the RGB colour space.
// The content of fn should apply the color values to an object and refresh it.
// You should call Start() on the returned animation to start it.
//
// Since: 2.0
func NewColorRGBAAnimation(start, stop color.Color, d time.Duration, fn func(color.Color)) *fyne.Animation {
r1, g1, b1, a1 := start.RGBA()
r2, g2, b2, a2 := stop.RGBA()
rStart := int(r1 >> 8)
gStart := int(g1 >> 8)
bStart := int(b1 >> 8)
aStart := int(a1 >> 8)
rDelta := float32(int(r2>>8) - rStart)
gDelta := float32(int(g2>>8) - gStart)
bDelta := float32(int(b2>>8) - bStart)
aDelta := float32(int(a2>>8) - aStart)
return &fyne.Animation{
Duration: d,
Tick: func(done float32) {
fn(color.RGBA{
R: scaleChannel(rStart, rDelta, done), G: scaleChannel(gStart, gDelta, done),
B: scaleChannel(bStart, bDelta, done), A: scaleChannel(aStart, aDelta, done),
})
},
}
}
// NewPositionAnimation sets up a new animation that will transition from the start to stop Position over
// the specified Duration. The content of fn should apply the position value to an object for the change
// to be visible. You should call Start() on the returned animation to start it.
//
// Since: 2.0
func NewPositionAnimation(start, stop fyne.Position, d time.Duration, fn func(fyne.Position)) *fyne.Animation {
xDelta := stop.X - start.X
yDelta := stop.Y - start.Y
return &fyne.Animation{
Duration: d,
Tick: func(done float32) {
fn(fyne.NewPos(scaleVal(start.X, xDelta, done), scaleVal(start.Y, yDelta, done)))
},
}
}
// NewSizeAnimation sets up a new animation that will transition from the start to stop Size over
// the specified Duration. The content of fn should apply the size value to an object for the change
// to be visible. You should call Start() on the returned animation to start it.
//
// Since: 2.0
func NewSizeAnimation(start, stop fyne.Size, d time.Duration, fn func(fyne.Size)) *fyne.Animation {
widthDelta := stop.Width - start.Width
heightDelta := stop.Height - start.Height
return &fyne.Animation{
Duration: d,
Tick: func(done float32) {
fn(fyne.NewSize(scaleVal(start.Width, widthDelta, done), scaleVal(start.Height, heightDelta, done)))
},
}
}
func scaleChannel(start int, diff, done float32) uint8 {
return uint8(start + int(diff*done))
}
func scaleVal(start float32, delta, done float32) float32 {
return start + delta*done
}