为视频创建AVPlayer

时间:2013-12-20 01:38:08

标签: ios avplayer

我正在创建一个AVPlayer来显示视频。我有一些代码来创建播放器,但没有任何显示。我不确定网址是否无效或者自己的播放器是否无效。

以下是我用来创建播放器的代码:

self.playing = NO;

AVPlayer *player = [[AVPlayer alloc] init];
player = [player initWithURL:self.videoURL];
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
[[[self view] layer] insertSublayer:playerLayer atIndex:3];
[playerLayer setFrame:self.view.bounds];
[player play];

以下是保存视频的代码:

self.videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
NSLog(@"%@", self.videoURL);

DetailViewController *detailViewController = [[DetailViewController alloc] init];
detailViewController.videoURL = self.videoURL;

0 个答案:

没有答案