如何接收有关内联播放器的通知

时间:2019-02-09 15:54:47

标签: swift xcode wkwebview

我有专用按钮将播放类型更改为inline = false,当我执行此本机播放器以充当我的视频播放器的全屏显示时,但是退出该播放器时,视频将在嵌入式播放中停止播放器,并且由于我们不允许控件,因此用户无法手动恢复。关闭本机播放器后,有什么方法可以接收通知,以便可以通过重新加载内联播放器来恢复代码中的播放?

这是我通过调用loadLiveStream进行内联播放和loadStreamFullScreen进行本机播放的方式来加载不同格式的视频的方法。

func loadLiveStream(streamID: String) {

    player.configuration.allowsInlineMediaPlayback = true
    print("Stream ID has changed to: \(streamID)")
    let htmlString = "https://player.twitch.tv/?channel=\(streamID)&controls=false"
    player.load(URLRequest(url: URL(string: htmlString)!))
}

func loadStreamFullscreen(streamID: String) {
    player.configuration.allowsInlineMediaPlayback = false

    print("Stream ID has changed to: \(streamID)")
    let htmlString = "https://player.twitch.tv/?channel=\(streamID)&controls=false&playsinline=false"
    player.load(URLRequest(url: URL(string: htmlString)!))
}

0 个答案:

没有答案