Fix playing local content after permission granted.

After maybeRequestReadExternalStoragePermission and the
subsequent granting of the permission, the media source
would never be created.

I can't see a case where initializePlayer shouldn't create
a new MediaSource, so I've just removed the condition.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164260074
This commit is contained in:
olly 2017-08-04 07:26:19 -07:00 committed by Oliver Woodman
parent 576f362912
commit c28ebf10f7

View File

@ -119,7 +119,7 @@ public class PlayerActivity extends Activity implements OnClickListener, EventLi
private DefaultTrackSelector trackSelector;
private TrackSelectionHelper trackSelectionHelper;
private DebugTextViewHelper debugViewHelper;
private boolean needRetrySource;
private boolean inErrorState;
private TrackGroupArray lastSeenTrackGroupArray;
private boolean shouldAutoPlay;
@ -297,7 +297,6 @@ public class PlayerActivity extends Activity implements OnClickListener, EventLi
debugViewHelper = new DebugTextViewHelper(player, debugTextView);
debugViewHelper.start();
}
if (needNewPlayer || needRetrySource) {
String action = intent.getAction();
Uri[] uris;
String[] extensions;
@ -348,10 +347,9 @@ public class PlayerActivity extends Activity implements OnClickListener, EventLi
player.seekTo(resumeWindow, resumePosition);
}
player.prepare(mediaSource, !haveResumePosition, false);
needRetrySource = false;
inErrorState = false;
updateButtonVisibilities();
}
}
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
int type = TextUtils.isEmpty(overrideExtension) ? Util.inferContentType(uri)
@ -502,7 +500,7 @@ public class PlayerActivity extends Activity implements OnClickListener, EventLi
@Override
public void onPositionDiscontinuity() {
if (needRetrySource) {
if (inErrorState) {
// This will only occur if the user has performed a seek whilst in the error state. Update the
// resume position so that if the user then retries, playback will resume from the position to
// which they seeked.
@ -548,7 +546,7 @@ public class PlayerActivity extends Activity implements OnClickListener, EventLi
if (errorString != null) {
showToast(errorString);
}
needRetrySource = true;
inErrorState = true;
if (isBehindLiveWindow(e)) {
clearResumePosition();
initializePlayer();
@ -584,7 +582,7 @@ public class PlayerActivity extends Activity implements OnClickListener, EventLi
private void updateButtonVisibilities() {
debugRootView.removeAllViews();
retryButton.setVisibility(needRetrySource ? View.VISIBLE : View.GONE);
retryButton.setVisibility(inErrorState ? View.VISIBLE : View.GONE);
debugRootView.addView(retryButton);
if (player == null) {