MP4 file not playing in MPMoviePlayerController? - iphone

I am using MPMoviePlayerController to play .mp4 file, while I'm testing .mp4 recorded in windows platform its working fine, however .mp4 recorded using Android is not playing in my iOS device(iPod touch), Player keeps on buffering it.. Any Idea what could be the problem? And please help me, how to debug the issue in MPMoviePlayerController.
NSURL *file_url = [NSURL fileURLWithPath:filepath];
moviePlayer = [[MPMoviePlayerController alloc]
initWithContentURL:file_url];
moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
// moviePlayer.useApplicationAudioSession = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
thanks

I have found the problem, iOS not supporting the audio format, which is recorded in Android. Now I recorded using AAC it is playing fine.

Related

MPMoviePlayerController interrupting playing audio

I'm developing an iPhone app that can play online videos and
I want to play an ad first when the video data is loading.
First, I request an AdColony video Ad and begin to play it, then use MPMoviePlayerController to load video data, But when the video is prepared to play, it interrupts the previous Ad sound, and causes the ad to stop.
Here are the codes Im using:
// Play Ad first
[AdColony playVideoAdForSlot:1 withDelegate:self]; // It also use MPMoviePlayerController to play video
// Load video for playing
moviePlayer = [[MPMoviePlayerController alloc]
init];
moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
moviePlayer.controlStyle = MPMovieControlStyleNone;
moviePlayer.shouldAutoplay = NO;
moviePlayer.view.frame = CGRectMake(0,44,320,320);
moviePlayer.view.userInteractionEnabled = YES;
[moviePlayer prepareToPlay]; // Interrupt Ad playing
The offical doc said "calling prepareToPlay may interrupt the movie player’s audio session", so the Ad was interrupted. If I remove prepareToPlay, the video data will not be preloaded
I have tried to put
[AdColony playVideoAdForSlot:1 withDelegate:self]; below [moviePlayer prepareToPlay];
but it does not work. Does anyone know how to resolve it?
There are ways to handle interruptions,
read through he Apples guide
http://developer.apple.com/library/ios/#documentation/Audio/Conceptual/AudioSessionProgrammingGuide/HandlingAudioInterruptions/HandlingAudioInterruptions.html#//apple_ref/doc/uid/TP40007875-CH11-SW1

Iphone Videoplayer

I am creating video based ios application.I am using MPMoviePlayerController for playing video. It is working correctly for local video files but I am not able to play the video for the server link please give me some idea
Here is my code
MPMoviePlayerController * player = [[MPMoviePlayerController alloc] init];
NSURL *url = [NSURL URLWithString:imageName];
player.scalingMode = MPMovieScalingModeFill;
[player setContentURL:url];
[player prepareToPlay];
[player play];
if you want using a MPMoviePlayerController implement that server links or streaming.
refer a this sample code. Will help you a lot: MoviePlayer

Can't play mp4 in Cocoa-Touch App

I am trying to play an mp4 after detecting a signal in the audio jack.
The video is playing once, after a delay of 1 sec which i dont want, and then application is freezing and i get this warning on the debugger: (only on the iphone, its working on simulation)
(8F190)/Symbols/System/Library/VideoDecoders/H264H4.videodecoder (file not found).
(8F190)/Symbols/System/Library/VideoDecoders/MP4VH4.videodecoder (file not found).
my code for the video is this :
//play video1
url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"sample1" ofType:#"mp4"]];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
moviePlayer.useApplicationAudioSession=NO;
[moviePlayer prepareToPlay];
moviePlayer.controlStyle = MPMovieControlStyleDefault;
[moviePlayer setMovieControlMode:MPMovieControlModeHidden];
moviePlayer.view.frame = CGRectMake(0, 0, 320, 480);
[self.view addSubview:moviePlayer.view];
[moviePlayer play];
I couldnt find anything on this warning on the net.
I have tried any kind of video encoding,according to the Apple docs.
We just cant play movies, does anyone have any idea how to fix it?
thanks .
If you run that code twice, the video won't play the second time, because you are creating a second MPMoviePlayerController and a second view, and only one MPMoviePlayerController view in your app can play video. So it works the first time but not the second time. You should be retaining your MPMovieVideoController in a property so that you can remove its view and release the MPMovieVideoController before trying to make a new one.

Live Video player

i want to create a Live Video Player.. can any one suggest how to make or any SDk available for live Streaming Video Player
Try this...
Live Streaming to iPhone
http://geobray.com/2010/03/26/live-tv-streaming-to-iphone-with-http/
or this
http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=live+streaming+to+iphone
The native iOS MPMoviePlayerController also supports streaming.
There's plenty of information about it on Google and particularly on Apple's Multimedia Programming Guide
As Hagai said,
You can play the lie streaming using MPMoviePlayerController
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:#"LIVE STREAM LINK"]];
// video player
MPMoviePlayerController *playerViewController = [[MPMoviePlayerController alloc] init];
playerViewController.contentURL = url;
playerViewController.view.frame = CGRectMake(0, 0, 320, 480);
[self.view addSubview:playerViewController.view];
[playerViewController play];
Thats all you need to perform

iPhone:Streaming feed URL sample?

I have a media streaming code like below for playing streaming video. I want to test it with some working streaming url feed on iOS 4 devices. Could someone provide me the exact sample streaming video feed if anything is available for iPhone supported? So that, i can test this code and make sure it works well, though it could be correct. I want a real streaming video url link.
NSString *strUrl = #"http://????????????"
NSURL *url = [NSURL URLWithString:strUrl];
MPMoviePlayerController *mPlayer = [[MPMoviePlayerController alloc]initWithContentURL:url];
mPlayer.view.frame = self.view.frame;
[self.view addSubview:mPlayer.view];
[mPlayer setFullscreen:YES animated:YES];
[mPlayer play];
Thanks.
I don't have a URL for you, but your code looks correct, except that you should turn auto-play off before setting full screen with animation. In my experience, the app could crash on setFullscreen:animated: if you use the player more than once. You might also want to observe the MPMoviePlayerPlaybackDidFinishNotification notification in case of playback error so that you can inform the user that there was a playback error.
NSURL *url = [NSURL URLWithString:strUrl];
MPMoviePlayerController *mPlayer = [[MPMoviePlayerController alloc]initWithContentURL:url]; mPlayer.view.frame = self.view.frame;
mPlayer.shouldAutoplay = NO;
[self.view addSubview:mPlayer.view];
[mPlayer setFullscreen:YES animated:YES];
[mPlayer play];
You can use below urls for testing purpose,
http://a1408.g.akamai.net/5/1408/1388/2005110405/1a1a1ad948be278cff2d96046ad90768d848b41947aa1986/sample_mpeg4.mp4
I have not tested it, but it should work well...