在WKWebView上检测并停止播放视频

发布于 2025-01-21 06:30:12 字数 1157 浏览 4 评论 0原文

我尝试了什么?

  • 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文