MPMoviewcontroller and AVPlayer with custom control - ios

Hi sorry for this old question. I have tried to research but still have no solution :(.
I need to implement a video controller with my own control buttons. Base on apple example
I use MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url];
player.controlStyle = MPMovieControlStyleNone; and add my own layer over player.view. There is a problem with my seekForward function. I can not set player.currentPlaybackTime = player.duration (when user press seekForward until reaching the end of the movie). I want to switch to AVPlayer but there is another issues. How can I custom with my own button?. Please help.

I have the same issue with MPMoviePlayerController. Also We can't add more than one MPMoviePlayerController in a same view. For this, I have created a custom player using AVPlayer having basic features. You can download it from my github account HRVideoPlayer. Let me know if you want more detailed version. I have built my own video player having all functionalities like Seeking, volume control, brightness control, replace currentItem, Repeat and shuffle.

Related

AVPlayerLayer Vs AVPlayerViewController

I am new to iOS app developing field. I am trying to capture video using AVFoundation. I am successful in this. But when I tried to play the video back using MPMoviePlayerController, I got too many issues. So I am trying to play using AVPlayer.
But in AVPlayer there are two approaches AVPlayerLayer and AVPlayerViewController.
I tried searching about those, but I didn't get any particular reason to choose one.
Can anyone suggest me which is better to use?
AVPlayerViewController is an all in one solution. You setup your AVPlayer with a video and present the player controller. It handles all the playing and has its own controls baked in (I'm sure you've used seen this in other apps). It is the simplest way to show a video.
AVPlayerLayer is for when you want to add some customization, like adding your own controls or extra views, or not making the video full screen.

radio streaming without MPMoviePlayerController

i am currently doing a small radio shoutcast for android and ios with kony.
everything is fine with android but for ios, i am creating a library to play the shoutcast.
Unfortunatly, it seems that the player of MPMoviePlayerController need to be set as a subview to work and i am unable to do that.
does anybody know an other solution to play a shoutcast on IOS?
I don't know about shoutcast but I imagine its similar to SoundCloud in which you use the API to parse the stream URL? If I'm right in thinking that then you simply need to put the URL into an NSURL and make sure to tell the MPMoviePlayerController the source, like so...
radioPlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:YOUR_SHOUTCAST_STREAM_URL]];
radioPlayer.movieSourceType = MPMovieSourceTypeStreaming;
Then simply play
[radioPlayer prepareToPlay];
Hope that helps :)

How to have video as a background in iOS?

I'm finding it difficult to search for this, background video searches for iOS typically refer to multitasking and switching apps with video.
I want to know if it's possible to have a video playing full screen without movie player controls, while displaying another view on top of that with logo, buttons, text, etc...
So,
Background: 15 second video loop -
Foreground: login / signup buttons, logo, etc...
There are a number of options, but the simplest will be to use a MPMoviePlayerController, with its repeatMode property set to loop forever, and its controlStyle set to none. That will give you a view with a looped movie with no controls that you can use as a background by adding it to your view hierarchy.
OP here - I was able to display a video full screen using this code (in viewDidLoad):
(don't forget to substantiate player as a property with MPMoviePlayerController *player;)
player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"videoname" ofType:#"m4v"]]];
[player.view setFrame: self.view.bounds];
player.repeatMode = MPMovieRepeatModeOne;
player.controlStyle = MPMovieControlStyleNone;
[myView addSubview:player.view];
[player play];
And that worked fine - it displays a video fullscreen without video controls. What I had a problem with was displaying buttons and graphics above that. Even though my view hierarchy had the player.view seemingly behind my view with buttons, I couldn't get the buttons to appear.
I fixed that by adding in:
[player.view addSubview:overlayView];
Just set the layer you intend to display above the video to an IBOutlet and then use the video view to add that view (overlayView in this case) as a subview.
I actually prefer a way that is portrayed in this tutorial
basically the idea is to create a gif of your video, crop it to iPhone Screen size and load it into an un-interactive UIWebView. I believe this will get the job done if you don't need any audio, and it's basically done effortlessly.
I hope it helps you =)

iPad Movie Player Problem

I am playing mp4 files in iPad using MPMoviePlayerController. I have a view connected in IB to play the video files. The problem is that if one of the files is audio-only, it plays fine, but then videos that play after the audio file do not show the play/pause/seek controls.
I am doing this to initialize the view:
self.theMovie = [[MPMoviePlayerController alloc] init];
[self.viewForMovie addSubview:theMovie.view];
Has anyone seen this behavior or have an idea how I can get the video controls to reappear?
Thank you!
You can set the control type with
self.theMovie.controlStyle=MPMovieControlStyleDefault
These are the available options:
MPMovieControlStyleNone
MPMovieControlStyleEmbedded
MPMovieControlStyleFullscreen
MPMovieControlStyleDefault
Details here: http://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPMoviePlayerController_Class/Reference/Reference.html

iPhone SDK: Custom video player controls

In my iPhone app I have designed a custom video player, currently it is very basic with just a play pause and stop button,
but I would like the user to be able to scrub, (I think thats the right word) the video like you can do with apple's original media player.
So for Instance I would like to be able to take a UISlider and have it control the current postiion of the videos playback if you get what I mean. Oh and incase your curious, the way I pause/play/stop the video is by using this simple piece of code [self.theMovie play]; [self.theMovie stop]; [self.theMovie pause]; The trouble is I don't know how to scrub the video.
Any help appreciated.
I've asked the same question: customize quicktime iphone and here MPVideoPlayer add/remove buttons
It seams that you have to posibilities:
You can add you view over the main window. An sample can be found here: MoviePlayer Sample
You can iterate through views, found one you need and Add/Remove views. I don't know yet how must does Apple likes/dislikes this method.

Resources