I'm encountering some errors after upgrading the just_audio package from just_audio: 0.2.2 to just_audio: 0.6.5. I have tried to change the code but failed. Here is a screenshot of my code; 
errors detail; 

Please help!
1 Answers
A lot will have changed between 0.2.x and 0.6.x so I will focus my answer on the specific error you showed concerning state.
In the new state model of 0.6.x, the state of the player consists of two orthogonal states called playing and processingState, as depicted in the following state diagram from the project README:
playing can be true or false, while processingState can be one of these states:
enum ProcessingState {
/// The player has not loaded an [AudioSource].
idle,
/// The player is loading an [AudioSource].
loading,
/// The player is buffering audio and unable to play.
buffering,
/// The player is has enough audio buffered and is able to play.
ready,
/// The player has reached the end of the audio.
completed,
}
One reason why this new composite state model was chosen is that in the old model, there was no way to distinguish between the following two states:
- Buffering while playing.
- Buffering while paused.
In the new model, these are easily distinguishable. If your app cares about both of these orthogonal states, you can listen to the playingStateStream which emits events encapsulating both states:
_audioPlayer.playerStateStream.listen((state) {
if (state.playing) ... else ...
switch (state.processingState) {
case ProcessingState.idle: ...
case ProcessingState.loading: ...
case ProcessingState.buffering: ...
case ProcessingState.ready: ...
case ProcessingState.completed: ...
}
});
Internally, playerStateStream is implemented by simply using rxdart to combine playingStream and processingStateStream. In more advanced scenarios, you may use a similar technique to combine any other streams your app is interested in all into one stream. If you have a good argument for making a particular combination of streams provided as a standard combination by the plugin, you are welcome to submit a feature request on GitHub.
Finally, since it appears you are also using audio_service, I would recommend looking at the latest audio_service example which demonstrates how to leverage the latest just_audio API to implement your background task in a more concise way.
