Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
cf7b908e
authored
Jan 16, 2020
by
tonihei
Committed by
Oliver Woodman
Jan 16, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix demo app NPE when selecting unsupported samples.
PiperOrigin-RevId: 290027772
parent
090aed3a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
View file @
cf7b908e
...
...
@@ -82,6 +82,7 @@ import java.net.CookieHandler;
import
java.net.CookieManager
;
import
java.net.CookiePolicy
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
/** An activity that plays media using {@link SimpleExoPlayer}. */
...
...
@@ -405,7 +406,7 @@ public class PlayerActivity extends AppCompatActivity
if
(!
actionIsListView
&&
!
ACTION_VIEW
.
equals
(
action
))
{
showToast
(
getString
(
R
.
string
.
unexpected_intent_action
,
action
));
finish
();
return
null
;
return
Collections
.
emptyList
()
;
}
Sample
intentAsSample
=
Sample
.
createFromIntent
(
intent
);
...
...
@@ -419,17 +420,20 @@ public class PlayerActivity extends AppCompatActivity
seenAdsTagUri
|=
sample
.
adTagUri
!=
null
;
if
(!
Util
.
checkCleartextTrafficPermitted
(
sample
.
uri
))
{
showToast
(
R
.
string
.
error_cleartext_not_permitted
);
return
null
;
return
Collections
.
emptyList
()
;
}
if
(
Util
.
maybeRequestReadExternalStoragePermission
(
/* activity= */
this
,
sample
.
uri
))
{
// The player will be reinitialized if the permission is granted.
return
null
;
return
Collections
.
emptyList
()
;
}
}
List
<
MediaSource
>
mediaSources
=
new
ArrayList
<>();
for
(
UriSample
sample
:
samples
)
{
MediaSource
mediaSource
=
createLeafMediaSource
(
sample
);
if
(
mediaSource
==
null
)
{
continue
;
}
Sample
.
SubtitleInfo
subtitleInfo
=
sample
.
subtitleInfo
;
if
(
subtitleInfo
!=
null
)
{
Format
subtitleFormat
=
...
...
@@ -467,6 +471,7 @@ public class PlayerActivity extends AppCompatActivity
return
mediaSources
;
}
@Nullable
private
MediaSource
createLeafMediaSource
(
UriSample
parameters
)
{
Sample
.
DrmInfo
drmInfo
=
parameters
.
drmInfo
;
int
errorStringId
=
R
.
string
.
error_drm_unknown
;
...
...
@@ -602,7 +607,7 @@ public class PlayerActivity extends AppCompatActivity
try
{
Class
<?>
loaderClass
=
Class
.
forName
(
"com.google.android.exoplayer2.ext.ima.ImaAdsLoader"
);
if
(
adsLoader
==
null
)
{
// Full class names used so the
LINT.IfChange
rule triggers should any of the classes move.
// Full class names used so the
lint
rule triggers should any of the classes move.
// LINT.IfChange
Constructor
<?
extends
AdsLoader
>
loaderConstructor
=
loaderClass
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment