From 5641dd2f75203fd31bd044f083af753c201ac129 Mon Sep 17 00:00:00 2001 From: Colin White Date: Fri, 23 Apr 2021 16:30:12 -0500 Subject: [PATCH] Fix VideoFrameUriFetcher attempting to handle http URIs. (#734) --- .../java/coil/fetch/VideoFrameFetcherTest.kt | 12 ++++++++++++ .../src/main/java/coil/fetch/VideoFrameFetcher.kt | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/coil-video/src/androidTest/java/coil/fetch/VideoFrameFetcherTest.kt b/coil-video/src/androidTest/java/coil/fetch/VideoFrameFetcherTest.kt index c775f698ca..3c283bfaab 100644 --- a/coil-video/src/androidTest/java/coil/fetch/VideoFrameFetcherTest.kt +++ b/coil-video/src/androidTest/java/coil/fetch/VideoFrameFetcherTest.kt @@ -36,6 +36,18 @@ class VideoFrameFetcherTest { fetcher = VideoFrameUriFetcher(context) } + @Test + fun uriFetcherHandlesContentScheme() { + val uri = "content://test/scheme/BigBuckBunny.mp4".toUri() + assertTrue(fetcher.handles(uri)) + } + + @Test + fun uriFetcherDoesNotHandleHttpScheme() { + val uri = "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4".toUri() + assertFalse(fetcher.handles(uri)) + } + @Test fun noSetFrameTime() { // MediaMetadataRetriever.getFrameAtTime does not work on the emulator pre-API 23. diff --git a/coil-video/src/main/java/coil/fetch/VideoFrameFetcher.kt b/coil-video/src/main/java/coil/fetch/VideoFrameFetcher.kt index b84eb65dc8..e90caf344f 100644 --- a/coil-video/src/main/java/coil/fetch/VideoFrameFetcher.kt +++ b/coil-video/src/main/java/coil/fetch/VideoFrameFetcher.kt @@ -38,7 +38,9 @@ class VideoFrameUriFetcher(private val context: Context) : VideoFrameFetcher(context: Context) : Fetcher { // https://developer.android.com/guide/topics/media/media-formats#video-formats @JvmField internal val SUPPORTED_FILE_EXTENSIONS = arrayOf(".3gp", ".mkv", ".mp4", ".ts", ".webm") + @JvmField internal val UNSUPPORTED_SCHEMES = arrayOf("http", "https") + internal const val ASSET_FILE_PATH_ROOT = "android_asset" const val VIDEO_FRAME_MICROS_KEY = VideoFrameDecoder.VIDEO_FRAME_MICROS_KEY