title: YouTube embedded video. paused in each second in iOS swift
body: <p>I am using GSPlayer for playing video in background
  screen and I also have to play YouTube video in a view but YouTube video gets amused in each second, if any one can please solve my problem it would be my pleasure,</p>
  <pre><code>DispatchQueue.main.async {
  
      let requestURL = URL(string: &quot;https://www.youtube.com/embed/B-ZbUAZV8R8?autoplay=1&quot;)
      let request = URLRequest(url: requestURL!)
          self.ytWebView.load(request)
      }
  
  func VideoPLayer(url:String,vc:UIViewController,playerView:VideoPlayerView,loop:Bool){
      playerView.isAutoReplay = loop
      playerView.stateDidChanged = { [weak vc] state in
          guard vc != nil else { return }
          
          switch state {
          case .none:
              print(&quot;none&quot;)
          case .error(let error):
              print(error.localizedDescription)
          case .loading:
              print(&quot;loading&quot;)
          case .paused(let playing, let buffering):
              print(&quot;Playing... homeBGVideo&quot;)
              self.StateChanged()
          case .playing:
              print(&quot;playing&quot;)
          }
          switch state {
          case .playing, .paused:
              print(&quot;Play&quot;)
          default:
              print(&quot;Pause&quot;)
          }
      }
      playerView.isMuted = true
      playerView.play(for: URL(string: url)!)
      playerView.addPeriodicTimeObserver(forInterval: CMTime(seconds: 1, preferredTimescale: 60), using: { [weak vc] _ in
          guard vc != nil else { return }
      })
  }
  </code></pre>