gpt4 book ai didi

ios - 如果禁用音频/振动 AVPlayer 不发声 : on

转载 作者:可可西里 更新时间:2023-10-31 23:58:53 27 4
gpt4 key购买 nike

嘿,我想知道是否有办法让播放器发出声音,即使您的 iPhone 设置为静音。是否有 Swift 代码来启用音调?

//IMPOSRT FOUNDATION PER PLAYER
import AVFoundation

let url = NSURL(string: "https://mywebsite.site/file/\(audio_r!)")
playerItem = AVPlayerItem(URL: url!)
player = AVPlayer(playerItem: playerItem!)
let playerLayer = AVPlayerLayer(player: player!)
playerLayer.frame = CGRectMake(0,0,300,50)
self.view.layer.addSublayer(playerLayer)
//imposto il volume
player!.muted = false
player!.volume = 1.0

有人可以帮助我吗?

最佳答案

播放类别不应服从静音开关

AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
AVAudioSession.sharedInstance().setActive(true)

关于ios - 如果禁用音频/振动 AVPlayer 不发声 : on,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40089891/

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