0

如何引用资产文件夹中的视频文件以使用 Xamarin Android 在我的 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 ();
    }
}
4

1 回答 1

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();
于 2013-10-31T18:11:04.503 回答