如何在我的应用程序中使用MPMoviePlayerController?

时间:2010-07-02 13:20:18

标签: iphone cocoa-touch

我在实现MPMoviePlayerController时遇到了麻烦。我已下载并运行MoviePlayer应用程序,它工作正常,但我无法在自己的应用程序中重现此功能。我添加了MediaPlayer框架并导入到我的应用程序。

以下是我的代码的相关部分:

UITableViewController类:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section==1) {
        MyAppDelegate *appDelegate = 
(MyAppDelegate *)[[UIApplication sharedApplication] delegate];
        [appDelegate initAndPlayMovie:[self localMovieURL]];
    }
}

MyAppDelegate:

-(void)initAndPlayMovie:(NSURL *)movieURL
{
    // Initialize a movie player object with the specified URL
    MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
    if (mp)
    {
        self.moviePlayer = mp;
        [mp release];       
            [self.moviePlayer play];
    }
}

我在

中做了一些调试
- (void) moviePreloadDidFinish:(NSNotification*)notification {
   NSLog(@"moviePreloadDidFinish");
}

并在

- (void) moviePlayBackDidFinish:(NSNotification*)notification {
   NSLog(@"moviePlayBackDidFinish");
}

我注意到电影正确加载并播放,我猜在背景中的某个地方,适当的时间,但我只是看不到电影播放器​​。视图永远不会改变我的TableViewController!

任何想法?请帮忙!!!

0 个答案:

没有答案
相关问题