2013-12-11 126 views
1

選擇我從資產的URL,努力發揮選定video.But MPMoviePlayer不顯示任何問題,同時播放視頻從ALAssetLibrary

 NSString* urlStr = @"assets-library://asset/asset.mp4?id=0685B109-8699-410D-8775-140972AF8397&ext=mp4"; 
    NSURL* movieUrl = [[NSURL alloc] initWithString:urlStr]; 
    MPMoviePlayerController* player = [[MPMoviePlayerController alloc] init]; 
    [player view].backgroundColor = [UIColor clearColor]; 

    player.scalingMode = MPMovieScalingModeNone; 
    player.controlStyle = MPMovieControlModeDefault; 
    player.backgroundView.backgroundColor = [UIColor clearColor]; 
    player.repeatMode = MPMovieRepeatModeNone; 

    [player setContentURL:movieUrl]; 
    [self.view addSubview:player.view]; 

    [player setFullscreen:YES animated:YES]; 
    [player play]; 

和我在控制檯:

[MPAVController] Autoplay: Disabling autoplay for pause 
2013-12-11 15:47:17.575 XavBookXavient[74716:c07] [MPAVController] Autoplay: Disabling autoplay 
2013-12-11 15:47:17.583 XavBookXavient[74716:c07] [MPAVController] Autoplay: Disabling autoplay for pause 
2013-12-11 15:47:17.583 XavBookXavient[74716:c07] [MPAVController] Autoplay: Disabling autoplay 
2013-12-11 15:47:17.587 XavBookXavient[74716:c07] [MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 1, on player: 0) 

回答

0

嘗試調用以下方法。

[player prepareToPlay]; 

呼喚「prepareToPlay」能解決問題,如果沒有它,「MPMoviePlayerLoadStateDidChangeNotification」沒有被髮送,因爲玩家沒有理會,預裝視頻。