0

Problem:

I would like to implement a similar solution that WKWebView has but with SFSafariViewController.

allowsInlineMediaPlayback = false

 let webConfiguration = WKWebViewConfiguration()
 webConfiguration.allowsInlineMediaPlayback = false

How can I implement a similar functionality with Safari Services?

import SafariServices

let bookmark = NSURL(string: youtubeVideoURL)
        let config = SFSafariViewController.Configuration()

        let safari = SFSafariViewController(url: bookmark as! URL)

        if(UIDevice.current.userInterfaceIdiom == .pad) {
            safari.modalPresentationStyle = .fullScreen
        }else{
            safari.modalPresentationStyle = .fullScreen
        }

        self.present(safari, animated: true, completion: nil)

Exactly what I want accomplished is in the code below. However, I am wondering if it can be done with a SFSafariViewController by somehow implementing

allowsInlineMediaPlayback

let youtubeVideoURL = posts[sender.view?.tag ?? 0].youtube_video_url + "?playsinline=1?autoplay=1"
       
        
        var myPlayer: WKWebView!
        
        let webConfiguration = WKWebViewConfiguration()
        webConfiguration.allowsInlineMediaPlayback = false
        webConfiguration.mediaTypesRequiringUserActionForPlayback = []
        
        myPlayer = WKWebView(frame: UIScreen.main.bounds, configuration: webConfiguration)
        self.view.addSubview(myPlayer)
        
        if let mediaURL:URL = URL(string: youtubeVideoURL) {
            let request:URLRequest = URLRequest(url: mediaURL);
            myPlayer.load(request)
        }

Pseudocode:

let config = SFSafariViewController.Configuration()
config.allowsInlineMediaPlayback = false
burnsi
  • 6,194
  • 13
  • 17
  • 27

0 Answers0