Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalStateException thrown after resetting player and setting data source #114

Closed
velocitysystems opened this issue Feb 13, 2020 · 3 comments

Comments

@velocitysystems
Copy link

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);

@apwillies
Copy link

apwillies commented Feb 13, 2020

@protyposis Any chance of getting this one fixed soon?

@protyposis
Copy link
Owner

Thanks for reporting this issue. I'll try to take a look in the next few days.

protyposis added a commit that referenced this issue Feb 26, 2020
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.
@protyposis
Copy link
Owner

Fixed in v4.4.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants