Player States


What each state means

StatePlayer behavior
idleIdle. A freshly constructed FPlayer sits here.
It holds a little memory and starts no extra threads.
From idle, only setDataSource can move it to initialized.
initializedInitialized. Compared with idle, the player now knows the input media source. Still no extra threads.
asyncPreparingAsynchronously preparing. You get here by calling prepareAsync from initialized.
This isn't a stable state: it waits for specific work to finish, then flips to prepared on its own.
That work covers probing the media type, opening the file, opening decoders and starting decode threads, starting a read thread, opening the audio output device, and starting video output threads.
preparedasyncPreparing lands here once its work is done.
Some audio and video has already been buffered and decoded, so playback can begin at any moment.
startedMedia (video or audio) is playing.
pausedPlayback of media (video or audio) is paused.
completedPlayback of media (video or audio) finished. You can play it again from the start.
stoppedEvery thread has released its resources. The audio device is closed.
endEvery buffer that needed manual release has been freed.
A player in this state just waits for garbage collection to reclaim the rest.
errorThe player hit an error.

Playable states

prepared, started, paused, completed.
From any playable state, start moves the player to started and playback runs.

Stable states

idle, initialized, prepared, paused, completed, stopped, end, error.
A stable state only changes when an API call moves it. It never shifts on its own.

Unstable states

asyncPreparing, started.
An unstable state changes on its own once conditions are met, and API calls can also push it to another state.

Every transition

idle

API callTarget state
setDataSource()initialized
reset()idle
release()end

initialized

API callTarget state
prepareAsync()asyncPreparing
reset()idle
release()end

asyncPreparing

API callTarget state
Preparation completesprepared
An error occurserror
reset()idle
release()end

prepared

API callTarget state
seekTo()prepared
start()started
reset()idle
release()end

started

API callTarget state
seekTo()started
start()started
pause()paused
stop()stopped
Playback completescompleted
An error occurserror
reset()idle
release()end

paused

API callTarget state
seekTo()paused
start()started
pause()paused
stop()stopped
reset()idle
release()end

completed

API callTarget state
seekTo()paused
start()started (from the beginning)
pause()paused
stop()stopped
reset()idle
release()end

stopped

API callTarget state
stop()stopped
prepareAsync()asyncPreparing
reset()idle
release()end

error

API callTarget state
reset()idle
release()end

end

API callTarget state
release()end