fix some possible issues with exoplayer
This commit is contained in:
parent
9fe93ea841
commit
225e3562f4
1 changed files with 11 additions and 3 deletions
|
|
@ -93,11 +93,15 @@ public class MultiPlayer implements Playback {
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerError(ExoPlaybackException error) {
|
public void onPlayerError(ExoPlaybackException error) {
|
||||||
Log.i(TAG, "onPlayerError: " + error.getMessage());
|
Log.i(TAG, "onPlayerError: " + error.getMessage());
|
||||||
if (context != null) {
|
if (context == null) {
|
||||||
Toast.makeText(context, context.getResources().getString(R.string.unplayable_file), Toast.LENGTH_SHORT).show();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
stop();
|
Toast.makeText(context, context.getResources().getString(R.string.unplayable_file), Toast.LENGTH_SHORT).show();
|
||||||
|
exoPlayer.release();
|
||||||
|
|
||||||
|
exoPlayer = new SimpleExoPlayer.Builder(context).build();
|
||||||
|
isReady = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -105,6 +109,8 @@ public class MultiPlayer implements Playback {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
|
||||||
httpClient = new OkHttpClient();
|
httpClient = new OkHttpClient();
|
||||||
|
|
||||||
|
if (exoPlayer != null) exoPlayer.release();
|
||||||
exoPlayer = new SimpleExoPlayer.Builder(context).build();
|
exoPlayer = new SimpleExoPlayer.Builder(context).build();
|
||||||
mediaSource = new ConcatenatingMediaSource();
|
mediaSource = new ConcatenatingMediaSource();
|
||||||
|
|
||||||
|
|
@ -230,6 +236,8 @@ public class MultiPlayer implements Playback {
|
||||||
@Override
|
@Override
|
||||||
public void stop() {
|
public void stop() {
|
||||||
exoPlayer.release();
|
exoPlayer.release();
|
||||||
|
|
||||||
|
exoPlayer = null;
|
||||||
isReady = false;
|
isReady = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue