Я работаю над воспроизведением онлайн-видеофайла с AVplayer с помощью AVMutablecomposition.Видео воспроизводится очень хорошо, когда я играю в браузере, но я не могу воспроизвести его на своем iPad.
Вот код:
self.composition = [AVMutableComposition composition];
NSURL *urlVideo = [NSURL URLWithString:@"{video location}"];
AVURLAsset *videoAsset = [[AVURLAsset alloc]initWithURL:urlVideo options:nil];
AVMutableCompositionTrack *compositionVideoTrack = [composition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
NSError *error = NULL;
AVAssetTrack *videoTrack = [[videoAsset tracksWithMediaType:AVMediaTypeVideo]objectAtIndex:0];
CMTimeRange x = CMTimeRangeMake(kCMTimeZero, [videoAsset duration]);
[compositionVideoTrack insertTimeRange:x ofTrack:videoTrack atTime:kCMTimeZero error:nil];
И код для установки AVPlayer:
AVPlayerItem *playerItem = [[AVPlayerItem alloc]initWithAsset:composition];
self.player = [[AVPlayer alloc]initWithPlayerItem:playerItem];
AVPlayerLayer *layerVideo = [AVPlayerLayer playerLayerWithPlayer:self.player];
layerVideo.frame = self.view.layer.bounds;
layerVideo.backgroundColor = [UIColor orangeColor].CGColor;
layerVideo.position = CGPointMake(1024/2, 768/2-10);
[self.view.layer addSublayer:layerVideo];
[self.player play];
Если я использую "AVPlayerItem * playerItem = [AVPlayerItem playerItemWithAsset: videoAsset];»вместо "AVPlayerItem * playerItem = [[AVPlayerItem alloc] initWithAsset: состав];"тогда я вижу, как воспроизводится видео.
Кто-нибудь знает, как воспроизводить видео, используя AVplayer с AVMutablecomposition?