我用這個代碼在我的應用程序如何按鈕來添加播放,停止...到視頻
NSURL *movieUrl = [NSURL fileURLWithPath:
[[NSBundle mainBundle] pathForResource:@"myvideoname"
ofType:@"mp4"]];
//create a new instance of MPMoviePlayerController
MPMoviePlayerController* myMovie=[[MPMoviePlayerController alloc]
initWithContentURL:movieUrl];
//disable scaling of our movie
myMovie.scalingMode = MPMovieScalingModeNone;
[myMovie.view setFrame: myView.bounds]; // player's frame must match parent's
[myView addSubview: myMovie.view];
[[myMovie view] setFrame:[myView bounds]];
//don't show any controls
// myMovie.movieControlMode = MPMovieControlModeHidden;
//you can specify at which time the movie should
//start playing (default is 0.0)
myMovie.initialPlaybackTime = 2.0;
//register a callback method which will be called
//after the movie finished
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieFinished:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:myMovie];
myMovie.scalingMode = MPMovieScalingModeAspectFill;
//start the movie (asynchronous method)
[myMovie play];
// Do any additional setup after loading the view from its nib.
它做工精細顯示視頻,但我想添加控件(播放,停止,聲音控制...) 我該怎麼辦? thanx
@Henrik @ texmex5謝謝你的回答。我添加了myMovie.controlStyle = MPMovieControlStyleEmbedded;堅果沒有改變。我havint明白我在哪裏把枚舉:(我把它放在.h,.mi總是有錯誤... – user761812 2011-05-22 22:44:18
你不必添加枚舉到你的頭文件。只有你需要添加的行是myMovie .controlStyle = MPMovieControlStyleEmbeded。 – texmex5 2011-05-23 06:22:56