开发者

How to use MPMoviePlayerViewController on iOS4(3.1.3 update)

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 *movie开发者_StackOverflowPath = [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.


just add below source to code:-

[themovie.view setFrame: self.view.bounds];  

[self.view addSubview:themovie.view];

Then it will worked sure......

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜