youtube / youtube-ios-player-helper

Lightweight helper library that allows iOS developers to add inline playback of YouTube videos through a WebView
Other
1.64k stars 680 forks source link

When the orientation change, the YTPlayer loads and take time to play.Can we play continuously after orientation without loading? #416

Open rajan271997 opened 3 years ago

rajan271997 commented 3 years ago

I make a tab bar application in which i added the table view to show the videos. When its play , User can change the orientation of the app. But when its change the orientation, the video is loading and take time to play again.

Can we make continuous playing like a youtube , when the orientation change ??

acosmicflamingo commented 3 years ago

This looks to be related to how tab bar behaves. In my app, I am able to change the orientation successfully without having it reload. I wonder if the following can help you debug:

  1. youtubeView.delegate = self
  2. Add the following

`

extension YouTubeView: YTPlayerViewDelegate {

func playerView(_ playerView: YTPlayerView, didChangeTo state: YTPlayerState) {
    switch state {
        case .buffering:
            print("Buffering")
        case .ended:
            print("Ended")
        case .paused:
            print("Paused")
        case .playing:
            print("Playing")
        case .unknown:
            print("Unknown")
        case .unstarted:
            print("Unstarted")
        default:
            break
    }
}

} `

  1. Insert a breakpoint in any of those
  2. Look at the stacktrace to see when it has changed to the loading state