From 2c68852b2aca7f931c9b914083f1e5f5957b3191 Mon Sep 17 00:00:00 2001 From: weak Date: Thu, 20 Feb 2020 09:45:19 +0100 Subject: [PATCH] enable inline and automatic media playback, refs #540 Signed-off-by: weak --- openHAB/Base.lproj/Main.storyboard | 20 -------------------- openHAB/WebUITableViewCell.swift | 14 +++++++++++++- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/openHAB/Base.lproj/Main.storyboard b/openHAB/Base.lproj/Main.storyboard index 6529df99d..428044467 100644 --- a/openHAB/Base.lproj/Main.storyboard +++ b/openHAB/Base.lproj/Main.storyboard @@ -538,30 +538,10 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/openHAB/WebUITableViewCell.swift b/openHAB/WebUITableViewCell.swift index 83a6426a8..66d0e66a9 100644 --- a/openHAB/WebUITableViewCell.swift +++ b/openHAB/WebUITableViewCell.swift @@ -16,13 +16,25 @@ import WebKit class WebUITableViewCell: GenericUITableViewCell { private var url: URL? - @IBOutlet private var widgetWebView: WKWebView! + private var widgetWebView: WKWebView! required init?(coder: NSCoder) { super.init(coder: coder) selectionStyle = .none separatorInset = .zero + + let configuration = WKWebViewConfiguration() + configuration.allowsInlineMediaPlayback = true + configuration.mediaTypesRequiringUserActionForPlayback = [] + widgetWebView = WKWebView(frame: contentView.frame, configuration: configuration) + contentView.addSubview(widgetWebView) + + widgetWebView.translatesAutoresizingMaskIntoConstraints = false + NSLayoutConstraint.activate([widgetWebView.leftAnchor.constraint(equalTo: contentView.leftAnchor), + widgetWebView.rightAnchor.constraint(equalTo: contentView.rightAnchor), + widgetWebView.topAnchor.constraint(equalTo: contentView.topAnchor), + widgetWebView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor)]) } override func awakeFromNib() {