Commit ba46e472 by olly Committed by Oliver Woodman

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
parent 42eaee3d
...@@ -119,7 +119,7 @@ public class PlayerActivity extends Activity implements OnClickListener, EventLi ...@@ -119,7 +119,7 @@ public class PlayerActivity extends Activity implements OnClickListener, EventLi
private DefaultTrackSelector trackSelector; private DefaultTrackSelector trackSelector;
private TrackSelectionHelper trackSelectionHelper; private TrackSelectionHelper trackSelectionHelper;
private DebugTextViewHelper debugViewHelper; private DebugTextViewHelper debugViewHelper;
private boolean needRetrySource; private boolean inErrorState;
private TrackGroupArray lastSeenTrackGroupArray; private TrackGroupArray lastSeenTrackGroupArray;
private boolean shouldAutoPlay; private boolean shouldAutoPlay;
...@@ -297,13 +297,12 @@ public class PlayerActivity extends Activity implements OnClickListener, EventLi ...@@ -297,13 +297,12 @@ public class PlayerActivity extends Activity implements OnClickListener, EventLi
debugViewHelper = new DebugTextViewHelper(player, debugTextView); debugViewHelper = new DebugTextViewHelper(player, debugTextView);
debugViewHelper.start(); debugViewHelper.start();
} }
if (needNewPlayer || needRetrySource) {
String action = intent.getAction(); String action = intent.getAction();
Uri[] uris; Uri[] uris;
String[] extensions; String[] extensions;
if (ACTION_VIEW.equals(action)) { if (ACTION_VIEW.equals(action)) {
uris = new Uri[] {intent.getData()}; uris = new Uri[]{intent.getData()};
extensions = new String[] {intent.getStringExtra(EXTENSION_EXTRA)}; extensions = new String[]{intent.getStringExtra(EXTENSION_EXTRA)};
} else if (ACTION_VIEW_LIST.equals(action)) { } else if (ACTION_VIEW_LIST.equals(action)) {
String[] uriStrings = intent.getStringArrayExtra(URI_LIST_EXTRA); String[] uriStrings = intent.getStringArrayExtra(URI_LIST_EXTRA);
uris = new Uri[uriStrings.length]; uris = new Uri[uriStrings.length];
...@@ -348,10 +347,9 @@ public class PlayerActivity extends Activity implements OnClickListener, EventLi ...@@ -348,10 +347,9 @@ public class PlayerActivity extends Activity implements OnClickListener, EventLi
player.seekTo(resumeWindow, resumePosition); player.seekTo(resumeWindow, resumePosition);
} }
player.prepare(mediaSource, !haveResumePosition, false); player.prepare(mediaSource, !haveResumePosition, false);
needRetrySource = false; inErrorState = false;
updateButtonVisibilities(); updateButtonVisibilities();
} }
}
private MediaSource buildMediaSource(Uri uri, String overrideExtension) { private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
int type = TextUtils.isEmpty(overrideExtension) ? Util.inferContentType(uri) int type = TextUtils.isEmpty(overrideExtension) ? Util.inferContentType(uri)
...@@ -502,7 +500,7 @@ public class PlayerActivity extends Activity implements OnClickListener, EventLi ...@@ -502,7 +500,7 @@ public class PlayerActivity extends Activity implements OnClickListener, EventLi
@Override @Override
public void onPositionDiscontinuity() { 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 // 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 // resume position so that if the user then retries, playback will resume from the position to
// which they seeked. // which they seeked.
...@@ -548,7 +546,7 @@ public class PlayerActivity extends Activity implements OnClickListener, EventLi ...@@ -548,7 +546,7 @@ public class PlayerActivity extends Activity implements OnClickListener, EventLi
if (errorString != null) { if (errorString != null) {
showToast(errorString); showToast(errorString);
} }
needRetrySource = true; inErrorState = true;
if (isBehindLiveWindow(e)) { if (isBehindLiveWindow(e)) {
clearResumePosition(); clearResumePosition();
initializePlayer(); initializePlayer();
...@@ -584,7 +582,7 @@ public class PlayerActivity extends Activity implements OnClickListener, EventLi ...@@ -584,7 +582,7 @@ public class PlayerActivity extends Activity implements OnClickListener, EventLi
private void updateButtonVisibilities() { private void updateButtonVisibilities() {
debugRootView.removeAllViews(); debugRootView.removeAllViews();
retryButton.setVisibility(needRetrySource ? View.VISIBLE : View.GONE); retryButton.setVisibility(inErrorState ? View.VISIBLE : View.GONE);
debugRootView.addView(retryButton); debugRootView.addView(retryButton);
if (player == null) { if (player == null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment