Url of a Video using PathForResource return null (Xamarin.iOS)

My problem is with a video, I added in the resources folder in my project Xamarin.iOS when I try to call one of this methods for example return null always.

1) var urlpath = NSBundle.MainBundle.PathForResource("video", ofType: "mp4");

2) asset = AVAsset.FromUrl(NSUrl.FromFilename("video.mp4"));

1 - 2) this lines return null always.

Using the simulator. Is like the resources folder not recognise the video like bundle resource. And this is the tricky part because if the resources folder not recognise, the file may be the problem, but the name or the subfolders name are good.

Upvotes: 1

Views: 602

Answers (1)

Reading among many post happened to me, I could not find the solution.

https://bugzilla.xamarin.com/show_bug.cgi?id=24130

Because I'm problem in Visual studio using Xamarin.iOS and with this two steps you can solve this problem in iOS.

1) firt right click over the video select properties

enter image description here

2) second step select in the list Bundle Resources

enter image description here

Basically the problem was that my video have a incorrect Build Action, if you check that you have your name correct and the .PathForResource or any url search file not find your file may be this It´s the problem that you have.

I search the link with the original solution for Swift and Android too when you try to reproduce a video but the url return null.

Upvotes: 2

Related Questions