2010-09-03 73 views
2

如何在我的應用程序中播放電影?我嘗試使用此代碼,但是Xcode中給了我這個錯誤:MPMoviePlayerViewController問題

NSBundle *bundle = [NSBundle mainBundle]; 
NSString *moviePath = [bundle pathForResource:@"welcome" ofType:@"mp4"]; 
NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain]; 
movieView = [[MPMoviePlayerViewController alloc] initWithContentURL: movieURL]; 
theMovie = [movieView moviePlayer]; 
theMovie.scalingMode = MPMovieScalingModeAspectFit; 
theMovie.fullscreen = TRUE; 
theMovie.controlStyle = MPMovieControlStyleNone; 
theMovie.shouldAutoplay = TRUE; 

[[[UIApplication sharedApplication] keyWindow] addSubview: movieView.view]; 

ERROR

ld: warning: in /Users/Rushil/Documents/StickDeath/MediaPlayer.framework/MediaPlayer, missing required architecture i386 in file 
Undefined symbols: 
    "_OBJC_CLASS_$_MPMoviePlayerViewController", referenced from: 
     objc-class-ref-to-MPMoviePlayerViewController in StickDeathViewController.o 
ld: symbol(s) not found 
collect2: ld returned 1 exit status 

回答

1

請注意,MPMoviePlayerViewController只在iOS3.2及更高版本

仔細檢查了這一點,我認爲這是問題。 More here about MPMoviePlayerViewController

+0

我知道它只適用於ios 3.2及更高版本,但我已將我的部署目標設置爲4.0,因此它只能在4.0設備上運行(僅用於測試此功能),但它仍不起作用 – Rushil 2010-09-03 03:15:05

+0

爲了使這個工作,你必須手動添加另一個視圖控制器或什麼? – Rushil 2010-09-03 03:15:51

+0

我想你錯了。這是一個編譯/編譯錯誤,而不是運行時錯誤,所以你不需要添加另一個viewcontroller。 Xcode只是沒有找到類 – vodkhang 2010-09-03 03:24:55

相關問題