ijkplayer player status analysis
There are different states in the player ijkplayer. The bar of the state is realized through API calls.
The following figure plots all the states in the player and the main API calls involving state jumps.
State transition diagram
In the figure, the state change connected by the solid arrow is completed through API calls, and
the state change connected by the dashed arrow is the state change that occurs automatically when a specific task is executed or an error occurs inside the player.
State interpretation
State name | Player performance |
---|---|
idle | Idle state, the FijkPlayer that has just been constructed is in this state. In this state, the player occupies a small amount of memory and no additional threads are started. The idle state can only be converted to the initialized state through setDataSource |
initialized | Compared with the idle state, the initialization completed state only has more information about the input media data source. Similarly, no additional threads are opened. |
asyncPreparing | Asynchronous preparation state, call prepareAsync in the initialized state to reach this state. This is not a stable state. This state will automatically change to the prepared state after the completion of specific tasks. The main preparation for this state is to detect the media file type, open the media file, open the decoder and create a new decoding thread, create a new data read thread, open an audio output device, create a new video output thread, etc. |
prepared | asyncPreparing automatically changes to this state after completing the specified task. In this state, a part of the audio and video data has been buffered and decoded, and can be played at any time. |
started | The media (video, audio) is playing. |
paused | Media (video, audio) playback is paused. |
completed | The media (video, audio) playback is complete. You can start playing from the beginning again. |
stopped | The resources occupied by various threads of the player have been released. The audio device is turned off. |
end | All the memory that needs to be manually released in the player has been released. Players in this state can only wait for garbage collection to release memory. |
error | An error occurred in the player. |
Playable state
prepared, started, paused, completed.
In the playable state, it can be converted to the started state by calling start, and the media can be played.
stable state
idle, initialized, prepared, paused, completed, stopped, end, error.
The stable state can only be converted to other states through API calls, and state changes will not occur autonomously.
Unsteady state
asyncPreparing, started.
The unstable state will automatically change to other states under certain conditions, and the state can also be jumped through API calls.
Full conversion API
idle
API name | Goal state |
---|---|
setDataSource() | initialized |
reset() | idle |
release() | end |
initialized
API name | Goal state |
---|---|
prepareAsync() | asyncPreparing |
reset() | idle |
release() | end |
asyncPreparing
API name | Goal state |
---|---|
Processing complete | prepared |
An error occurred | error |
reset() | idle |
release() | end |
prepared
API name | Goal state |
---|---|
seekTo () | prepared |
start() | started |
reset() | idle |
release() | end |
started
API name | Goal state |
---|---|
seekTo () | started |
start() | started |
pause() | paused |
stop() | stopped |
Play complete | completed |
An error occurred | error |
reset() | idle |
release() | end |
paused
API name | Goal state |
---|---|
seekTo () | paused |
start() | started |
pause() | paused |
stop() | stopped |
reset() | idle |
release() | end |
completed
API name | Goal state |
---|---|
seekTo () | paused |
start() | started (from the beginning) |
pause() | paused |
stop() | stopped |
reset() | idle |
release() | end |
stopped
API name | Goal state |
---|---|
stop() | stopped |
prepareAsync() | asyncPreparing |
reset() | idle |
release() | end |
error
API name | Goal state |
---|---|
reset() | idle |
release() | end |
end
API name | Goal state |
---|---|
release() | end |
Technical Exchange Group: [960994558] Sorted out some good study books, interview questions from big companies, and popular technology teaching video materials to share in it (including C/C++, Linux, Nginx, ZeroMQ, MySQL, Redis, fastdfs, MongoDB, ZK, streaming media, CDN, P2P, K8S, Docker, TCP/IP, coroutine, DPDK, etc.), you can add it yourself if you need it! ~