2010-05-28 410 views
0

我正在編寫iPad應用程序。在這個應用程序中,我想在默認的Quicktime播放器中打開電影URL。當我試圖在瀏覽器中打開URL時,電影開始在瀏覽器中播放。如何在默認播放器中打開電影(所以我可以播放暫停控件..)如何在iPad上打開QuickTime播放器

任何幫助將不勝感激。

感謝 SAURABH

回答

0

最後,我認爲這是不可能打開的QuickTime播放器在iPad上。所以我搜索了谷歌,並找到了MPMoviePlayerViewController類,它很好地解決了我的問題。

- (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]; } 

我已經發布了完整的教程我的博客http://www.makebetterthings.com/blogs/iphone/play-video-on-iphone-and-ipad/