Reputation: 42824
I have a video placed in Assets folder of android
Assets/LanguageResource/MyVideo.mp4
How to find the URI
for the asset file
private void startVideo()
{
//Creating MediaController
mediaController = new MediaController(this);
mediaController.SetAnchorView(video);
video.SetMediaController(mediaController);
video.SetVideoURI(uri);
video.RequestFocus();
video.Start();
}
Upvotes: 0
Views: 5902
Reputation: 16652
The URL
for the asset file should be like this: file:///android_asset/one.mp4
.
And you can get the AbsolutePath
of the file for example like this:
var file = new File(Android.Net.Uri.Parse("file:///android_asset/one.mp4").ToString());
var uri = file.AbsolutePath;
And assets added to your project will show up just like a file system that can read from by app using AssetManager.
If you want to access the stream of this file, you can check the official document like this: Using Android Assets.
Edit:
Sorry, problem is that we cannot play video from assets folder, you need to load it from raw/ resource folder.
Upvotes: 4
Reputation: 16
You can able to find a file from AssetManager of android and get a stream of file directly.
like var br = new BinaryReader(Application.Context.Assets.Open("LanguageResource/MyVideo.mp4");
Upvotes: 0