简体   繁体   中英

Issue while playing video selected from ALAssetLibrary

I get the URL from Asset and try to play selected video.But MPMoviePlayer do not show anything

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

And i get in console:

[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)

Try to call the following method.

[player prepareToPlay];

Calling "prepareToPlay" fixed your problem, Without it, "MPMoviePlayerLoadStateDidChangeNotification" was not being sent because the player didn't bother to preload the video.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM