You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MediaPlayerExtended throws an IllegalStateException when switching between data sources which contain and do not contain an audio track.
Steps to Reproduce
Set data source to media containing a video track with an audio track.
Call the prepare() or prepareAsync() method.
Call the reset() method.
Set data source to media containing a video track without an audio track.
Call the prepare() or prepareAsync() method.
Expected Behavior
The media should be prepared for playback.
Actual Behavior
An IllegalStateException is thrown.
java.lang.IllegalStateException
02-13 11:03:01.878 E/MediaPlayer(12568): at net.protyposis.android.mediaplayer.AudioPlayback.pause(AudioPlayback.java:205)
02-13 11:03:01.878 E/MediaPlayer(12568): at net.protyposis.android.mediaplayer.MediaPlayer.prepareInternal(MediaPlayer.java:456)
02-13 11:03:01.878 E/MediaPlayer(12568): at net.protyposis.android.mediaplayer.MediaPlayer.access$800(MediaPlayer.java:36)
02-13 11:03:01.878 E/MediaPlayer(12568): at net.protyposis.android.mediaplayer.MediaPlayer$PlaybackThread.prepareInternal(MediaPlayer.java:1101)
02-13 11:03:01.878 E/MediaPlayer(12568): at net.protyposis.android.mediaplayer.MediaPlayer$PlaybackThread.handleMessage(MediaPlayer.java:1053)
02-13 11:03:01.878 E/MediaPlayer(12568): at android.os.Handler.dispatchMessage(Handler.java:98)
02-13 11:03:01.878 E/MediaPlayer(12568): at android.os.Looper.loop(Looper.java:154)
02-13 11:03:01.878 E/MediaPlayer(12568): at android.os.HandlerThread.run(HandlerThread.java:61)
Discussion
I believe the issue is that mAudioPlayback is never set to null when calling reset() . Since the first data source contained an audio track, this field was set but never nulled out when calling reset()or setting the second data source which does not contain an audio track.
Fixes GitHub issue #114 where loading of a media source without an audio track fails after loading a media source with an audio track. The player tried to reuse the disposed AudioTrack instance from the previous source and ran into an exception.
Description
MediaPlayerExtended throws an IllegalStateException when switching between data sources which contain and do not contain an audio track.
Steps to Reproduce
prepare()
orprepareAsync()
method.reset()
method.prepare()
orprepareAsync()
method.Expected Behavior
The media should be prepared for playback.
Actual Behavior
An
IllegalStateException
is thrown.Discussion
I believe the issue is that
mAudioPlayback
is never set tonull
when callingreset()
. Since the first data source contained an audio track, this field was set but never nulled out when callingreset()
or setting the second data source which does not contain an audio track.MediaPlayer-Extended/MediaPlayer/src/main/java/net/protyposis/android/mediaplayer/MediaPlayer.java
Line 456 in 2ff8e6d
The text was updated successfully, but these errors were encountered: