任何想法爲什麼我可以讓我的AVPlayerViewController類播放內容,但無法讓它顯示播放控件?玩家按預期加載內容,但就是這樣。iOS AVPlayerViewController不顯示播放控件
在我MediaPlayerViewController.m類,我有:
#pragma mark - Player
- (void)setupPlayer{
// Sample URLs to use either a local file or streaming URL
NSURL *url = [[NSBundle mainBundle] URLForResource:@"Besan" withExtension:@"mp4"];
//url = [NSURL URLWithString:@"http://www.youtube.com/watch?v=qcI2_v7Vj2U"];
// Create an instance of the AVPlayer object
self.player = [AVPlayer playerWithURL:url];
// Keep an eye on the status of our player
[self.player addObserver:self forKeyPath:@"status" options:0 context:nil];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
if (object == self.player && [keyPath isEqualToString:@"status"]) {
if (self.player.status == AVPlayerStatusFailed){
NSLog(@"AVPlayer setup failed");
} else if (self.player.status == AVPlayerStatusReadyToPlay) {
NSLog(@"AVPlayer is ready to play");
[self.player play];
}
}
}
我有這個問題也是如此。當您刪除observeValueForKeyPath方法時會顯示控件。現在尋找某種解決方法... – 2014-12-09 17:56:58