Skip to content

Commit

Permalink
enable inline and automatic media playback, refs #540
Browse files Browse the repository at this point in the history
Signed-off-by: weak <weak@fraglab.at>
  • Loading branch information
weakfl committed Feb 20, 2020
1 parent 360730a commit 2c68852
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
20 changes: 0 additions & 20 deletions openHAB/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -538,30 +538,10 @@
<tableViewCellContentView key="contentView" autoresizesSubviews="NO" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="cNS-Yn-KPo" id="Tr2-YU-Z8o">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<wkWebView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="bpq-qh-s5O">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<wkWebViewConfiguration key="configuration">
<dataDetectorTypes key="dataDetectorTypes" none="YES"/>
<audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
<wkPreferences key="preferences"/>
</wkWebViewConfiguration>
</wkWebView>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="bpq-qh-s5O" secondAttribute="trailing" id="4Uf-fM-rFE"/>
<constraint firstItem="bpq-qh-s5O" firstAttribute="top" secondItem="Tr2-YU-Z8o" secondAttribute="top" id="A9l-WE-9nf"/>
<constraint firstAttribute="bottom" secondItem="bpq-qh-s5O" secondAttribute="bottom" id="koD-P3-nTj"/>
<constraint firstItem="bpq-qh-s5O" firstAttribute="leading" secondItem="Tr2-YU-Z8o" secondAttribute="leading" id="rDZ-IY-OZf"/>
</constraints>
</tableViewCellContentView>
<accessibility key="accessibilityConfiguration">
<accessibilityTraits key="traits" notEnabled="YES"/>
</accessibility>
<connections>
<outlet property="widgetWebView" destination="bpq-qh-s5O" id="3bc-MS-NLR"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
Expand Down
14 changes: 13 additions & 1 deletion openHAB/WebUITableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 2c68852

Please sign in to comment.