fix bug that caused ExternalPlayerFragment to not always be shown

This commit is contained in:
Tom Hennen 2015-09-26 11:11:48 -04:00
parent b090e2bf65
commit c097b672d6
2 changed files with 18 additions and 16 deletions

View File

@ -141,26 +141,12 @@ public class ExternalPlayerFragment extends Fragment {
@Override @Override
public void onShutdownNotification() { public void onShutdownNotification() {
if (fragmentLayout != null) { playbackDone();
fragmentLayout.setVisibility(View.GONE);
}
controller = setupPlaybackController();
if (butPlay != null) {
butPlay.setOnClickListener(controller
.newOnPlayButtonClickListener());
}
} }
@Override @Override
public void onPlaybackEnd() { public void onPlaybackEnd() {
if (fragmentLayout != null) { playbackDone();
fragmentLayout.setVisibility(View.GONE);
}
controller = setupPlaybackController();
if (butPlay != null) {
butPlay.setOnClickListener(controller
.newOnPlayButtonClickListener());
}
} }
@Override @Override
@ -192,6 +178,21 @@ public class ExternalPlayerFragment extends Fragment {
} }
} }
private void playbackDone() {
if (fragmentLayout != null) {
fragmentLayout.setVisibility(View.GONE);
}
if (controller != null) {
controller.release();
}
controller = setupPlaybackController();
if (butPlay != null) {
butPlay.setOnClickListener(controller
.newOnPlayButtonClickListener());
}
controller.init();
}
private boolean loadMediaInfo() { private boolean loadMediaInfo() {
Log.d(TAG, "Loading media info"); Log.d(TAG, "Loading media info");
if (controller != null && controller.serviceAvailable()) { if (controller != null && controller.serviceAvailable()) {

View File

@ -120,6 +120,7 @@ public abstract class PlaybackController {
throw new IllegalStateException( throw new IllegalStateException(
"Can't call init() after release() has been called"); "Can't call init() after release() has been called");
} }
checkMediaInfoLoaded();
} }
/** /**