我想在UIView中嵌入一個AVPlayer並從一個url播放mp4視頻文件。問題是,我只收到一個黑色的空白視圖(見截圖)AVPlayer不會在iOS9上播放來自url的視頻
在它的工作對我以前的IOS版本,但由於升級到iOS9我得到這個問題。
我的.h文件看起來像這樣:
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIView *viewPlayerContainer;
而在我的執行文件我有以下幾點:
@import AVFoundation;
@import AVKit;
@interface ViewController()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
AVPlayerViewController *playerViewController = [[AVPlayerViewController alloc] init];
NSURL *url = [NSURL URLWithString:@"http://techslides.com/demos/sample-videos/small.mp4"];
AVURLAsset *asset = [AVURLAsset assetWithURL: url];
AVPlayerItem *item = [AVPlayerItem playerItemWithAsset: asset];
AVPlayer * player = [[AVPlayer alloc] initWithPlayerItem: item];
[playerViewController.view setFrame:CGRectMake(0, 0, _viewPlayerContainer.bounds.size.width, _viewPlayerContainer.bounds.size.width)];
playerViewController.showsPlaybackControls = NO;
[_viewPlayerContainer addSubview:playerViewController.view];
[player play];
}
我失去了一些東西?
提前致謝!
可能應用的運輸保障。嘗試通過「https:」加載視頻和/或查看http://stackoverflow.com/questions/30731785/how-do-i-load-an-http-url-with-app-transport-security-enabled- in-ios-9 – ChrisH
我已經試過但沒有成功 – Granit
任何東西都會在您的調試器中記錄下來嗎? –