如您所知,當我使用MPmoviePlayerController播放影片時,moviePlayer應在moviePlayer'view的中心顯示一個activityIndicatorView。現在,我已將一個自定義activityIndicatorView放入我的程序中,我只想隱藏或移除MPMoviePlayController的activityIndicatorView,我可以這樣做嗎?隱藏MoviePlayerController中的ActivityIndicator
2
A
回答
7
是的,我們可以!
我想你想要做的是在你的電影被加載時顯示活動idicator,而不是當它被播放時?我只是假設並繼續...在SDK 3.2及更高版本中,整個MPMoviePlayerController(和MPMoviePlayerViewController)比以前的版本好很多。如果你仍然使用MPMoviePlayerController,你可以考慮切換到MPMoviePlayerViewController(它基本上是一個包裝MPMoviePlayerController對象的UIView子類)。無論如何,爲了顯示和隱藏你的UIActivityindicator視圖,我建議你掛載到MPMoviePlayerController在負載或playstatus更改時發送的通知。
其中的幾個是:
MPMoviePlayerPlaybackStateDidChangeNotification
MPMoviePlayerLoadStateDidChangeNotification
所以你掛接到這些事件這樣做:
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(loadStateChanged:)
name: MPMoviePlayerLoadStateDidChangeNotification
object: moviePlayerViewController.moviePlayer];
這
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(playBackStateChanged:)
name: MPMoviePlayerPlaybackStateDidChangeNotification
object: moviePlayerViewController.moviePlayer];
和您的處理程序中(playBackStateChanged
和loadStateChanged
)
你可以做這樣的事情:
-(void)playBackStateChanged:(id)sender
{
MPMoviePlaybackState playbackState = [moviePlayerViewController.moviePlayer playbackState];
switch (playbackState) {
case MPMoviePlaybackStateStopped :
break;
case MPMoviePlaybackStatePlaying :
[yourActivityIndicatorView stopAnimating];
break;
case MPMoviePlaybackStateInterrupted :
[yourActivityIndicatorView startAnimating];
break;
}
}
確保「hidesWhenStopped」(或類似)你IndicatorView的屬性被設置爲yes(如果你這樣做,你不必關心和隱藏取消隱藏控制。
其餘的很簡單,只需在您的MPMovieViewController視圖中添加您的activityIndicatorView ontop即可。
希望我能幫助
歡呼
SAM
相關問題
- 1. 使用SDWebImageDownloader顯示和隱藏ActivityIndicator
- 2. 隱藏ActivityIndicator和顯示標題導航欄中
- 3. NSTimer With ActivityIndicator
- 4. TableViewCell中evey UIWebView的ActivityIndicator
- 5. UIWebView中的activityIndicator與TabBar
- 6. iPhone - 加載ActivityIndicator
- 7. IOS:UITableView上的ActivityIndicator ...如何?
- 8. React Native - 「ProgressBarAndroid is deprecated。Use ActivityIndicator instead」
- 9. userinteract stop,直到activityIndicator停止
- 10. 在modalViewController上添加一個activityIndicator iphone
- 11. 在NSXMLParsing期間不顯示ActivityIndicator
- 12. React Native <ActivityIndicator />不可見
- 13. xamarin表單中的ActivityIndicator表單不起作用
- 14. 在XAML或CodeBehind中沒有顯示ActivityIndicator
- 15. 在iPhone SDK中獲得內存分配ActivityIndicator
- 16. 訪問數據庫時的異步數據庫調用/ ActivityIndicator
- 17. ActivityIndicator啓動/停止的優雅檢測動畫
- 18. xcode - 使用「activityIndicator」從服務器重新調用xml
- 19. Nativescript:在頁面轉換正在進行時顯示ActivityIndicator
- 20. NativeScript:顯示ActivityIndicator時禁用所有控件
- 21. 如何僅在webView內容完全加載時停止activityIndicator
- 22. 將新頁面導航到導航時顯示ActivityIndicator
- 23. ReactNative ActivityIndicator不顯示動畫屬性啓動虛假時
- 24. 在整個應用程序中擁有一個ActivityIndicator的好設計
- 25. UIActivityIndicator基於UIWebView的加載不顯示/隱藏
- 26. ShouldAutoplay上MoviePlayerController
- 27. 在調用web服務時使用performSelector for activityIndicator的問題 - IOS
- 28. 告訴ActivityIndicator展現自己,然後導航到另一個頁面
- 29. 隱藏的隱藏欄
- 30. 中隱藏的div
我這樣做,我只想讓moviePlayerViewController的activeIndicator從不顯示,因爲我已經被自己 – ben 2010-07-10 01:33:44
阿添加activeIndicator我想我明白你現在。解決辦法是隱藏你的播放器,直到Movieplayer的Loadstate等於MPMovieLoadStatePlayable,然後再次取消播放器。同時您可以顯示您的自定義加載程序。 – samsam 2010-07-14 09:16:06