MPMoviePlayerController Initial Image

In my application, the MPMoviePlayerController instance that I created runs as a black box, looking like this (because the video starts black and disappears):

enter image description here

However, I imagined something more user-friendly, for example, with a thumbnail image, as shown below:

enter image description here

To create the layout I created, but the video in the camera and the videos sent in the Messages application, use the arrow arrow. What class do I need to implement to use the iOS play arrow in stock?

+8
ios mpmovieplayercontroller
source share
3 answers

It looks something like the thumbnailImageAtTime:timeOption: MPMoviePlayerController , you need to pass the time when you want to get the thumbnail and use this image to display the UIImageView on top of the video.

After you create the thumbnail, you will create a UIImageView and set the image to thumbnail and make sure you set userInteractionsEnabled to YES . Be sure to set the frame of this image to close the movie.

Now you can create a UITapGestureRecognizer in this image view that will call the method. This method then calls the play method of your MPMoviePlayerController object.

 -(void)viewDidLoad{ [...] UIImage *thumbnail = [moviePlayer thumbnailImageAtTime:5.0 timeOption:MPMovieTimeOptionNearestKeyFrame]; UIImageView *iv = [[UIImageView alloc] initWithImage:thumbnail]; iv.userInteractionEnabled = YES; iv.frame = moviePlayer.frame; [self.view addSubview:iv]; [iv release]; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)]; tap.numberOfTapsRequired = 1; [iv addGestureRecognizer:tap]; [tap release]; [...] } - (void)handleTap:(UITapGestureRecognizer *)gesture{ iv.hidden = YES; [moviePlayer play]; } 

Note that if you want the play button to click the play button in Photoshop and add it on top of the thumbnail image, attach a gesture recognizer to this image view and make sure you hide both images when you start your video game.

You can use UIButton otherwise with the image set to the playback image, then you do not need UIGestureRecognizer at all.

+6
source share

You will get this arrow by inserting your video into the HTML 5 <video> in the web view.

For a real implementation, see answers like Play embedded video in a UIWebView with HTML5 .

0
source share

How about using UIButton? It can have a nice background image, click on it and move it behind the movie player, or even delete the button. So easy to add even to code

0
source share

All Articles