1

为我的教堂制作一个应用程序,需要从 xml 下载后播放 mp3 文件。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];
4

1 回答 1

2

试试这个..

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");
}
于 2013-04-10T05:55:23.670 回答