iphone - 如何在从 URL 流式传输音频时全屏显示 MPMoviePlayerController 的事件指示器

标签 iphone ios mpmovieplayercontroller audio-streaming uiactivityindicatorview

我正在使用 MPMoviePlayerController 从 URL 流式传输音频。我将其设置为全屏模式,以便更好地控制 View

        MPMoviePlayerController *audioStreamer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:URL]];
//[audioStreamer.view  setFrame:CGRectMake(0,0,320,460)];
[audioStreamer.view  setFrame:self.view.bounds];

//[self.view addSubview: audioStreamer.view];
[self.view insertSubview:audioStreamer.view belowSubview:HUD.view];
[audioStreamer setFullscreen:YES animated:YES];

//[audioStreamer.view addSubview:HUD.view];

[[NSNotificationCenter defaultCenter] addObserver: self 
                                         selector: @selector(loadStateChanged:) 
                                             name: MPMoviePlayerLoadStateDidChangeNotification 
                                           object: audioStreamer];

[audioStreamer prepareToPlay];

在流式传输和准备播放时,我想显示 UIactivicty Indicator,以便用户考虑加载音频。需要在全屏模式下查看 MPMoviePlayerController 黑屏时事件指示器的任何建议或代码段。

最佳答案

您需要为此实现自己的....

由于这是 Controller ,您可以获得 MPMoviePlayerController 的 View 。只需创建 UIActivityIndi​​catorView 并将其放在 MPMoviePlayerController 的 View 上。请查看代码。

UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
activityIndicator.frame = CGRectMake(140, 200, 50, 21);
[activityIndicator startAnimating];
[self.view addSubview:activityIndicator];
[activityIndicator release];   

一旦电影通过它的委托(delegate)方法开始,就停止这个指示器。

关于iphone - 如何在从 URL 流式传输音频时全屏显示 MPMoviePlayerController 的事件指示器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10703686/

相关文章:

iphone - 为什么 UITabBarController 中的 viewDidAppear 在 View 出现之前执行?

iphone - 如何让特定的 View Controller 同时支持横向和纵向

iphone - 设置缓冲速率 MPMoviePlayerController

ios - 断言失败 : movie player has wrong activation state (1)

iPhone应用程序-使用新项目更新应用程序

Javascript。监听 iPhone 摇动事件?

iphone - 核心动画 : Transferring animating objects to next UIViewController

javascript - 如何在 React Native 上保留/模糊 TextInput 键盘

iphone - 如何重复使用多个 .xib 作为另一个 .xib 的模板?

iPhone - 纵向应用程序,但支持视频的所有方向