From 5e78c66961e4f09994cc918911844bece7de2812 Mon Sep 17 00:00:00 2001 From: Alesia Date: Tue, 19 Sep 2023 15:16:42 +0300 Subject: [PATCH] fix-bug-with-mp4-video: fix mp4 bug --- .../wtf/flutter/vr_player/VideoPlayerController.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/android/src/main/kotlin/wtf/flutter/vr_player/VideoPlayerController.kt b/android/src/main/kotlin/wtf/flutter/vr_player/VideoPlayerController.kt index 7696507..e44b739 100644 --- a/android/src/main/kotlin/wtf/flutter/vr_player/VideoPlayerController.kt +++ b/android/src/main/kotlin/wtf/flutter/vr_player/VideoPlayerController.kt @@ -230,11 +230,15 @@ class VideoPlayerController( // In our case it will be hls // in case of mpd/wvm formats you have to to call mediaSource.setDrmData method as well if (videoUrl.get("videoPath") != null){ - mediaSource.url = videoUrl.get("videoPath") as String - mediaSource.mediaFormat = PKMediaFormat.mp4 + val url = videoUrl.get("videoPath") as String + val extension = url.substringAfterLast('.', ""); + mediaSource.url = url + mediaSource.mediaFormat = if(extension=="mp4") PKMediaFormat.mp4 else PKMediaFormat.hls } else { - mediaSource.url = videoUrl.get("videoUrl") as String - mediaSource.mediaFormat = PKMediaFormat.hls + val url = videoUrl.get("videoUrl") as String + val extension = url.substringAfterLast('.', ""); + mediaSource.url = url + mediaSource.mediaFormat = if(extension=="mp4") PKMediaFormat.mp4 else PKMediaFormat.hls } return listOf(mediaSource)