本文介绍了如何在iOS4上使用MPMoviePlayerViewController(3.1.3更新)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iPhone是iOS4(3.1.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

当我运行aplication时视频不起作用只是播放声音。
这段代码有什么问题?

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

谢谢。

推荐答案

只需将以下来源添加到代码中: -

just add below source to code:-

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

[self.view addSubview:themovie.view];

然后它会确定......

Then it will worked sure......

这篇关于如何在iOS4上使用MPMoviePlayerViewController(3.1.3更新)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 06:01