Vipin
Vipin

Reputation: 4728

Playing a video in ipad

I want to play a movie in my app and the video is stored in my ipad library.

Can anyone provide me the necessary guidance for it?

Upvotes: 0

Views: 339

Answers (2)

Jano
Jano

Reputation: 63667

See a sample of a custom view/viewController combo in Pragmatic iPad Programming. Check the source code for chapter 8 (free download from that page). They use a video provided as a file inside the project. Btw, if the file in the video appears red in XCode, you'll have to remove it and re add it, I think the project definition is a bit screwed.

Upvotes: 0

edc1591
edc1591

Reputation: 10182

  • Get the MPMediaItem of the video you want using MPMediaQuery
  • Get the Asset URL like this:

    NSURL *videoURL = [mediaItem valueForProperty:MPMediaItemPropertyAssetURL];

  • Instantiate an MPMoviePlayerViewController using videoURL as the content URL.

If the video is stored in your App's bundle then do this to get the URL:

NSURL *videoURL = [[NSBundle mainBundle] URLForResource:@"nameoffile" withExtension:@"mp4"];

Upvotes: 1

Related Questions