Skip to content

IllegalStateException thrown after resetting player and setting data source #114

@velocitysystems

Description

@velocitysystems

Description

MediaPlayerExtended throws an IllegalStateException when switching between data sources which contain and do not contain an audio track.

Steps to Reproduce

  1. Set data source to media containing a video track with an audio track.
  2. Call the prepare() or prepareAsync() method.
  3. Call the reset() method.
  4. Set data source to media containing a video track without an audio track.
  5. 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.

if (mAudioPlayback != null) mAudioPlayback.pause(true);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions