views:

144

answers:

2

Hi,

I am having a crash issue while playing video in iphone 4.0 OS. Actually, I have created application with base SDK 3.0 and now i am just installing application to 4.0 OS device.

It is not working in that... I have debugged that issue and found that in 4.0 OS, apple change the framework and methods to play the video.

Any one help me how to overcome this issue.

Here is my code which is running fine in 3.0 OS.

-(void)play
    {
     NSBundle *bundle = [NSBundle mainBundle];
     //NSString *path = [bundle pathForResource:@"Icon" ofType:@"png"];
     NSString *path = [bundle pathForResource:@"loader" ofType:@"m4v"];
     NSURL *url = [NSURL fileURLWithPath:path];
     moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
     moviePlayer.scalingMode = MPMovieScalingModeAspectFill;

     [[NSNotificationCenter defaultCenter] addObserver:self 
                selector:@selector(moviePlayBackDidFinish:) 
                 name:MPMoviePlayerPlaybackDidFinishNotification 
                  object:moviePlayer];
     moviePlayer.movieControlMode = MPMovieControlModeHidden;
     [moviePlayer play];
    }

Thanks in advance, Pragnesh

+1  A: 

With iOS4, you need to use the MPMoviePlayerViewController. I posted my working code sample here.

stitz
Ya i understand but my base sdk is 3.1.2 then compiler is giving error for MPMoviePlayerViewController..
Pragnesh Dixit
To become compatible with iOS4, you will need to upgrade your xcode to 3.2.3, set your base SDK to 4.0 and then set your target OS to 3.0. Then the code snippet should work and you should be 4.0 and 3.0 compatible. The MPMoviePlayerViewController is only available in the 4.0 SDK. Lastly, Apple is wanting everyone to upgrade their apps to the 4.0 SDK and that is part od the way you get the "tested on iOS4" label in the AppStore.
stitz
Thank you very much stitz.. now it is working fine
Pragnesh Dixit
A: 

I am facing same problem stitz.

Base sdk is different and giving error MPMoviePlayerViewController.

mitul shah
Mitulshah, are you using 4.0 as your base SDK? The code sample from the link requires it.
stitz
hi,Above Solution is working .thanks stitz
mitul shah
Sagar