2016-06-20 34 views
0

我想从iOS中的服务器播放视频。我已经实施了以下代码MPMoviePlayer中的黑屏

MPMoviePlayerController *movie = [[MPMoviePlayerController alloc] 
            initWithContentURL:[NSURL URLWithString:@"https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"]]; 
[movie.view setFrame:CGRectMake(0, 0, 320, 320)]; 
[self presentMoviePlayerViewControllerAnimated:movie]; 
[movie play]; 
[self.view addSubview:movie.view]; 

但是我越来越黑屏。而我用AVPlayer实现它它的工作原理是什么?

+0

你能尝试删除这一行吗? '[self.view addSubview:movie.view];' –

+0

尽管它不起作用 – remyr3my

+0

创建MPMoviePlayerController *电影的对象;在h文件中,然后使用这个对象。 – aBilal17

回答

0

首先保留你的电影播放器​​对象。 在h文件中使用此行。

@property (strong, nonatomic) MPMoviePlayerController * movie; 

然后在m文件中使用这个对象。也使用这条线。

[moviePlayer prepareToPlay]; 
+0

我也试过了。甚至不工作 – remyr3my