Events - sibiraj-s/ng-youtube-embed-iframe GitHub Wiki

Check Youtube Iframe API Events for more details and usage options.

The API fires events to notify your application of changes to the embedded player. The events can be received by following methods

onReady

This event fires whenever a player has finished loading and is ready to begin receiving API calls.

ngYoutubePlayer: onPlayerReady;

// sample
$scope.$on('ngYoutubePlayer:onPlayerReady', function(event, player, id) {
  console.log('player ready');
});

onStateChange

This event fires whenever the player's state changes.

ngYoutubePlayer: onPlayerStateChange;

you can also watch for particular events on state change such as

ngYoutubePlayer: PLAYING;
ngYoutubePlayer: ENDED;
ngYoutubePlayer: UNSTARTED;
ngYoutubePlayer: PAUSED;
ngYoutubePlayer: BUFFERING;
ngYoutubePlayer: CUED;

onPlayerPlaybackQualityChange

This event fires whenever the video playback quality changes.

ngYoutubePlayer: onPlayerPlaybackQualityChange;

onPlaybackRateChange

This event fires whenever the video playback rate changes.

ngYoutubePlayer: onPlaybackRateChange;

onPlayerError

This event fires if an error occurs in the player.

ngYoutubePlayer: onPlayerError;

onApiChange

This event is fired to indicate that the player has loaded (or unloaded) a module with exposed API methods.

ngYoutubePlayer: onApiChange;

The following command retrieves an array of module names for which you can set player options:

$scope.ytPlayer.getOptions();

Example: to retrieve in particular

getOptions('captions');

Retrieving an option:

getOption(module, option);

Setting an option

setOption(module, option, value);