Problem Encountered with below action :
[<WebAVPlayerController 0x600001308000> valueForUndefinedKey:]: this class is not key value coding-compliant for the key playingOnMatchPointDevice." 0x00006000025e05a0
Action Tested on iOS 15+:
hit Landscape(Full Screen) icon on the Video and the video crashes when it's full screen
I had been searching and could not find any solution on this problem. I am using WKWebView in Xcode 13. I followed this link iOS15 Webview using `Video` causes crashes - `WebAVPlayerController valueForUndefinedKey - playingOnMatchPointDevice `
But the problem is still not solved. Your help is greatly appreciated.
here the code
import UIKit
import WebKit
class TitlePreviewViewController: UIViewController,WKUIDelegate {
private let titleLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.font = .systemFont(ofSize: 22, weight: .bold)
label.text = "Harry potter"
return label
}()
private let overviewLabel: UILabel = {
let label = UILabel()
label.font = .systemFont(ofSize: 18, weight: .regular)
label.translatesAutoresizingMaskIntoConstraints = false
label.numberOfLines = 0
label.text = "This is the best movie ever to watch as a kid!"
return label
}()
lazy var webView: WKWebView = {
let configuration = WKWebViewConfiguration()
configuration.allowsInlineMediaPlayback = true
let webView = WKWebView(frame:.zero,configuration: configuration)
if #available(iOS 10.0, *) {
configuration.mediaTypesRequiringUserActionForPlayback = []
} else {
configuration.requiresUserActionForMediaPlayback = false
}
webView.translatesAutoresizingMaskIntoConstraints = false
return webView
}()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .systemBackground
view.addSubview(webView)
view.addSubview(titleLabel)
view.addSubview(overviewLabel)
configureConstraints()
webView.uiDelegate = self
webView.navigationDelegate = self
}
func configureConstraints() {
let webViewConstraints = [
webView.topAnchor.constraint(equalTo: view.topAnchor, constant: 50),
webView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
webView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
webView.heightAnchor.constraint(equalToConstant: 300)
]
let titleLabelConstraints = [
titleLabel.topAnchor.constraint(equalTo: webView.bottomAnchor, constant: 20),
titleLabel.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20),
]
let overviewLabelConstraints = [
overviewLabel.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 15),
overviewLabel.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20),
overviewLabel.trailingAnchor.constraint(equalTo: view.trailingAnchor)
]
NSLayoutConstraint.activate(webViewConstraints)
NSLayoutConstraint.activate(titleLabelConstraints)
NSLayoutConstraint.activate(overviewLabelConstraints)
}
public func configure(with model: TitlePreviewViewModel) {
titleLabel.text = model.title
overviewLabel.text = model.titleOverview
guard let url = URL(string: "https://www.youtube.com/embed/\(Video Url )") else {
return
}
webView.load(URLRequest(url: url))
}
}
extension TitlePreviewViewController: WKNavigationDelegate{
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
}
}
Thanks