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
90 lines
2.2 KiB
Go
90 lines
2.2 KiB
Go
package internal
|
|
|
|
import "fyne.io/fyne/v2"
|
|
|
|
// ClipStack keeps track of the areas that should be clipped when drawing a canvas.
|
|
// If no clips are present then adding one will be added as-is.
|
|
// Subsequent items pushed will be completely within the previous clip.
|
|
type ClipStack struct {
|
|
clips []*ClipItem
|
|
}
|
|
|
|
// Pop removes the current top clip and returns it.
|
|
func (c *ClipStack) Pop() *ClipItem {
|
|
if len(c.clips) == 0 {
|
|
return nil
|
|
}
|
|
|
|
top := len(c.clips) - 1
|
|
ret := c.clips[top]
|
|
c.clips[top] = nil // release memory reference
|
|
c.clips = c.clips[:top]
|
|
return ret
|
|
}
|
|
|
|
// Length returns the number of items in this clip stack. 0 means no clip.
|
|
func (c *ClipStack) Length() int {
|
|
return len(c.clips)
|
|
}
|
|
|
|
// Push a new clip onto this stack at position and size specified.
|
|
// The returned clip item is the result of calculating the intersection of the requested clip and its parent.
|
|
func (c *ClipStack) Push(p fyne.Position, s fyne.Size) *ClipItem {
|
|
outer := c.Top()
|
|
inner := outer.Intersect(p, s)
|
|
|
|
c.clips = append(c.clips, inner)
|
|
return inner
|
|
}
|
|
|
|
// Top returns the current clip item - it will always be within the bounds of any parent clips.
|
|
func (c *ClipStack) Top() *ClipItem {
|
|
if len(c.clips) == 0 {
|
|
return nil
|
|
}
|
|
|
|
return c.clips[len(c.clips)-1]
|
|
}
|
|
|
|
// ClipItem represents a single clip in a clip stack, denoted by a size and position.
|
|
type ClipItem struct {
|
|
pos fyne.Position
|
|
size fyne.Size
|
|
}
|
|
|
|
// Rect returns the position and size parameters of the clip.
|
|
func (i *ClipItem) Rect() (fyne.Position, fyne.Size) {
|
|
return i.pos, i.size
|
|
}
|
|
|
|
// Intersect returns a new clip item that is the intersection of the requested parameters and this clip.
|
|
func (i *ClipItem) Intersect(p fyne.Position, s fyne.Size) *ClipItem {
|
|
ret := &ClipItem{p, s}
|
|
if i == nil {
|
|
return ret
|
|
}
|
|
|
|
if ret.pos.X < i.pos.X {
|
|
ret.pos.X = i.pos.X
|
|
ret.size.Width -= i.pos.X - p.X
|
|
}
|
|
if ret.pos.Y < i.pos.Y {
|
|
ret.pos.Y = i.pos.Y
|
|
ret.size.Height -= i.pos.Y - p.Y
|
|
}
|
|
|
|
if p.X+s.Width > i.pos.X+i.size.Width {
|
|
ret.size.Width = (i.pos.X + i.size.Width) - ret.pos.X
|
|
}
|
|
if p.Y+s.Height > i.pos.Y+i.size.Height {
|
|
ret.size.Height = (i.pos.Y + i.size.Height) - ret.pos.Y
|
|
}
|
|
|
|
if ret.size.Width < 0 || ret.size.Height < 0 {
|
|
ret.size = fyne.NewSize(0, 0)
|
|
return ret
|
|
}
|
|
|
|
return ret
|
|
}
|