eonil
eonil

Reputation: 85955

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?

Upvotes: 1

Views: 1651

Answers (2)

Till
Till

Reputation: 27597

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

Upvotes: 2

visakh7
visakh7

Reputation: 26390

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

Upvotes: 0

Related Questions