//On document ready
document.addEventListener( "DOMContentLoaded", function() {
- var player = Popcorn( Popcorn.vimeo( "player_1" ) )
+ var player = Popcorn( Popcorn.vimeo( "player_1", "http://player.vimeo.com/video/11127501", {
+ width: 500,
+ height: 281
+ }) )
.footnote({
start: 5, // seconds
end: 40, // seconds
</head>
<body>
<div>
- <div id="player_1" width="500" height="281" src="http://player.vimeo.com/video/11127501" ></div><br />
+ <div id="player_1" ></div><br />
<button class="simple" id="btnPlay">Play</button>
<button class="simple" id="btnPause">Pause</button>
<button class="seek" id="btnSeek">Seek to 30</button>
makeSWF.call( self, url, container );
}, 1 );
return;
- }
-
- // The video id for youtube (web or player formats)
- // First check manually given url, if that doesn't work resort to "src"
- this.vidId = this.vidId || extractIdFromUrl( container.getAttribute( "src" ) ) || extractIdFromUri( container.getAttribute( "src" ) );
-
- if ( !this.vidId ) {
- throw "Could not find video id";
}
bounds = container.getBoundingClientRect();
vid.dispatchEvent( "durationchange" );
}
- Popcorn.youtube = function( elementId, url ) {
- return new Popcorn.youtube.init( elementId, url );
+ Popcorn.youtube = function( elementId, url, options ) {
+ return new Popcorn.youtube.init( elementId, url, options );
};
- Popcorn.youtube.init = function( elementId, url ) {
+ Popcorn.youtube.init = function( elementId, url, options ) {
if ( !elementId ) {
throw "Element id is invalid.";
} else if ( /file/.test( location.protocol ) ) {
throw "This must be run from a web server.";
}
+ options = options || {};
+
var self = this;
this.playerId = elementId + Popcorn.guid();
this.loadedData = false;
this.fullyLoaded = false;
+ options.width = options.width && (+options.width)+"px";
+ options.height = options.height && (+options.height)+"px";
+
this._target = document.getElementById( elementId );
this._container = document.createElement( "div" );
this._container.id = this.playerId;
- this._container.style.height = this._target.style.height = this._target.style.height || "350px";
- this._container.style.width = this._target.style.width = this._target.style.width || "460px";
+ this._container.style.height = this._target.style.height = options.height || this._target.style.height || "350px";
+ this._container.style.width = this._target.style.width = options.width || this._target.style.width || "460px";
this._target.appendChild( this._container );
this.offsetHeight = +this._target.offsetHeight;
this.vidId = extractIdFromUrl( url ) || extractIdFromUri( url );
+ if ( !this.vidId ) {
+ throw "Could not find video id";
+ }
+
this.addEventListener( "load", function() {
// For calculating position relative to video (like subtitles)
this.offsetWidth = this.video.offsetWidth;