AVPlayer视频播放按钮划掉了

时间:2016-12-28 21:20:39

标签: ios objective-c avplayer

我目前正在尝试从网址中检索.mp4。

视频可从网络浏览器访问,但播放按钮已被删除。关于什么可能出错的任何想法?

有问题的代码

 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

2 个答案:

答案 0 :(得分:0)

我认为除了UIWebView之外没有办法在iOS应用程序中播放youtube视频。您也可以通过传递视频网址重定向到youtube应用程序。所以youtube应用程序将处理剩下的事情

您可以阅读YouTube第2节第10点here

的指南

您可以使用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];

答案 1 :(得分:0)

我的视频无法播放的原因是因为在xml中我检索视频的网址时,我没有使用http://启动网址。

此播放器的代码可以正常工作。

相关问题