tags:

views:

717

answers:

3

My iPhone is a iOS4(3.1.3 update). I tryid this code.


#import <UIKit/UIKit.h>

@interface testViewController : UIViewController {
}

@end
//-------------------------------------------------
#import <MediaPlayer/MediaPlayer.h>
#import "testViewController.h"

@implementation testViewController
- (void)viewDidLoad {
  [super viewDidLoad];
  NSBundle *Bundle = [NSBundle mainBundle];
  NSString *moviePath = [Bundle pathForResource:@"test" ofType:@"MOV"];
  NSURL *videoURL = [[NSURL fileURLWithPath:moviePath] retain];

  MPMoviePlayerViewController *theMovie = [[MPMoviePlayerViewController alloc] initWithContentURL:videoURL]; 
  [self presentMoviePlayerViewControllerAnimated:theMovie];
  theMovie.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
  [theMovie.moviePlayer play];
}

- (void)dealloc {
    [super dealloc];
}

@end

when I run the aplication the video didn't work just only plays sound. What is wrong with this code?

Thanks.

A: 

I had the same problem in my app. Here is a link to my solution.

stitz
SUKIYAKI
+1  A: 

I've posted a complete working example that should run on 3.x, 3.2 (iPad) and 4.x devices.

Getting MPMoviePlayerController to Cooperate with iOS4, 3.2 (iPad) and Earlier Versions of iPhone SDK

Hope that helps.

John
Thank you very match Jhon.your sample code is great!!
SUKIYAKI
A: 

Hi stilz,

I have implemented your code in my app(4.0).Its working fine in simulator with local url.But its not working when i call the URL from the server.The video size is 3MB.If i touch,the video page is open and close within a second.

And i got the message from console

"AddRunningClient starting device on non-zero client count"

How can i solve it?

vinay