【发布时间】:2011-04-11 12:00:34
【问题描述】:
我正在尝试在 MPMoviePlayerController 中播放音频 URL(流式 URL)。 (我知道要播放 AVAudioFramework)。我想显示带有控件的视图,用户可以在其中使用 MPMoviePlayerController 暂停、播放、更改音量等。这就是我使用 MPMoviePlayerController 的原因。 音频正在播放,但我没有看到媒体播放器。为什么? 我正在使用以下代码:
-(void)playMovie:(NSURL *)movieURL attachTo:(UIView*)parentView autoPlay:(BOOL)autoplay showControls:(BOOL)showcontrols repeat:(BOOL)autorepeat autoExit:(BOOL)exit
{
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
moviePlayer.controlStyle = showcontrols ? MPMovieControlStyleEmbedded : MPMovieControlStyleNone;
moviePlayer.repeatMode = autorepeat;
moviePlayer.shouldAutoplay = autoplay;
[moviePlayer play];
[parentView addSubview:moviePlayer.view];
}
【问题讨论】:
标签: iphone media-player audio-streaming