Iphone MPMoviePlayerController-无法在<;上的我的应用程序中播放电影;3GS(3GS可以)

Iphone MPMoviePlayerController-无法在<;上的我的应用程序中播放电影;3GS(3GS可以),iphone,mpmovieplayercontroller,Iphone,Mpmovieplayercontroller,在我的应用程序中,我播放了一些电影。我已经检查了电影的信息,它们似乎在MPMoviePlayerController应该能够处理的范围内(比特率等) 他们是从一个URL流式传输的,它只会在3GS上播放,不会更低。我已尝试从MPMoviePlayerController中收集mpmovieplayercontentpreload-didfinishnotification和MPMoviePlayerPlaybackDidFinishNotification的通知中的错误,但我得到了通知中的user

在我的应用程序中,我播放了一些电影。我已经检查了电影的信息,它们似乎在
MPMoviePlayerController
应该能够处理的范围内(比特率等)

他们是从一个URL流式传输的,它只会在3GS上播放,不会更低。我已尝试从
MPMoviePlayerController
中收集
mpmovieplayercontentpreload-didfinishnotification
MPMoviePlayerPlaybackDidFinishNotification
的通知中的错误,但我得到了通知中的
userInfo
键的无用错误字符串,这只告诉我这部电影不能播放的事实

我正在测试的URL是:

在3G或2G iPhone上,MPMoviePlayerController会出现,它会短暂地尝试加载电影,但随后会淡出到它所在的视图控制器

有人知道为什么我不能在3GS上传输和播放上面的URL吗?我确信这是内存问题,但我已经在2G iPhone上试用过了,但它仍然无法工作

我正在使用苹果自己的流媒体电影示例应用程序中的一段代码来启动这部电影:

MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"http://movies.apple.com/movies/independent/lawabidingcitizen/lawabidingcitizen_h.480.mov"];
if (mp) {
    self.moviePlayer = mp;
    [mp release];
    [self.moviePlayer play];
}

谢谢

我认为发布部分给您带来了麻烦,我正在使用此代码,工作正常:

moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];

    //// //// //// //// //// //// //// //// //// //// //// //// //// //// //// //// /
    // ONLY FOR IOS 3.2 or later
    if ( kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iPhoneOS_3_2 ) {

        // May help to reduce latency
        [moviePlayer prepareToPlay];

        /// //// //// //// //// //// //// //// //// //// //// //// //// //// /
        // Set the correct frame for Movie Controller.
        moviePlayer.view.frame = self.view.frame;

        /// //// //// //// //// //// //// //// //// //// //// //// //// //// /
        // Autorezing the view, allows him to adjust with the orientation.
        moviePlayer.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        moviePlayer.view.autoresizesSubviews = YES;

        /// //// //// //// //// //// //// //// //// //// //// //// //// //// /
        // Add to screen.
        [self.view addSubview:moviePlayer.view];
    } 

    //// //// //// ///// //// //// ///// //// //// ///// //// //// ///// //// //// /
    // Older than 3.2
    else {
        // Play Movie.
        [moviePlayer play];

        // Register to receive a notification when the movie has finished playing. 
        [[NSNotificationCenter defaultCenter] addObserver:self 
                                                 selector:@selector(moviePlayBackDidFinish:) 
                                                     name:MPMoviePlayerPlaybackDidFinishNotification 
                                                   object:nil];
    }
此代码是为所有IOS准备的。如果仅支持<3.2,请使用正确的零件

您应该实现一个方法
movieplaybackdidfish:
,以便在电影结束播放时接收通知,如下所示:

//// //// //// ///// //// //// ///// //// //// ///// //// //// ///// //// //// /
// Notification called when the movie finished playing. This Call is only for iOS 3.2
- (void) moviePlayBackDidFinish:(NSNotification*)notification {
    // Unregister. 
    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:MPMoviePlayerPlaybackDidFinishNotification
                                                  object:nil];

    // Your finish code here.
}
您必须在UIViewController
@界面中声明
moviePlayer
,并在
dealloc:
方法中声明dealloc