CrustyRatFink
CrustyRatFink

Reputation: 534

YouTube iframe API video ad events

What events are issued when a pre-roll ad plays in stream before a video embedded with the YouTube iframe API?

I want to make sure to show the player when the ad plays, but it appears that the ad plays outside of the normal queued, buffering, or playing events.

Upvotes: 1

Views: 1225

Answers (1)

KENdi
KENdi

Reputation: 7771

Based on this SO question, when the video with pre roll ad play, the onStateChange of the video is PAUSED or (2).

The onStateChange event fires whenever the player's state changes. The data property of the event object that the API passes to your event listener function will specify an integer that corresponds to the new player state. Possible values are:

  • -1 (unstarted)
  • 0 (ended)
  • 1 (playing)
  • 2 (paused)
  • 3 (buffering)
  • 5 (video cued).

For more information, just check the this documentation and the SO link above.

Upvotes: 0

Related Questions