I'm having a few issues playing a video in MonoTouch. From what I can find there are two different approaches to take. Both result in the audio being played but no video. I'm betting I'm missing something simple so any help would be great.
Attempt one - taken from MT documentation
moviePlayer = new MPMoviePlayerController(new NSUrl("test.mp4"));
moviePlayer.Play();
Attempt two
moviePlayer = new MPMoviePlayerViewController(new NSUrl("test.mp4"));
this.PresentMoviePlayerViewController(moviePlayer);
Thanks
From looking at the documentation, you need to add the MPMoviePlayerController to a view, otherwise the video will no know where to play.
Your second attempt looks a little better, are you calling the play method on the moviePlayer (note this is a MPMoviePlayerViewController) MPMoviePlayerController (named MoviePlayer)?
For what it's worth, I can get;
moviePlayerController = new MPMoviePlayerViewController(new NSUrl("test.mp4"));
this.PresentMoviePlayerViewController(moviePlayerController);
working with no issues on a sample iPad app. Are you sure your test.mp4 is...
Encoded correctly
Included in the project
Video's build action is set to content
Documentation for MPMoviePlayerController: http://developer.apple.com/library/ios/#documentation/MediaPlayer/Reference/MPMoviePlayerController_Class/MPMoviePlayerController/MPMoviePlayerController.html
Documentation for MPMoviewPlayerViewController:
http://developer.apple.com/library/ios/#documentation/MediaPlayer/Reference/MPMoviePlayerViewController_class/Reference/Reference.html#//apple_ref/occ/cl/MPMoviePlayerViewController
Related
i have implemented Custom Video Player feature in my Application that will used to play online videos now i want to implement video buffering feature i am searching for it but not getting proper solution.
So can anyone guide me please.
look into the AVPlayer + AVPlayerLayer classes.
load AVPlayer with the URL of the video.
give it some time to buffer the video before calling the playing method, maybe like this:
[self performSelector:#selector(play:) withObject:nil afterDelay:10.0];
I think MPMoviePlayerController by default supports the streaming feature. Why don't you try that.
Is there any way to add more than 1 video player in a single View? I am getting the .m4v list from server adn have to display that much videos in single page.
It doesnot matter if I play 1 video at a time but which ever video I want must play there itself.
So the videos are placed one below other.
I have tried using mpmoviecontroller but it's drawback is it can have only one instance in the whole applicaiton So if i try to alloc 2 players in a view then the first one does not work and only one player works..
Is there any legal alternate way for the same?
MPMoviePlayerController will allow multiple instances, but only one of them can be playing their movie at any given time.
Please check the link : http://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPMoviePlayerController_Class/MPMoviePlayerController/MPMoviePlayerController.html
I used AVPlayer class (which also MPMoviePlayerController uses under the hood) to successfully play multiple videos from multiple source.
The process of using it is more involved than MPMoviePlayerController, but I would say it is definitely worth to look at if you want some customized behavior in your player. The official programming guide is a good start.
I am using MPMoviePlayerController to stream movie from the internet. And now my first application start to look nice :) BUT :) I have 4 URLs to stream (different movies), and I wan't when I tap to the movie to stop current movie and play another from another URL. Like changing channels on TV. I know how to catch tap, but I don't know how to change URL and start to play movie from that URL (like TV), any help?
I have used this tutorial to make application.
I think setContentURL is the function you're looking for. See:
Apple Documentation on MPMoviePlayerController
use [self.moviePlayer setContentURL:newUrl] to show the next video/movie. It is given in the Apple Documentation on MPMoviePlayerController. :)
I am developing an application for IPAD and I need to play two videos one after another but can not find how. I'm using MPMoviePlayerViewController to do it and do not know how to launch a share after the first video to be played and start the second. Can someone help?
what about using MPMoviePlayerPlaybackDidFinishNotification from documentation ?
In that method:
[..] you can also change the currently playing movie by changing the value in the contentURL property. [..]
(still from documentation)
hope it helps
I want to use AVAudioPlayer to play MP4 files from iTunes generator. I could use UIWebView to play it and it worked, but I want to put an image of my choice on the background of the player instead of the "QuickTime"-logo.
Here is an example of the m4p file I want to play with AVAudioPlayer.
If your question is, "can someone help me figure out how to use AVAudioPlayer," then I'd recommend taking a look at Apple's avTouch sample app, the documentation for AVAudioPlayer, and the guide Getting Started with Audio & Video.
When it happened to me I had a missing '/' on the end of my url. Adding that cleared me right up.