gpt4 book ai didi

swift - 在不使用麦克风的情况下请求麦克风访问 - swift

转载 作者:IT王子 更新时间:2023-10-29 05:53:49 24 4
gpt4 key购买 nike

我的应用程序上的动画 (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)。在设备上运行效果很好。

关于swift - 在不使用麦克风的情况下请求麦克风访问 - swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53361159/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com