我的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
当我运行应用程序时,视频无法正常播放声音。 这段代码有什么问题?
感谢。
答案 0 :(得分:2)
只需将以下源代码添加到代码中: -
[themovie.view setFrame: self.view.bounds];
[self.view addSubview:themovie.view];
然后它会确定......