【问题标题】:How to use MPMoviePlayerViewController on iOS4(3.1.3 update)如何在 iOS 4 上使用 MPMoviePlayerController(3.1.3 更新)
【发布时间】:2010-06-30 14:48:56
【问题描述】:

我的 iPhone 是 iOS4(3.1.3 更新)。 我尝试了这段代码。


#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

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

谢谢。

【问题讨论】:

标签: iphone xcode ios4


【解决方案1】:

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

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

[self.view addSubview:themovie.view];

那么它肯定会工作......

【讨论】:

    猜你喜欢
    • 2012-10-01
    • 2011-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多