我的应用程序上有动画(mp4)的问题。有时(并非所有时间)应用程序启动时,它会请求麦克风访问,但我不是在应用程序中的任何位置请求。我只使用AVPlayer播放mp4内容。下面的代码是唯一一个与播放器相关的代码。知道为什么我被要求进行麦克风访问吗?谢谢
import UIKit
import Foundation
import MediaPlayer
import AVKit
class AnimationLaunchscreen: UIViewController {
var player: AVPlayer?
override func viewDidLoad() {
super.viewDidLoad()
let timer = Timer.scheduledTimer(timeInterval: 6.0, target: self, selector: #selector(timeToMoveOn), userInfo: nil, repeats: false)
self.loadVideo()
}
@objc func timeToMoveOn() {
self.performSegue(withIdentifier: "goToTableView", sender: self)
}
func loadVideo() {
let path = Bundle.main.path(forResource: "stopwatchAnimation", ofType:"mp4")
let filePathURL = NSURL.fileURL(withPath: path!)
let player = AVPlayer(url: filePathURL)
let playerLayer = AVPlayerLayer(player: player)
playerLayer.frame = self.view.frame
playerLayer.videoGravity = AVLayerVideoGravity.resizeAspectFill
playerLayer.zPosition = -1
self.view.layer.addSublayer(playerLayer)
player.seek(to: CMTime.zero)
player.play()
}
override func viewWillAppear(_ animated: Bool) {
makeStatusBarBlack()
}
}
在这里添加答案,因此比阅读评论更容易找到。这似乎只是模拟器上的一个错误(https://forums.developer.apple.com/thread/110423)。在设备上运行工作正常。