I have a YouTube player on a webpage created using the YouTube IFrame API
When I get the onStateChange event, as in the code example:
var player; function onYouTubeIframeAPIReady() { player = new YT.Player('player', { height: '390', width: '640', videoId: 'M7lc1UVf-VE', events: { 'onReady': onPlayerReady, 'onStateChange': onPlayerStateChange } });
When onPlayerStateChange is onPlayerStateChange , I would like to be able to distinguish
- The user clicked on the playerβs user interface and changed the state (play, pause, etc.).
- An API call was made to change state (
player.playVideo() , player.pauseVideo() , etc.)
Currently, both results lead to an exact single event.
javascript youtube youtube-api
Ron harlev
source share