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

Queueing functions

Queueing functions allow you to load and play a video, a playlist, or another list of videos. It supports Array and Object syntax

Check Youtube Iframe API Queueing functions for more information

Video

Array Syntax
[(videoId: String), (startSeconds: Number), (suggestedQuality: String)];
Object Syntax
interface Options {
  videoId: String;
  startSeconds: Number;
  endSeconds: Number;
  suggestedQuality: String;
}

Playlists

Array Syntax
[(playlist: String | Array), (index: Number), (startSeconds: Number), (suggestedQuality: String)];
Object Syntax
interface Options {
  list: String;
  listType: String;
  index: Number;
  startSeconds: Number;
  suggestedQuality: String;
}

Usage

For Videos, supported functions are cueVideoById, loadVideoById, cueVideoByUrl, loadVideoByUrl

loadVideo(name, array | object);

For Playlists, supported functions are cuePlaylist, loadPlaylist

loadVideo(name, array | object);

Playback controls and player settings

Define ytPlayer in your controller and assign it to $scope variable $scope.ytPlayer = ytPlayer;

Can be used once the player is ready

app.controller('youtubeCtrl', [
  '$scope',
  'ytPlayer',
  function($scope, ytPlayer) {
    $scope.ytPlayer;

    $scope.$on('ngYoutubePlayer:onPlayerReady', function(event, data, id) {
      $scope.ytPlayer = ytPlayer;
    });
  }
]);

Usage

$scope.ytPlayer['myYoutubePlayer'].playVideo();
Playing a video
play: playVideo();
pause: pauseVideo();
stop: stopVideo();
seekTo: seekTo((seconds: Number), (allowSeekAhead: Boolean));
Playing a video in a playlist
nextVideo: nextVideo();
previousVideo: previousVideo();
playVideoAt: playVideoAt((index: number));
Changing the player volume
mute: mute();
unMute: unMute();
isMuted: isMuted();
setVolume: setVolume((volume: number));
getVolume: getVolume();
Setting the player size
setSize: setSize(width, height);
Setting the playback rate
getPlaybackRate: getPlaybackRate();
setPlaybackRate: setPlaybackRate(playback_rate);
getAvailablePlaybackRates: getAvailablePlaybackRates();
Setting playback behaviour for playlists
setLoop: setLoop((loopPlaylists: Boolean));
setShuffle: setShuffle((shufflePlaylist: Boolean));
Playback status
getVideoLoadedFraction: getVideoLoadedFraction();
getPlayerState: getPlayerState();
getCurrentTime: getCurrentTime();
Playback quality
getPlaybackQuality: getPlaybackQuality();
setPlaybackQuality: setPlaybackQuality((suggestedQuality: String));
getAvailableQualityLevels: getAvailableQualityLevels();
Retrieving video information
getDuration: getDuration();
getVideoUrl: getVideoUrl();
getVideoEmbedCode: getVideoEmbedCode();
Retrieving playlist information
getPlaylist: getPlaylist();
getPlaylistIndex: getPlaylistIndex();
Adding or removing an event listener
addEventListener: addEventListener((event: String), (listener: String));
removeEventListener: removeEventListener((event: String), (listener: String));
Accessing and modifying DOM nodes
getIframe: getIframe();
destroy: destroy();