Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I play an mp4 resource with AVPlayer?

I have included an mp4 resource in my project navigator. I want to play it in an AVPlayer. I know how to create an AVPlayerItem for the AVPlayer object, and so now I'd like to load the appropriate AVAsset into it pointing to my mp4 resource. The problem is that AVAsset only has an assetWithURL: method to create an AVAsset. I want an assetWithName: method, but that method does not exist. How can I play my mp4 file if I don't have a URL for it? If it's not possible to play via name reference, how can I get a file URL for my mp4 file?

like image 918
zakdances Avatar asked Jul 26 '12 18:07

zakdances


People also ask

What is Avplayeritem?

An object that models the timing and presentation state of an asset during playback.


1 Answers

To get the URL, use

[[NSBundle mainBundle] URLForResource:@"my_video" withExtension:@"mp4"]
like image 158
Marc Avatar answered Sep 20 '22 04:09

Marc