Giter Club home page Giter Club logo

ng-youtubeapi.js's Introduction

ng-YouTubeAPI.js

Implementing the YouTube API with AngularJS.

This implementation comes with three directives for different functionality. This implementation is also specifically designed to handle multiple players on one page - there's nothing stopping you from simply using one however.

The ytPlayer Directive

<div data-yt-player="myPlayer" data-yt-vid="MyYouTubeVideoID" data-yt-playervars="{'modestbranding': 1}"></div>

This baby is the actual video player. Give it an ID and the video you want it to load with. You can have as many of these on the page as you wish, just be sure to give each a unique ID.

Crack ng-YouTubeAPI.js open and alter the template as you require.

You can see the full list of player vars here: https://developers.google.com/youtube/player_parameters?playerVersion=HTML5#Parameters

The ytPlayto Directive

<div data-yt-playto="myPlayer" data-yt-vid="anotherVideoID"></div>

This directive allows you to load another video into the stipulated player. Alter the template as needed. Feel free to strip out the $http call if you want to define the video name yourself.

But the API has loadVideoById()??? If you don't need to return any video data, feel free to use it.

The ytSpy Directive

<div data-yt-spy="myPlayer" data-yt-value="title"></div>

This directive allows you to spy on the player in question and retrieve data about it, outside of any template scope. Want your player and 'what's playing now' data in completely different areas? Use this instead, or as well as, the template found in the ytPlayer directive.

API Functions

All the YouTube API functions can be called by passing in the constructor service to your custom directives / controllers:

constructor.players['myPlayer'].playVideo();

They can all be found here: https://developers.google.com/youtube/iframe_api_reference#Playback_controls

ng-youtubeapi.js's People

Stargazers

Christian Bonato avatar Andrej Bartko avatar Matthew Daniels avatar Jesse Clark avatar Paul Preibisch avatar Vincent Ogloblinsky avatar Ayush Narula avatar Yuri avatar

Watchers

Paul Preibisch avatar Patrick Marabeas avatar

ng-youtubeapi.js's Issues

Unecessary API ready broadcast

$window.onYouTubePlayerAPIReady = function() { $rootScope.$broadcast( 'onYouTubePlayerAPIReady' ); };

Not sure why I thought it was necessary to broadcast this, since it's being called - itself - by the very function I could use...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.