I am developing an Android App and would like to have a video file (mp4) bundled inside the .apk so that when the app is launched I can play a short intro video.
Unfortunately I'm having trouble figuring out where in my project folder I should place this video file, and also how to access it (the path to the file).
I am using videoView.setVideoPath();
Any help would be greatly appreciated. Thanks
Assets provide a way to include arbitrary files like text, xml, fonts, music, and video in your application. If you try to include these files as "resources", Android will process them into its resource system and you will not be able to get the raw data.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. Step 3 – Right click app >> New >> Folder >> Assets folder.
Android keeps APK files of installed user apps in /data/app directory and system apps in /system/app directory.
It can be noticed that unlike Eclipse ADT (App Development Tools), Android Studio doesn't contain an Assets folder in which we usually use to keep the web files like HTML. Assets provide a way to add arbitrary files like text, XML, HTML, fonts, music, and video in the application.
Put it in res\raw folder. Then in code use this uri: "android.resource://com.mypackagename/raw/myvideosample"
You should put it in /res/raw and access it with
getResources().openRawResource(id)
Find more info here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With