         let videoInfo = videoViewController.videoInfo
         guard let nextVideoInfo = videoInfoAfter(videoInfo) else { return nil }
         let newViewController = VideoViewController(videoInfo: nextVideoInfo, client: client)
+        newViewController.viewState.swap(.inactive)
+        newViewController.userPlayState.swap(userPlayState.value)
         return newViewController
     }
     

        
        playerView.frame = view.bounds
    }
    
    func loadVideo() {
        client.rac_getVideoWithIdentifier(videoInfo.id)
            .startWithResult { [weak self] (result: Result<XCDYouTubeVideo, NSError>) in
                guard let this = self else { return }
                guard let streamUrl = result.value?.streamURLs[XCDYouTubeVideoQualityHTTPLiveStreaming] else { return }
                let player = AVPlayer(url: streamUrl)
                this.playerView.player = player
                if this.playWhenReady == true {
                    player.play()
                }
            }
    }
    
    func playVideo() {
        guard let player = self.playerView.player else {
            self.playWhenReady = true
            return
        }
        player.play()
    }
    
    func stopVideo() {
        self.playerView.player?.pause()
    }
    
    func togglePlayPause() {
        guard let player = self.playerView.player else { return }
        let playState = player.rate == 1
        playState ? player.pause() : player.play()
    }
}


    }
    
    private func videoInfoIndex(_ videoInfo: LiveVideoInfo) -> Int? {
        switch viewData.value {
        case .loaded(let infos):
            guard let index = infos.index(where: { $0.id == videoInfo.id }) else { return nil }
            return index
