任何一个澄清有关Avplayer播放控件

时间:2016-05-05 13:18:26

标签: ios avplayer

我创建了这样的avplayer,但是控件没有显示。任何一个解释是否有任何播放控件我们需要创建自定义播放。

 NSString *path = [[NSBundle mainBundle] pathForResource:@"sample2" ofType:@"mp4"];
_videoURL = [NSURL fileURLWithPath: path];
_videoAsset = [AVURLAsset assetWithURL:_videoURL];
_videoDuration = (int)CMTimeGetSeconds(_videoAsset.duration);
_playerItem = [AVPlayerItem playerItemWithAsset:_videoAsset];
_player = [AVPlayer playerWithPlayerItem:_playerItem];

_playerLayer = [AVPlayerLayer playerLayerWithPlayer:_player];
_playerLayer.frame = CGRectMake(0, self.frame.size.height*0.2, self.frame.size.width, self.frame.size.height*0.3);
[self.layer addSublayer:_playerLayer];
[_player play];
_isPlaying = YES;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(itemDidFinishPlaying:) name:AVPlayerItemDidPlayToEndTimeNotification object:_playerItem];

0 个答案:

没有答案