我正在尝试为 iPad 创建一个简单的应用程序,当您单击按钮时会播放 FLV。我使用来自http://developer.apple.com/iphone/library/codinghowtos/AudioAndVideo/index.html#VIDEO-USE_THE_MEDIA_PLAYER_FRAMEWORK_FOR_VIDEO_PLAYBACK的代码作为参考。这是我的点击事件的代码
-(IBAction) btnPlayVideoClick:(id) sender {
NSString* videoPath = [[NSBundle mainBundle] pathForResource:@"myVideo" ofType:@"flv"];
MPMoviePlayerController* myMovie = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:videoPath]];
myMovie.scalingMode = MPMovieScalingModeAspectFill;
// Register for the playback finished notification.
[[NSNotificationCenter defaultCenter] addObserver:self
selector: @selector(myMovieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:myMovie];
[myMovie play];
}
-(void)myMovieFinishedCallback:(NSNotification*)aNotification
{
MPMoviePlayerController* theMovie=[aNotification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:theMovie];
// Release the movie instance created in playMovieAtURL
[theMovie release];
}
我能够成功编译和运行该应用程序,但是当我单击该按钮时,该应用程序将退出,没有任何错误消息或任何活动。是我做错了什么,还是因为某些原因我无法使用模拟器播放 FLV。我还不能在真实设备上进行测试,因为我正在等待获得开发许可证的批准。
谢谢,
麦克风