tags:

views:

677

answers:

1

Hello All,

I am programming an iPad app. In this app I want to open a movie URL in default Quicktime player. When I tried to open the URL in the browser the movie starts playing in the browser. How can I open the movie in the default player (so i can get play pause controls..)

Any help would be much appreciated.

Thanks Saurabh

A: 

Finally I think it is not possible to open the quicktime player on iPad. So I searched on google and found MPMoviePlayerViewController class, which solves my problem quite well.

- (void)viewDidLoad {
    NSString *url = [[NSBundle mainBundle]
        pathForResource:@"Stock_Footage_Demobroadband"
                 ofType:@"mp4"];

    MPMoviePlayerViewController *playerViewController =
    [[MPMoviePlayerViewController alloc]
        initWithContentURL:[NSURL fileURLWithPath:url]];

    [[NSNotificationCenter defaultCenter]
        addObserver:self
           selector:@selector(movieFinishedCallback:)
               name:MPMoviePlayerPlaybackDidFinishNotification
             object:[playerViewController moviePlayer]];

    [self.view addSubview:playerViewController.view];

    //---play movie---
    MPMoviePlayerController *player = [playerViewController moviePlayer];
    [player play];

    [super viewDidLoad]; }

- (void) movieFinishedCallback:(NSNotification*) aNotification {
    MPMoviePlayerController *player = [aNotification object];
    [[NSNotificationCenter defaultCenter]
        removeObserver:self
                  name:MPMoviePlayerPlaybackDidFinishNotification
                object:player];
    [player stop];
    [self.view removeFromSuperView];
    [player autorelease]; }

I have posted a complete tutorial my blog http://www.makebetterthings.com/blogs/iphone/play-video-on-iphone-and-ipad/

Saurabh