Skip to content

Commit

Permalink
[video-player] add support for content uris as urls (#1813)
Browse files Browse the repository at this point in the history
content:// uris will be routed from DefaultDataSourceFactory in Android
  • Loading branch information
udnisap authored and Chris Yang committed Sep 4, 2019
1 parent c893375 commit b8c8c96
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.10.2+1

* Use DefaultHttpDataSourceFactory only when network schemas and use
DefaultHttpDataSourceFactory by default.

## 0.10.2

* **Android Only** Adds optional VideoFormat used to signal what format the plugin should try.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,16 @@ private static class VideoPlayer {
Uri uri = Uri.parse(dataSource);

DataSource.Factory dataSourceFactory;
if (isFileOrAsset(uri)) {
dataSourceFactory = new DefaultDataSourceFactory(context, "ExoPlayer");
} else {
if (isHTTP(uri)) {
dataSourceFactory =
new DefaultHttpDataSourceFactory(
"ExoPlayer",
null,
DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS,
true);
} else {
dataSourceFactory = new DefaultDataSourceFactory(context, "ExoPlayer");
}

MediaSource mediaSource = buildMediaSource(uri, dataSourceFactory, formatHint, context);
Expand All @@ -104,12 +104,12 @@ private static class VideoPlayer {
setupVideoPlayer(eventChannel, textureEntry, result);
}

private static boolean isFileOrAsset(Uri uri) {
private static boolean isHTTP(Uri uri) {
if (uri == null || uri.getScheme() == null) {
return false;
}
String scheme = uri.getScheme();
return scheme.equals("file") || scheme.equals("asset");
return scheme.equals("http") || scheme.equals("https");
}

private MediaSource buildMediaSource(
Expand Down

0 comments on commit b8c8c96

Please sign in to comment.