From 74d2c2147447358be7e9134dbb7363beeb746052 Mon Sep 17 00:00:00 2001 From: Pasindu Perera Date: Mon, 29 Jul 2019 01:22:37 -0700 Subject: [PATCH] [video-player] add support for content uris as urls -- all http and https uris will be routed to DefaultHttpDataSourceFactory -- everything else will use DefaultMediaSource --- packages/video_player/CHANGELOG.md | 5 +++++ .../flutter/plugins/videoplayer/VideoPlayerPlugin.java | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/video_player/CHANGELOG.md b/packages/video_player/CHANGELOG.md index 207a9ca272ce..cc341ec1e3bb 100644 --- a/packages/video_player/CHANGELOG.md +++ b/packages/video_player/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.10.1+7 + +* Use DefaultHttpDataSourceFactory only when network schemas and use +DefaultHttpDataSourceFactory by default. + ## 0.10.1+6 * [iOS] Fixed a memory leak with notification observing. diff --git a/packages/video_player/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayerPlugin.java b/packages/video_player/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayerPlugin.java index 0be5e770101c..56108d870d54 100644 --- a/packages/video_player/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayerPlugin.java +++ b/packages/video_player/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayerPlugin.java @@ -81,9 +81,7 @@ 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", @@ -91,6 +89,8 @@ private static class VideoPlayer { DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS, DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, true); + } else { + dataSourceFactory = new DefaultDataSourceFactory(context, "ExoPlayer"); } MediaSource mediaSource = buildMediaSource(uri, dataSourceFactory, context); @@ -99,12 +99,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(