Skip to content

hpx7/meteor-youtube-iframe-player

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

meteor-youtube-iframe-player

Control YouTube's embedded player using Meteor

Install

Install using Meteor:

$ meteor add hpx7:youtube-iframe-player

Usage

new YTPlayer([name], playerVars)

name is optional and allows you to distinguish between multiple players (ytplayer by default). playerVars are options passed to YouTube's iFrame API.

Now just include {{> YTPlayer name="<my_player_name>"}} in your template where you'd like the player to be rendered. The name parameter is optional and defaults to ytplayer

Examples

To play a song:

Tracker.autorun(function () {
  var yt_id = ... // the video id for a youtube video
  if (yt.ready()) yt.player.loadVideoById(yt_id);
});

To add an event listener:

Tracker.autorun(function () {
  if (yt.ready()) {
    yt.player.addEventListener('onStateChange', function (e) {
      if (e.data === YT.PlayerState.ENDED) {
        // handle the event
      }
    });
  }
});

About

Control YouTube's embedded player using Meteor

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published