在WKWebView上检测并停止播放视频
我尝试了什么?
- uiscreen.screens.count> 1
Ans : Always getting one even though my app is currently Airplay(ing) on my Macbook
- WKWebView的设置配置
mediaPlaybackAllowsAirPlay = false
allowsAirPlayForMediaPlayback = false
Although the airplay button is not present in the player controls but one can still caste using the control panel airplay button by swipping the screen from above.
- 尝试了此方法广泛用于检测AirPlay,但仅在屏幕镜像无回调的情况下检测到AirPlay。
func isAirplayOn() -> Bool {
let audioSession = AVAudioSession.sharedInstance()
let currentRoute = audioSession.currentRoute
for outputPort in currentRoute.outputs {
if outputPort.portType == AVAudioSession.Port.airPlay {
return true
}
}
return false
}
因此,对我而言,这也行不通。 让我知道如何在WKWebView的音频/视频播放器上检测AirPlay或禁用AirPlay。 任何帮助将不胜感激。    
What I have tried?
- UIScreen.screens.count > 1
Ans : Always getting one even though my app is currently Airplay(ing) on my Macbook
- Setting configuration of WKWebView
mediaPlaybackAllowsAirPlay = false
allowsAirPlayForMediaPlayback = false
Although the airplay button is not present in the player controls but one can still caste using the control panel airplay button by swipping the screen from above.
- Tried this method used widely to detect Airplay but it only detects in case of screen mirroring no callbacks for Airplay.
func isAirplayOn() -> Bool {
let audioSession = AVAudioSession.sharedInstance()
let currentRoute = audioSession.currentRoute
for outputPort in currentRoute.outputs {
if outputPort.portType == AVAudioSession.Port.airPlay {
return true
}
}
return false
}
So to my vain this also does not work.
Let me know how to either detect airplay or disable it on WKWebView's Audio/Video Player.
Any help will be highly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论