【发布时间】:2015-06-15 23:05:53
【问题描述】:
如果这个问题已经被问过,请原谅我,但我到处找,我只能找到来自 iOS 5.0 的老问题,而人们遇到了相反的问题。
我的问题是我创建了一个我想在我的应用程序中使用的视频,并且我最近添加了音频。视频播放正常,没有问题,但音频不播放。如果我在计算机的任何视频播放器中播放视频,都会有声音,所以我无法弄清楚问题所在。
这是我的代码:
var movieViewController: MPMoviePlayerViewController?
func playVideoUsingViewController() {
if let
path = NSBundle.mainBundle().pathForResource("wakyIntro", ofType: "mp4"),
url = NSURL(fileURLWithPath: path),
movieViewController = MPMoviePlayerViewController(contentURL: url) {
self.movieViewController = movieViewController
movieViewController.moviePlayer.fullscreen = true
movieViewController.moviePlayer.controlStyle = .None
movieViewController.moviePlayer.scalingMode = .AspectFill
movieViewController.view.userInteractionEnabled = false
self.showViewController(movieViewController, sender: self)
println("Movie loaded")
} else {
println("Video failed")
}
}
然后我就从我的 ViewController 中调用它:
func mainMenuViewControllerDidPressPlay(mainMenuViewController: MainMenuViewController) {
game?.runAction(pressButton)
if !videoPlayed{
playVideoUsingViewController()
} else if !gameStarted {
gameStarted = true
game?.bird.startAnimation(game!)
game?.bird.startPhysics()
}
self.hideViewController(mainMenuViewController)
}
任何想法或建议将不胜感激!
【问题讨论】:
-
检查 1 个可能的原因,您的设备是否处于静音模式(静音键已关闭)。这只是一个可能的原因,除了所有与编码相关的东西。
标签: ios swift audio video mpmovieplayercontroller