I've searched for this question and all the answers are talking about using raw
resource folder.
I need to use the assets
folder because the app loads the video file very slowly. So, I want to reduce the time and show the video directly.
<VideoView
android:id="@+id/vv_video"
android:layout_width="300dp"
android:layout_height="400dp"
android:backgroundTint="@color/white"
android:layout_centerInParent="true" />
Using setVideoPath()
val uri = "file:///android_asset/intro.mp4"
vv_video.setVideoPath(uri)
vv_video.start()
val uri = "android.resource://$packageName/intro.mp4"; // I did try without the extension. But didn't work.
vv_video.setVideoPath(uri)
vv_video.start()
Using setVideoURL()
val uri = "file:///android_asset/intro.mp4"
vv_video.setVideoURI(Uri.parse(uri))
vv_video.start()
val uri = "android.resource://$packageName/intro.mp4"; // I did try without the extension. But didn't work.
vv_video.setVideoURI(Uri.parse(uri))
vv_video.start()
All didn't work. I tried with the raw
folder. And it worked well.
How can I solve this problem? Or is there any way to load video quicker than using raw
??