ios - MPMoviePlayerController 黑色窗口,不加载音频文件

标签 ios audio video mpmovieplayercontroller loading

为我的教堂制作一个应用程序,需要 mp3 文件从 xml 下载后才能播放。 NSLog 正确显示 url,但是当我运行它时,我只得到一个旋转的“加载”和一个黑框。关于原因有什么建议吗?

谢谢!

-(void)viewDidAppear:(BOOL)animated
{
RSSItem* item = (RSSItem*)self.detailItem;
self.title = item.title;
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:item.link];
NSLog(@"The url is %@", item.link);
moviePlayerController.view.frame = CGRectMake(73, 203, 640, 360);
[self.view addSubview:moviePlayerController.view];
[moviePlayerController prepareToPlay];
moviePlayerController.fullscreen = YES;
[moviePlayerController play];

最佳答案

试试这个..

RSSItem* item = (RSSItem*)self.detailItem;
self.title = item.title;
if(item.link)
{
//NSURL *url = [NSURL fileURLWithPath:item.link];
MPMoviePlayerViewController *moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:item.link];
moviePlayer.view.frame = CGRectMake(0, 0, 500, 500);
moviePlayer.moviePlayer.shouldAutoplay=YES;
moviePlayer.moviePlayer.controlStyle = MPMediaTypeMusicVideo;
[moviePlayer.moviePlayer setFullscreen:YES animated:YES];
[self.view addSubview:moviePlayer.view];
[moviePlayer.moviePlayer play];
}
else
{
NSLog(@"no url");
}

关于ios - MPMoviePlayerController 黑色窗口,不加载音频文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15662129/

相关文章:

iphone - 查找 NSString 中子字符串的所有位置(不仅仅是第一个)

video - 使用 FFmpeg 修剪视频并在其上添加飞旋镖效果

objective-c - 找不到 MediaPlayer/Mediaplayer.h 文件

ios - 使用 Swift,如何禁止弹出键盘?

ios - 检查有效的 vimeo url ios

ios - Swift:如何制作图钉放置位置的自定义标题 View ?

c++ - NAS (with qt/linux)- 无法建立简单的音频服务器连接测试

java - 简单的静音问题?

ios - 如何在iOS SDK中在系统级别更改音频路由?

python-3.x - 我将如何使用 ffpyplayer 播放视频流?