Youtube WKWEbView在iOS中隐藏本机播放器的控件
我正在iOS应用程序中复制Youtube视频。我面临的问题是,当视频在iOS的本机视频播放器中播放时 这对我来说没关系,但我想禁用本机播放器中的控件,这样用户就不能跳过视频了 这可能吗 这是我的代码:Youtube WKWEbView在iOS中隐藏本机播放器的控件,youtube,embed,wkwebview,Youtube,Embed,Wkwebview,我正在iOS应用程序中复制Youtube视频。我面临的问题是,当视频在iOS的本机视频播放器中播放时 这对我来说没关系,但我想禁用本机播放器中的控件,这样用户就不能跳过视频了 这可能吗 这是我的代码: func setUpUI() { let webConfiguration = WKWebViewConfiguration() webConfiguration.allowsInlineMediaPlayback = true webView =
func setUpUI() {
let webConfiguration = WKWebViewConfiguration()
webConfiguration.allowsInlineMediaPlayback = true
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
webView.backgroundColor = .red
self.backgroundColor = .white
webView.translatesAutoresizingMaskIntoConstraints = false
self.contentView.addSubview(mainContainer)
mainContainer.addSubview(lineSeparator)
mainContainer.addSubview(bottomLineSeparator)
mainContainer.addSubview(videoIcon)
mainContainer.addSubview(watchItAll)
mainContainer.addSubview(videoContainer)
videoContainer.addSubview(videoTitleContainer)
videoContainer.addSubview(webView)
videoTitleContainer.addSubview(videoTitleLabel)
lineSeparator.backgroundColor = .lightGreyBkgrnd
lineSeparator.layer.borderColor = UIColor.lightGreyBkgrnd.cgColor
lineSeparator.layer.borderWidth = 3
videoContainer.layer.borderColor = UIColor.dimGray.cgColor
videoContainer.layer.borderWidth = 2
bottomLineSeparator.backgroundColor = .lightGreyBkgrnd
bottomLineSeparator.layer.borderColor = UIColor.lightGreyBkgrnd.cgColor
bottomLineSeparator.layer.borderWidth = 3
self.videoTitleLabel.font = UIFont.preferredFont(forTextStyle: .headline)
self.videoTitleLabel.textColor = UIColor.tuftsBlue
videoPlayerSuperView.translatesAutoresizingMaskIntoConstraints = false
self.watchItAll.font = UIFont.preferredFont(forTextStyle: .body)
self.watchItAll.numberOfLines = 0
//videoContainer.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(videoTapped)))
let html = """
<iframe width="100%" height="100%" src="https://www.youtube.com/embed/0oBx7Jg4m-o?autoplay=0&showinfo&controls=0" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
"""
webView.loadHTMLString(html, baseURL: nil)
}
func setUpUI(){
让webConfiguration=WKWebViewConfiguration()
webConfiguration.allowsInlineMediaPlayback=true
webView=WKWebView(帧:.0,配置:webConfiguration)
webView.uiDelegate=self
webView.backgroundColor=.red
self.backgroundColor=.white
webView.translatesAutoresizingMaskIntoConstraints=false
self.contentView.addSubview(maincainer)
mainContainer.addSubview(行分隔符)
mainContainer.addSubview(底线分隔符)
mainContainer.addSubview(视频图标)
mainContainer.addSubview(WatchiAll)
mainContainer.addSubview(视频容器)
videoContainer.addSubview(videoTitleContainer)
videoContainer.addSubview(webView)
videoTitleContainer.addSubview(videoTitleLabel)
lineSeparator.backgroundColor=.lightGreyBkgrnd
lineSeparator.layer.borderColor=UIColor.lightGreyBkgrnd.cgColor
lineSeparator.layer.borderWidth=3
videoContainer.layer.borderColor=UIColor.dimGray.cgColor
videoContainer.layer.borderWidth=2
bottomLineSeparator.backgroundColor=.lightGreyBkgrnd
bottomLineSeparator.layer.borderColor=UIColor.lightGreyBkgrnd.cgColor
bottomLineSeparator.layer.borderWidth=3
self.videoTitleLabel.font=UIFont.preferredFont(forTextStyle:.headline)
self.videoTitleLabel.textColor=UIColor.tuftsBlue
videoPlayerSuperView.TranslatesAutoResizengMaskintoConstraints=错误
self.watchItAll.font=UIFont.preferredFont(forTextStyle:.body)
self.watchItAll.numberOfLines=0
//videoContainer.AddGestureRecognitor(UITapGestureRecognitor(目标:self,操作:#选择器(videoTapped)))
让html=”“”
"""
loadHTMLString(html,baseURL:nil)
}
如果您使用的是AVPlayerViewController来播放视频,它有一个属性
open var showsPlaybackControlls: Bool
您可以设置为NO以隐藏用户控件
此外,如果突出显示该类并选择“转到定义”,您将看到您可能想要决定使用的该类的其他函数和属性。AVPlayer不会复制YouTube视频。我的问题我已经编辑了我的问题并添加了相关代码。