2016-12-28 134 views
0

我目前正試圖從URL中檢索.mp4。AVPlayer視頻播放按鈕劃掉

該視頻可以從網絡瀏覽器訪問,但播放按鈕被劃掉。有什麼想法可能會出錯?

代碼有問題

NSURL *movieURL = [NSURL URLWithString:self.videoURL]; 

// create an AVPlayer 
AVPlayer *player = [AVPlayer playerWithURL:movieURL]; 

// create a player view controller 
AVPlayerViewController *controller = [[AVPlayerViewController alloc]init]; 
controller.player = player; 
[player play]; 

// show the view controller 
[self addChildViewController:controller]; 
[self.view addSubview:controller.view]; 
controller.view.frame = self.view.frame; 

截圖設備

iOS Video playback failure

回答

0

我覺得沒有辦法離開的UIWebView在屋裏玩的iOS應用程序的YouTube視頻。您也可以通過將您的視頻url.So的YouTube應用程序將處理的事情其餘

您可以閱讀YouTube部分的準則2點10 here

您可以使用YouTube播放器重定向到YouTube應用here

#import <AVKit/AVKit.h> 
#import <AVFoundation/AVFoundation.h> 

NSURL *movieURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"IMG_0597" ofType:@"mov"]]; 
AVURLAsset *asset = [AVURLAsset assetWithURL:movieURL]; 
AVPlayerItem *item = [AVPlayerItem playerItemWithAsset: asset]; 
AVPlayerViewController *playerViewController = [[AVPlayerViewController alloc] init]; 
AVPlayer *player = [[AVPlayer alloc] initWithPlayerItem: item]; 
playerViewController.player = player; 
[playerViewController.view setFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.width)]; 
playerViewController.delegate=self; 
playerViewController.showsPlaybackControls = YES; 
[self.view addSubview:playerViewController.view]; 
[player play]; 
0

我的視頻沒有播放的原因是因爲在xml中,我正在檢索視頻的網址,因此我沒有使用http://開始網址。

該播放器的代碼正常工作。