アセットライブラリから映画を再生したい。カメラロールからALAssetを取得し、そのURLをMPMoviePlayerControllerに送信します。
xxxViewController *SelectVC = [[xxxViewController alloc] initWithContentURL: [[mediumAsset defaultRepresentation]url]];
- (id)initWithContentURL:(NSURL *)contentURL
{
self = [super initWithNibName:nil bundle:nil];
if (self)
{
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:contentURL];
[moviePlayer setShouldAutoplay:NO];
[moviePlayer setControlStyle:MPMovieControlStyleFullscreen];
[moviePlayer prepareToPlay];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerLoadStateChanged:)
name:MPMoviePlayerLoadStateDidChangeNotification
object:nil];
}
return self;
}
次のようなエラーメッセージ:
[MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 0, on player: 1)
2012-07-23 19:11:54.194 [5466:907] url assets-library://asset/asset.mov?id=DA201372-BC11-4C0A-B134-B7E89FBC7DAF&ext=mov
2012-07-23 19:11:54.286 [5466:907] [MPAVController] Autoplay: Enabling autoplay
2012-07-23 19:11:54.289 [5466:907] Error (null) setting playback mode to 'AVAudioSessionModeDefault'
2012-07-23 19:11:54.313 [5466:907] [MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 0, on player: 1)
2012-07-23 19:11:54.340 [5466:907] [MPQueuePlayer] Inserting item <AVPlayerItem: 0x209eaae0, asset = <AVURLAsset: 0x209e8f20, URL = assets-library://asset/asset.mov?id=DA201372-BC11-4C0A-B134-B7E89FBC7DAF&ext=mov>> into player <AVQueuePlayer: 0x20a65f90>
2012-07-23 19:11:54.408 [5466:907] [MPQueuePlayer] Items after insertion: (
"<AVPlayerItem: 0x209eaae0, asset = <AVURLAsset: 0x209e8f20, URL = assets-library://asset/asset.mov?id=DA201372-BC11-4C0A-B134-B7E89FBC7DAF&ext=mov>>"
)
2012-07-23 19:11:54.930 [5466:907] [MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 0, on player: 1)
2012-07-23 19:11:54.956 [5466:907] [MPAVController] Autoplay: _streamLikelyToKeepUp: 0 -> 1