Documentation
¶
Overview ¶
Package videoplay tracks app and platform ownership of a video’s playback.
Index ¶
- Constants
- type State
- func (p *State) Applied(playing bool)
- func (p *State) Changed(playing, paused bool, reason int) (driver.Event, bool)
- func (p *State) Configure(pausedChanged bool) bool
- func (p *State) Ended(repeat bool, at time.Duration)
- func (p *State) Expect(reason int)
- func (p *State) Resume() bool
- func (p *State) Rewinds(at time.Duration) bool
Constants ¶
const Background = -1
Background is the backend's own reason for a pause because the app went to the background, which Changed reports as VideoPauseInterruption. No audio-session interruption ends it, so it never lets the video resume, and it takes back the resume of an interruption that paused the video before.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type State ¶
type State struct {
// Playing is what the player did last, as far as the backend knows.
Playing bool
// Completed holds a non-repeating end until an explicit replay or seek.
Completed bool
// contains filtered or unexported fields
}
State follows who decides whether a video's player plays. The app's Paused applies when it changes and when a source opens; between changes the platform's controls and the system may pause or play the player, and the player then keeps their state, not Paused, until Paused changes. Each such change is reported once, as EventVideoPause with its reason or EventVideoPlay.
func (*State) Applied ¶
Applied records the play state the backend is about to give the player, which is not reported.
func (*State) Changed ¶
Changed takes a play state the player reached on its own, from its controls or the system, with paused the app's Paused, and returns the event that reports it. reason is the pause's, unless the system gave one before. A pause for an audio-session interruption may resume when the interruption ends.
func (*State) Configure ¶
Configure reports whether to apply the app’s Paused: when it changed, or no native control or completed frame holds the play state.
func (*State) Ended ¶
Ended records that the player reached its end, which EventEnd reports. A video that repeats plays on from its start, and whoever held its play state keeps it, so a play from the controls while Paused is true goes on; one that does not stops, leaves the play state to Paused again, and stays at its end through unrelated configuration until Paused changes, a seek or the controls play it; at is where it stopped.
func (*State) Expect ¶
Expect records why the system is about to pause the player, before the player says it stopped.
func (*State) Resume ¶
Resume says whether the player plays again as an interruption that paused it ends: when the system lets it, and the app has not changed Paused since.
func (*State) Rewinds ¶
Rewinds says whether the app's play of a completed video starts over from the beginning, with at the player's position: it does while the player is still where it ended, and resumes where the platform's controls scrubbed it back to otherwise. The end the player reached is the mark, not the item's duration, which a player's end may fall short of.