如何使用Xamarin Android引用我的assets文件夹中的视频文件以在我的videoView上播放。不确定如何正确引用资产文件夹。
public class VideoActivity : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.Video);
var videoView = FindViewById<VideoView> (Resource.Id.SampleVideoView);
var uri = Android.Net.Uri.Parse ("file:///android_asset/big_buck_bunny.mp4");
videoView.SetVideoURI (uri);
videoView.Start ();
}
}
答案 0 :(得分:2)
试试这个:
var descriptor = Assets.OpenFd("big_buck_bunny.mp4");
var mediaPlayer = new MediaPlayer();
mediaPlayer.SetDataSource(descriptor.FileDescriptor, descriptor.StartOffset, descriptor.Length);
mediaPlayer.Prepare();
mediaPlayer.Start();