views:

887

answers:

2

I am trying to play video without showing controls (volume and other buttons) but it also should be possible to make them visible by taping on the video.

The code is: theMovie.scalingMode = MPMovieScalingModeAspectFill; theMovie.movieControlMode = MPMovieControlModeDefault; In this case it shows the controls by default and by taping on the video they get hidden.

If I change the mode to MPMovieControlModeHidden then I can not see the controls but also I can not bring them back.

Is there a way to start video without controls but not disabling them completely?

A: 

Hello Dmitry!

Tip: look at the bold piece of text if you don't want to know my long story about how boring I am actually starting to look into a problem by reading the documentation and looking into the sample code it offers.

You question has interested me so I started from looking at MPMoviePlayerController Class Reference on iPhone Dev Center. I didn't actually find anything related to the problem you've stumbled upon so I've decided to play around with this sample project MPMoviePlayerController reference - MoviePlayer. I juts wanted to reproduce your situation and maybe try dealing with it by simulating a single touch event or triggering the same method that responds to this event manually.

But it turned out that Apple's sample project in fact behaves absolutely like you want your's to. It starts video playback and the overlay controls are automagically animated out of the screen from the very beginning. I've looked through the code, it's rather simple and doesn't really 'deal' in any way with this problem you have. So maybe it's something you do (or do in somewhat not right order) that causes the problem. Check it out and get back to us with a cure because judging by usefulness metric there are people who have similar problems.

Ivan Karpan
I noticed that a device behaves differently from simulator. Just tried to run the sample project that you have mentioned on the device and the controls are still shown. Although, on a simulator they are hidden.I tried it on several devices - iPhone and iPod Touch both on 3.1.2 - all the same.But I know it should be possible, because in some games, for instance Heroes of Sparta, they do exactly as I want.Any ideas?
Dmitry
OK, understood... I'm still interested in finding an answer for your question so I'll try to implement that touch simulation idea I've mentioned and test it on an iPhone (I have 3G 3.1.2).
Ivan Karpan
+1  A: 

Good news Dmitriy!

I've found a solution that will do the job for you, I hope.

It is as follows:

  1. Initialize your MPMoviePlayerController object's movieControlMode property with MPMovieControlModeHidden value
  2. Play the movie
  3. After the movie playback has started set your MPMoviePlayerController object's movieControlMode property back to MPMovieControlModeDefault

Third step can be accomplished by observing MPMoviePlayerContentPreloadDidFinishNotification notification. Though this might cause unresponsive black screen (or of another color you've set as your MPMoviePlayerController object's backgroundColor) in case you will play a streaming video, which be actually preloaded by MPMoviePlayerController. I don't have any movie of compatible format on a remote server at my disposal right now so I can't test this scenario is real and therefore mess around to see if there's something that can be done to avoid this side effect (though I think I will do that if you publish or find such movie for testing somewhere in the Internet).

Ivan Karpan
Works like a charm. Thanks a lot!
Dmitry
You're welcome. :)
Ivan Karpan