iPhone playing video in custom view: Example Code Please? - iphone

I'm wanting to put together an application which plays video fullscreen with an interface overlaying it that basically chooses the video that is played underneath it (think 'Gym Babes' but nowhere near as risqé!). I don't wish to use private headers so MPMoviePlayerController is out of the question.
I've been digging through stackoverflow for a while and have come to the conclusion that I would need to use some sort of custom codec/video library that I assume would be written in C.
My question is basically has anyone had success doing this? And can anyone share any code, tutorials etc they can share?

You probably want to take a look at AVPlayerLayer: http://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVPlayerLayer_Class/Reference/Reference.html it gives you basic playback abilities with no (read fully customizable) interface…

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!

Get frames from video, edit and save in iPhone

I am referring this application and want to learn that how can we create like this?
Actually there is the major R&D task for me and I don't even know what to search in this topic.
I don't know , from where to start googling.
According to my understandings, the concepts is, It is getting all frames from video as Image and edit it like draw line on it and then save it, so once video is played it also contains that editing.
I had referred this iFrameExtractor but can't got success.
Please advise me how to start doing R&D on this topic..
Thanks in advance.
Ok i have a answer for your question, First of all u have to get all video from your iPhone. That can be done using ALAssetLibrary after that u have to how thee videos in UITableView. I think that should be easy for u. After selecting a video from a table view u have to play that selected video using MPMoviePlayerController or AVPlayer. After that u have to draw anything.There are number of methods of drawing anything on Videos which are:-
UIBezierPathCurve, UIGraphicsBeginImageContext, Open GLes etc etc
Thats it.try googling on it. 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.

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.

Small video playback

From what I have gathered from internets the MPMoviePlayerController class doesn't support small video playback. So, in an effort to beat a dead horse I was wondering what kind of methods could be used to get a small video playing in a corner of the screen without interrupting the rest of the screen.
So far we've come across two solutions that may work: using a UIImageView and flopping images through it like a madman and using a large fullscreen video with all the animations we need already on it and skipping around as needed.
Am I wrong about the MPMoviePlayerController not supporting non-fullscreen video? Is their an easier solution than making UIImageView flip-books? Is cutting around a video a performance hazard?
I think you're stuck with flip books. Pretty sure the fullscreen video issue is a limitation of the hardware video decoder.
After researching for about 1 hour, I didn't find anything. It appears impossible to play video non-fullscreen on the iPhone. I didn't check for openGL ES though.
well.. i have been looking for and haven't found the alternate yet!
But there are some applications already does it!
check TVUlite from TVUNetworks
As I mentioned in another reply, this blog post http://www.nightirion.com/2010/01/scaling-a-movie-on-the-iphone/ mentions a method that will allow you to play non-fullscreen video. However, I'm not sure if this method will be approved by the app store verification process.