2016-12-28 150 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://开始网址。

该播放器的代码正常工作。