From d64388a075bfb693a4f69cecea8dceb1f1723b84 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 83d50bfcc4..6aa56341f5 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 @@ -436,6 +436,11 @@ public class PlayerActivity extends AppCompatActivity } Sample.SubtitleInfo subtitleInfo = sample.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,