---
title: State of Player
permalink: /docs/en/fijkstate.html
key: docs-fijkstate
---

There're different states inside FijkPlayer / ijkplayer. Jump between states is achieved through an API call.

The following illustration plots all the states in player, as well as the main API calls that invoke state jumps.

## State Changte Legend

The state jumps which connected by soild arrow in the figure are achieved by **API call**.   
The dashed arrow connected state changes are occurs automatically by some specific task within the player finished or some error occurs.

![state_of_ijkplayer](https://user-images.githubusercontent.com/51129600/62750997-ab195100-ba94-11e9-941b-57509e2bd677.png)


## State Interpretation

|----|----|
|State Name| Player Situation |
|----|----|
|idle| Idle state, the FijkPlayer that just completed the construction is in this state. <br> In this state, the player takes up a small amount of memory and no extra threads are started. <br> The idle state can only be converted to the initialized state via `setDataSource` |
|initialized| The initialized state is only more information about the input media data source than the idle state. Also no extra threads are open. |
|asyncPreparing| Calling `prepareAsync` in the initialized state reaches this state. <br> This is not a steady state, which is automatically converted to the prepared state after a specific task is completed. <br> The main task 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 the audio output device, create a new video output thread. |
|prepared| asyncPreparing automatically converts to this state when the specified task is completed.  <br>In this state, audio and video data is under in bufferring and decoding, and it can be started 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 again from the beginning. |
|stopped| The threads occupied by the player have been released. The audio device is turned off. |
|end| All memory in the player that needs to be manually released is released. <br> Players in this state can only wait for garbage collection for memory release. |
|error| Player has error |

#### Playable State 
prepared, started, paused, completed.  
In the playable state, you can convert to the **started** state by calling `start` and the playback becomes started.

#### Steady State
idle, initialized, prepared, paused, completed, stopped, end, error.  
Steady state can only be converted to other states through API calls. State changed are not autonomous.

#### Non-steady State 
asyncPreparing, started.  
Non-steady state will automatically change to other states when matching some conditions.   
Non-Steady state jumps can also be mase through API calls.

## Full Jump API

* **idle**  

|----|----|
|API name|target state|
|----|----|
| setDataSource()  | initialized |
| reset()  | idle |
| release()  | end |


* **initialized**


|----|----|
|API name |target state|
|----|----|
| prepareAsync()  | asyncPreparing |
| reset()  | idle |
| release()  | end |

* **asyncPreparing**

|----|----|
|API name|target state|
|----|----|
| prepare task complete | prepared |
| error ossurs  | error |
| reset()  | idle |
| release()  | end |


* **prepared**

|----|----|
|API name|target state|
|----|----|
| seekTo()  | prepared |
| start()  | started |
| reset()  | idle |
| release()  | end |



* **started**

|----|----|
|API名称|目标状态|
|----|----|
| seekTo()  | started |
| start()  | started |
| pause()  | paused |
| stop()  | stopped |
| playback finish | completed |
| error ossurs  | error |
| reset()  | idle |
| release()  | end |


* **paused**

|----|----|
|API name|target name|
|----|----|
| seekTo()  | paused |
| start()  | started |
| pause()  | paused |
| stop()  | stopped |
| reset()  | idle |
| release()  | end |

* **completed**

|----|----|
|API name|target state|
|----|----|
| seekTo()  | paused |
| start()  | started (from beginning)|
| pause()  | paused |
| stop()  | stopped |
| reset()  | idle |
| release()  | end |


* **stopped**

|----|----|
|API name|target name|
|----|----|
| stop()  | stopped |
| prepareAsync()  | asyncPreparing |
| reset()  | idle |
| release()  | end |

* **error**

|----|----|
|API name|target state|
|----|----|
| reset()  | idle |
| release()  | end |


* **end**

|----|----|
|API name|target state|
|----|----|
| release()  | end |

