From d1703ad68c0912ffd4ff0c223ae058096c71aa8a Mon Sep 17 00:00:00 2001 From: ibaker Date: Tue, 21 Jan 2020 20:04:08 +0000 Subject: [PATCH] Ensure the demo app requests local-file permissions for subtitle files Currently we only do this for the main sample URI, not for subtitles. So pairing a web-based video file with a local subtitle file on a fresh install just throws a 'permission denied' exception. PiperOrigin-RevId: 290794091 --- .../com/google/android/exoplayer2/demo/PlayerActivity.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java b/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java index 87593a7db4..6814e296db 100644 --- a/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java +++ b/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java @@ -432,6 +432,11 @@ public class PlayerActivity extends AppCompatActivity mediaSources[i] = createLeafMediaSource(samples[i]); Sample.SubtitleInfo subtitleInfo = samples[i].subtitleInfo; if (subtitleInfo != null) { + if (Util.maybeRequestReadExternalStoragePermission( + /* activity= */ this, subtitleInfo.uri)) { + // The player will be reinitialized if the permission is granted. + return Collections.emptyList(); + } Format subtitleFormat = Format.createTextSampleFormat( /* id= */ null,