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 677 forks source link

'-[YTPlayerView playerState]: unrecognized selector sent to instance 0x7f98617bdc60' #465

Open nihp opened 2 years ago

nihp commented 2 years ago

reason: '-[YTPlayerView playerState]: unrecognized selector sent to instance 0x7f98617bdc60'

Getting the below error and unable to play the video in iOS

 YTPlayerView* videosWebView;
 YTPlayerState playerState = videosWebView.delegate;

player state is empty

brol1dev commented 2 years ago

Hi @nihp ,

The code snippet seems incorrect to me, specifically YTPlayerState playerState = videosWebView.delegate; This wouldn't work because delegate is an instance of YTPlayerViewDelegate.

You should be using the playerState (playerState) method instead.

nihp commented 2 years ago

How can I add this and return the state. It would be helpful.

isPlaying = [videosWebView playerState] == kYTPlayerStatePlaying;

How can I handle the above with the completion handler. I am new to this,