开发者

How can I make `-[MPMoviePlayerController backgroundView]` to show immediately?

Currently my -[MPMoviePlayerController backgroundView] does not appear until movie loaded enough. So UIActivityIndicatorView which I placed on there does not appear immediately. This drives me crazy. The only solution have been found is placing duplicated indicator-view somewhere开发者_如何学运维 between background-view and -[MPMoviePlayerController view]. But this does not look regular, and definitely a view hierarchy hack which is not guaranteed to work properly. If the background-view shows immediately, all will work magically.

How can I make the background-view immediately before movie loaded?


Do not use the backgroundView but the view of the moviecontroller itself...

Following steps (assuming your MPMovieControllerPlayer instance is called moviePlayerController and your UIActivityIndicatorView instance is called activityIndicatorView)

  • Add your UIActivityIndicatorView on top of the MPMoviePlayerController view (e.g. [moviePlayerController.view addSubview:activityIndixatorView];)

  • Start animating the activity indicator

  • Register for MPMoviePlayerLoadStateDidChangeNotification

  • Within the handler of the above notification, watch out for moviePlayerController.loadState & MPMovieLoadStatePlayable == MPMovieLoadStatePlayable

  • If the above condition is matched, hide your activity indicator


I am not sure but Can a UIActivityIndicator be displayed over a MPMoviePlayerController in full screen mode? may help you a bit

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜