流媒体音频时,我看不到MPMoviePlayerController

时间:2014-09-16 10:37:06

标签: audio mpmovieplayercontroller

当我只播放音频时,我无法看到MPMoviePlayerController控件,这是正常的吗?我只能看到一个黑屏,虽然音频正在播放,但是在另一个视图中播放视频时它可以正常工作。我希望这会允许我使用控件,所以我没有必要用AVPlayer构建我自己的UI。

我的代码如下;

self.audioPlayer = [[MPMoviePlayerController alloc] init];
self.audioPlayer.movieSourceType = MPMovieSourceTypeStreaming;
[self.audioPlayer setContentURL:self.audioUrl];
[self.audioPlayer setControlStyle:MPMovieControlModeDefault];
self.audioPlayer.scalingMode = MPMovieScalingModeAspectFit;


[self.audioPlayer.view setFrame:self.view.bounds];

[self.view addSubview:self.audioPlayer.view];
[self.view bringSubviewToFront:self.audioPlayer.view];

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlayBackDidFinish:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:self.audioPlayer];

[self.audioPlayer prepareToPlay];
[self.audioPlayer play];

此致

1 个答案:

答案 0 :(得分:0)

最后我用UI构建了一个AVPlayer,而不是使用MPmovieplayer。