Open video in iPhone without controls - iphone

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?

Good news Dmitriy!
I've found a solution that will do the job for you, I hope.
It is as follows:
Initialize your
MPMoviePlayerController object's
movieControlMode property with
MPMovieControlModeHidden value
Play the movie
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).

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.

Related

IPhone disable/hide scrubbar mpmovieplayercontroller in fullscreen mode

I'm creating an iphone app with video clips (among other things) where I need to play one or more ads before the actual video clip. Naturally my client doesn't want users to be able to fast forward during the ads but at the same time they must be able to exit the view so I cant set controlStyle to MPMovieControlStyleNone.
I would prefer not to hack the default view and remove the scrubbar so it seems my only option is to implement a custom bar with a single "Done"/"Back" button.
I've googled my eyes out trying to find example code for this, but no dice. I've seen similar questions posted here as well but no answers are given that could help me out. I'm a novice IOS developer and could really use som help with this (custom control bar with single "Done" button for fullscreen MPMoviePlayerController that shows/hideson tap OR disable scrubbar in an acceptable fashion – in fullscreen mode).
Anyone done this before or know where to find some example code? Thanks!

Export CoreAnimation to video file

I wrote a basic animation framework using Core Animation on iPhone. It has the functionality for pause and resume of animations and also can run animations at specified time. My basic problem is that I cannot find a way to export my animations to a video file (.mov, .avi etc). I have read about AVAssetWriter and AVComposition but cannot understand how to make them work in my case.
By searching the internet the closest I was able to get was it by doing frame by frame reading of my animations. Even for it I could not find a way to make it work and could not find that whether iPhone SDK have something to do that for this kind of frame by frame reading in my case. I also came close to this question on stackoverflow and still could not figure out (sorry if I feel that I am beginner in those things, but I am not, just could not understand some things)
If anyone know how to make it work or even how to something similar to it please share. And if there is no way then if you know any other way to do i.e using OpenGL ES instead of CoreAnimation please share it too.
Check this presentation: http://www.slideshare.net/invalidname/advanced-media-manipulation-with-av-foundation
Around page 84 he talks about adding animation to video compositions. I believe this will help you get what you need.
EDIT: Specifically you need to look at the animationTool of your video composition. This is a AVVideoCompositionCoreAnimationTool object that allows you to add a core animation layer to your output video. See also this question:
Recording custom overlay on iPhone
I am sorry I do not have the time to get you a full code snippet, but basically you set this animation tool of your video composition, and then create an AVAssetExportSession and set its videoComposition to the one you made.

Is it possible to get multiple MPMoviePlayerControllers in the same view?

I have written code so that technically there should be two MPMoviePlayerControllers within the same view, both ready to play an audio file. What always happens is that one pops up and disappears, and the other comes up and stays, and is fully useable.
Any idea why one disappears? I'm not trying to play two at once, just want to give users the option to play from different sources.
There can only be one active MPMoviePlayerController, it won't mind if the user didn't play it yet. I do not know the technical reason, but I do know that this is the normal behavior when you do that.
My advice would be to use AVAudioPlayer to achieve what you want. The sad part if that you will have to implement the UI of the player.

iPhone Smooth Transition from One Video To Another

I have to figure out the best way to transition from one video to the next
BASIC IDEA: An example would be that there is a video of a person walking.....the user taps the video and a seamless transition occurs to a video of a person running (over simplified example)
My first thought was to create 2 movie players and use transitions between the 2 view elements. But movie-player doesn't support that.
stopping the current video, loading new content, and then starting it is a solution but not very elegant. We are making a interactive sales tool for our reps and we want this to look as professional as possible.
CURRENT THOUGHT: If there was some sample code for AVPlayer, it would seem I could use AVVideoComposition to switch between videos? But details on how that might happen don't seem to be currently available.
POSSIBLE CLUE: I figured this would be easy as I bought an app called Live Cams HD that shows 16 different video feeds at once.
Any ideas? Thanks in advance!
Steve, the short answer is that you are not going to be able to get the kind of results you want using AVPlayer. The h.264 video logic included in iOS is really great at playing video and video/audio together, but it really sucks at starting/stopping and switching from one clip to another. The reason is that there is a lot of buffering that needs to happen to load up and start playing a h.264 video in hardware. Basically, you need to roll your own code that sets UIImage/CGImageRef for your views in a way that makes it easy to switch from one clip to another by simply switching from one array of UIImage objects to another. Of course, that is easy to say yet not so easy to implement.
What I would suggest is that you evaluate existing code that already implements this logic instead of rolling your own. For example, have a look at this StreetFighter demo app. It shows how a very simple game like iPhone UI can be constructed using a series of clips that show a character doing a kick, a punch, or throwing a fireball. The results looks like this:
I also wrote up a blog post about seamless-video-looping-on-ios. You can of course roll your own code to do all this, but I would suggest reading more about my library at the linked website as it will save you a lot of time.
After the first video has played every frame except the last one, you quickly swap to a view with an image of the last frame (basically the last frame) and then you transition into a view with the an image of the first frame of the next video and start up that one.
Or you could create a animation with all your frames (programming your videos), that will make it customizable, but the quality will probably not be as good and the cpu usage can spike, so you will have to make a call on that one.

Playing quicktime files with pause points via Keynote (forward and backward)

I have a quicktime file (.mov) generated by Keynote. When played in quicktime, it pauses itself at dozens of pre-defined points waiting for user input. It is basically a slide show with transitions pre-rendered to video.
I want to wrap this in an iPhone app, but see no methods on an MPMoviePlayerController to do anything other than play, which does not pause at the pause points.
Also, I want to be able to play backwards to a prior stop point if the user taps elsewhere on the phone.
Is there a better library for this than MPMoviePlayerController or (deprecated?) UIMoviePlayerController? Or am I overlooking methods that would allow this?
If you think about what you're trying to do, this is actually a fairly complex task. What you're really asking for is the ability to hook up an arbitrary movie playing UI tied to unique gestures, based on the specifics of your movie. I don't think either of the classes in question is going to get you there.
The easiest solution here might be content-based: generate one quicktime movie per "group" of Keynote slides, where each group ends at a pause point, and then it should be pretty easy to interpret gestures to either advance to the next movie (or load it automatically when you reach the end of the last one), or return to the start of the currently playing movie.