【发布时间】:2011-07-15 13:24:29
【问题描述】:
我正在构建一个游戏应用程序,我需要在其中播放动画视频及其相应的声音(可能因情况而异)。我已准备好所有视频和声音文件,但我无法同时播放它们。我正在使用 MPMoviePlayer 播放视频和 AVFoundation 框架来播放音频。有没有同时运行这两个?
对于视频:
MPMoviePlayerViewController *videoController = [[[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:[cellDetails objectForKey:@"AVFile"]]] autorelease];
[self presentMoviePlayerViewControllerAnimated:videoController];
对于声音:
// Instantiates the AVAudioPlayer object, initializing it with the sound
AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: soundFileURL error: nil];
self.appSoundPlayer = newPlayer;
[newPlayer release];
[appSoundPlayer prepareToPlay];
appSoundPlayer.numberOfLoops = -1;
[appSoundPlayer setVolume: self.soundLevel];
[appSoundPlayer setDelegate: self];
[appSoundPlayer play];
谢谢。
【问题讨论】:
-
取决于您使用 AVFoundation 的方式。要发布一些代码吗?
-
请查看已编辑的问题。谢谢!
标签: iphone avfoundation mpmovieplayer