I'm using MPMoviePlayerViewController, When the scale button is clicked for the first time, the icon does not change, making the icon showing as reverse.
This error happend on Simulator and on Device.
I think this is an apple bug i created a small project to reproduce the bug, can be downloaded here
The code i'm using to show the video:
MPMoviePlayerViewController *moviePlayerController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:theFilePath]];
[self presentMoviePlayerViewControllerAnimated:moviePlayerController];
Related
In one of my ViewControllers, I have an AVPlayerViewController. In my viewDidLoad I have
self.videoPlayerController = [AVPlayerViewController new];
Then, I play a video using the following method
- (void)playVideo:(NSURL*)videoURL {
[self presentViewController:self.videoPlayerController animated:YES completion:^(){
AVPlayer *player = [[AVPlayer alloc] initWithURL:videoURL];
[self.videoPlayerController setVideoGravity:AVLayerVideoGravityResizeAspect];
[self.videoPlayerController setPlayer:player];
[self.videoPlayerController.player play];
}];
}
When playing a video for the first time, the AVPlayerViewController appears, but the video is stuck on the first frame, and will not play. No audio plays either.
In iOS 10.0, the seekbar in the on screen controls show that the video is playing (it will progress to the end). In iOS 10.2 however, the seekbar is stuck at 0:00 as well.
I am experiencing this problem on iPads with iOS versions 10.0 and 10.2, however, it works in the XCode simulator (both 10.0 and 10.2).
My problem is similar in nature to this.
Also, the video plays correctly if you close the ViewController containing the AVPlayerViewController, reopen it, and attempt to play the video again.
I guess that the problem is in your video file. Try to download another video mp4 video sample. Add it to your project and try.
Using MPMoviePlayerController, if I make a fullscreen video with ControlStyleFullscreen, then I close it, then I instantiate a new one, the progress bar is gone from the controls in iOS 8 in the second one. This happens 100% of the time. Has anyone else encountered this? Is this an iOS bug? It still happens in 8.2.
Another way to reproduce: using an embedded video with ControlStyleEmbedded, if I run the following code, the progress bar also disappears. Note that the code is intended to force the controls to show after a programmatic pause:
[self.videoPlayer pause];
self.videoPlayer.controlStyle = MPMovieControlStyleNone;
self.videoPlayer.controlStyle = MPMovieControlStyleEmbedded;
I have a tabbed application. Each tab loads a table view controller inside a navigation controller to maintain the upper navigation bar.
The table view controller presents a list of videos. Upon clicking a table cell, the user is presented with a MPMoviePlayerViewController which loads the requested video using the following code:
VideoViewController * playerController = [[VideoViewController alloc] initWithContentURL:url];
[self.navigationController pushViewController:playerController animated:YES];
[playerController.moviePlayer prepareToPlay];
[playerController.moviePlayer play];
UIBarButtonItem *mailButton = [[UIBarButtonItem alloc] initWithTitle:#"Email Link" style:UIBarButtonItemStylePlain target:self action:#selector(openMailBasket:)];
playerController.navigationItem.rightBarButtonItem = mailButton;
Note: VideoViewController is a subclass of MPMoviePlayerViewController.
This works great. However, if I click a tab at the bottom to navigate to another section, then go back to the Videos section, it misbehaves.
In IOS 5, the video starts back at the beginning. This is fine.
In IOS 6, I get a blank video screen that says "Loading..." and never loads.
In IOS 7, I am given a black video player with a total time of 0:00.
Its like the video has been 'unloaded' in IOS 6 and IOS 7. However, if I execute this in viewWillAppear:
NSString *vidURL = [self.moviePlayer.contentURL absoluteString];
NSLog(#"URL: %#",vidURL);
The URL is valid.
Note: I must use MPMoviePlayerViewController instead of MPMoviePlayerController because I need the 'Email Link' button to appear at the top.
Do I need to do anything special to get MPMoviePlayerViewController to maintain the video's state when I navigate elsewhere? Is ARC deallocating my video, and if so, why does it work in IOS 5, and what can I do about it?
Well, apparently typing it out on here led me to find the solution, so I'll lay it out.
I got to thinking about why it was working on IOS 5 and not 6 or 7. It seemed to me that ARC was probably autoreleasing my video data, and I needed a way to tell IOS that I want to bring the movie back.
All I needed to do was add:
-(void)viewWillAppear:(BOOL)animated
{
[self.moviePlayer prepareToPlay];
}
to my VideoViewController class.
I have an MPMoviePlayerController where I load a video from a URL. In iOS 3.2.2 the video started downloading when I added it to a view, but it didn't play until I hit the play button (which is what I want). However, since iOS 4.2.1 came out, it started behaving differently; the video starts downloading and plays automatically.
Here's how I load my MPMoviePlayerController:
MPMoviePlayerController *player = [[MPMoviePlayerController alloc]
initWithContentURL:[NSURL URLWithString:theVideo.fileUrl]];
player.view.frame = articleVideoFrame;
[mainView addSubview:player.view];
I even tried to perform a [player pause]; after the addSubview part, but it still plays automatically. Could you guys help me with this one?
Got it! I used player.shouldAutoplay = NO; and that did the trick. Documentation says it is by default YES, which explains it all. Probably in 3.2 default was NO, but has been switched in 4.2.
I have noticed some other behavior changes in video playback in 4.2.1...namely the video player does not become visible until it starts receiving the data for the movie...
In the previous versions it used to come up instantaneously with "Loading movie..." text on top.
Sometimes, the player gets stuck in when not in full screen mode, with no Done button available or not responding to touches on Pause and Zoom...
I am having other more subtle issues with the playback but I can't isolate the issue just yet...
Hey All,
Im working on an app for the iPad and Ive run across an issue that I need some guidance on. I have an app that uses the TabBarController. The TabBarController contains 4 UIViewController...one for each screen in the app. On each of these 4 screens, there are 4 tiles that need to act as buttons and play a video when clicked. I would like to play the video in a view that hovers over the rest of the screen and is dismissed if the user touches anywhere outside the playing video.
My question is: How do I go about implementing the custom view to play the video? It seems to me that it should be just another view with a viewController...but I dont know if that is the correct way to go about this. Also, how do I get it to play the right video depending on what button was clicked?
Any advice is greatly appreciated.
Thanks
Alex
I'm not sure if I entirely get what the question is, if my answer is not enough please be more precise.
first you initialize your video player view controller class MPMoviePlayerController, then you can do whatever you want with it's .view property, or the container view to display your 4 buttons.
NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:#"someMovie" ofType:#"m4v"];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];
player.view.frame = CGRectMake(someX, someY, someWidth, someHeight);
[self.view addSubview:player.view];
[player play];