Giter VIP home page Giter VIP logo

mootube's Introduction

MooTube

Takes advantage of Youtube Iframe api to ease make use of it.

How to use

As a simple example, you could use the following lines at Document Head:

<html>
	<head>
		<title>MooTube example</title>
		<script type="text/javascript" src="mootools-core.js" />
		<script rel="javascript" src="mootube.js"></script>
		<script rel="javascript" src="mootube.player.js"></script>
		
		[... whatever else you have in your document head]
	</head>
	
	<body>
		<h1>Youtube Iframe API with MooTools</h1>
		<div id="player"></div>
		
		[... whatever else code you have in your document body]
	</body>
</html>


Youtube Iframe API documentation at:
https://developers.google.com/youtube/iframe_api_reference

How to use

First you need to create an instance of MooTube, which loads the Youtube Iframe API.
var mootube = new MooTube({
	onReady: function() {
		// Youtube Iframe API is ready to go!
	}
});

Once the API is loaded and ready, you can create players on any element in the DOM.
var player = mootube.player('player', {
	video_id: 'OuoytdFfyXs',
	width: 800,
	height: 600,
	playerVars: {
		autoplay: 1,
		theme: 'light'
	},
	// onReady EVENT
	onReady: function() {
		// Video player is ready to listen calls
	}
});

You can see the complete list of player variables to place in 'playerVars' option at:
https://developers.google.com/youtube/player_parameters?playerVersion=HTML5

FUNCTIONS

Every player has the same functions than API, since these are mapped to the Player class.

To read about functions and their parameters, documentation:
https://developers.google.com/youtube/iframe_api_reference#Functions

EVENTS

Every player support same events than API, since these are mapped to the Player class.

var player = mootube.player('player', {
	video_id: 'OuoytdFfyXs',
	// Events
	onReady: function(event) {
		// Do something
	},
	onStateChange: function(event) {
		// Do something
	},
	onPlaybackQualityChange: function(event) {
		// Do something
	},
	onPlaybackRateChange: function(event) {
		// Do something
	},
	onError: function(event) {
		// Do something
	}
});

To read about events, documentation:
https://developers.google.com/youtube/iframe_api_reference#Events

Donations

Donations are welcome. By donating you contribute to this and other Open Source efforts.

mootube's People

Contributors

luiscarlosjayk avatar

Stargazers

 avatar  avatar

Watchers

Ivan Ilic avatar  avatar  avatar James Cloos avatar

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.