Close Menu
  • Home
  • AI
  • Big Data
  • Cloud Computing
  • iOS Development
  • IoT
  • IT/ Cybersecurity
  • Tech
    • Nanotechnology
    • Green Technology
    • Apple
    • Software Development
    • Software Engineering

Subscribe to Updates

Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

    What's Hot

    Revolutionising IoT Management: A Conversation with Simetric’s Matthew Coleman

    March 5, 2026

    ios – This video is unavilable | Error code: 152 – 4

    March 5, 2026

    Who is the Kimwolf Botmaster “Dort”? – Krebs on Security

    March 4, 2026
    Facebook X (Twitter) Instagram
    Facebook X (Twitter) Instagram
    Big Tee Tech Hub
    • Home
    • AI
    • Big Data
    • Cloud Computing
    • iOS Development
    • IoT
    • IT/ Cybersecurity
    • Tech
      • Nanotechnology
      • Green Technology
      • Apple
      • Software Development
      • Software Engineering
    Big Tee Tech Hub
    Home»iOS Development»ios – This video is unavilable | Error code: 152 – 4
    iOS Development

    ios – This video is unavilable | Error code: 152 – 4

    big tee tech hubBy big tee tech hubMarch 5, 2026002 Mins Read
    Share Facebook Twitter Pinterest Copy Link LinkedIn Tumblr Email Telegram WhatsApp
    Follow Us
    Google News Flipboard
    ios – This video is unavilable | Error code: 152 – 4
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link


    When trying to show youtube video in my app with embeded way, it shows the error code: 152 – 4.
    I just want to make a view where passing the YouTube ID will play the YouTube video inside my app’s specific screens/views. Now this error occurs when trying to play the video.

    Any workaround on this? I can not find any so far.

    My code:

    final class YouTubePlayerViewController: UIViewController, WKNavigationDelegate {
    
        var youtubeId: String
        private var webView: WKWebView!
    
        init(youtubeId: String) {
            self.youtubeId = youtubeId
            super.init(nibName: nil, bundle: nil)
        }
    
        required init?(coder: NSCoder) { fatalError() }
    
        override func viewDidLoad() {
            super.viewDidLoad()
            view.backgroundColor = .black
            setupWebView()
            loadPlayer()
        }
    
        private func setupWebView() {
            let config = WKWebViewConfiguration()
            config.allowsInlineMediaPlayback = true
            config.allowsAirPlayForMediaPlayback = true
            config.allowsPictureInPictureMediaPlayback = true
            config.mediaTypesRequiringUserActionForPlayback = []
    
            // Required — tells WKWebView it is allowed to autoplay / inline play
            let prefs = WKWebpagePreferences()
            prefs.allowsContentJavaScript = true
            config.defaultWebpagePreferences = prefs
    
            webView = WKWebView(frame: view.bounds, configuration: config)
            webView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
            webView.navigationDelegate = self
            webView.scrollView.isScrollEnabled = false
            webView.scrollView.bounces = false
            webView.backgroundColor = .black
            webView.isOpaque = true
            view.addSubview(webView)
        }
    
        func loadPlayer() {
            // The critical trick: we load a real youtube.com URL as the *base*
            // and inject an autoplay embed via HTML. Because the base URL is
            // genuinely youtube.com, WKWebView passes YouTube's origin check.
            let html = """
            
            
              
                
                
              
              
                https://www.youtube.com/watch?v=\(youtubeId)
                
              
            
            """
    
            // baseURL MUST be a real youtube.com origin — this is what fixes Error 152
            webView.loadHTMLString(html, baseURL: URL(string: "
        }
    
        func updateYoutubeId(_ newId: String) {
            guard newId != youtubeId else { return }
            youtubeId = newId
            loadPlayer()
        }
    }
    



    Source link

    Code Error iOS unavilable Video
    Follow on Google News Follow on Flipboard
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Copy Link
    tonirufai
    big tee tech hub
    • Website

    Related Posts

    Apple releases new firmware for AirPods Pro 2 with features for iOS 18

    March 4, 2026

    ios – Swift string truncates / does not hold enough content

    March 4, 2026

    swift – SwiftUI IOS 26 – Menu button floats outside its container during selection animation

    March 3, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    Revolutionising IoT Management: A Conversation with Simetric’s Matthew Coleman

    March 5, 2026

    ios – This video is unavilable | Error code: 152 – 4

    March 5, 2026

    Who is the Kimwolf Botmaster “Dort”? – Krebs on Security

    March 4, 2026

    How AI trained on birds is surfacing underwater mysteries

    March 4, 2026
    About Us
    About Us

    Welcome To big tee tech hub. Big tee tech hub is a Professional seo tools Platform. Here we will provide you only interesting content, which you will like very much. We’re dedicated to providing you the best of seo tools, with a focus on dependability and tools. We’re working to turn our passion for seo tools into a booming online website. We hope you enjoy our seo tools as much as we enjoy offering them to you.

    Don't Miss!

    Revolutionising IoT Management: A Conversation with Simetric’s Matthew Coleman

    March 5, 2026

    ios – This video is unavilable | Error code: 152 – 4

    March 5, 2026

    Subscribe to Updates

    Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

      • About Us
      • Contact Us
      • Disclaimer
      • Privacy Policy
      • Terms and Conditions
      © 2026 bigteetechhub.All Right Reserved

      Type above and press Enter to search. Press Esc to cancel.