# HG changeset patch # User veltr # Date 1328622065 -3600 # Node ID 980163a156d17531635a4be03f784981e4b7f894 # Parent 2ce658b19b9685e549bea74baeb663f76eae6fbb Added Dailymotion support diff -r 2ce658b19b96 -r 980163a156d1 src/js/init.js --- a/src/js/init.js Mon Feb 06 16:05:08 2012 +0100 +++ b/src/js/init.js Tue Feb 07 14:41:05 2012 +0100 @@ -117,7 +117,11 @@ pop = Popcorn.youtube("#" + containerDiv, opts.video, opts); break; - + + case "dailymotion": + pop = new IriSP.PopcornReplacement.dailymotion("#" + containerDiv, options); + break; + case "allocine": /* pass the options as-is to the allocine player and let it handle everything */ pop = new IriSP.PopcornReplacement.allocine("#" + containerDiv, options); diff -r 2ce658b19b96 -r 980163a156d1 src/js/players/player.dailymotion.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/js/players/player.dailymotion.js Tue Feb 07 14:41:05 2012 +0100 @@ -0,0 +1,86 @@ +/* To wrap a player the develop should create a new class derived from +the IriSP.PopcornReplacement.player and defining the correct functions */ + +/** jwplayer player wrapper */ +IriSP.PopcornReplacement.dailymotion = function(container, options) { + /* appel du parent pour initialiser les structures communes à tous les players */ + IriSP.PopcornReplacement.player.call(this, container, options); + + var _this = this; + + /* Définition des fonctions de l'API - */ + + this.playerFns = { + play : function() { + return _this.player.playVideo(); + }, + pause : function() { + return _this.player.pauseVideo(); + }, + getPosition : function() { + return _this.player.getCurrentTime(); + }, + seek : function(pos) { + return _this.player.seekTo(pos); + }, + getMute : function() { + return _this.player.isMuted(); + }, + setMute : function(p) { + return p ? _this.player.mute() : _this.player.unMute(); + } + } + + window.onDailymotionPlayerReady = IriSP.wrap(this, this.ready); + window.onDailymotionStateChange = IriSP.wrap(this, this.stateHandler); + window.onDailymotionVideoProgress = IriSP.wrap(this, this.progressHandler); + + var params = { + allowScriptAccess : "always" + }; + var atts = { + id : this.container + }; + swfobject.embedSWF("http://www.dailymotion.com/swf?chromeless=1&enableApi=1", this.container, options.width, options.height, "8", null, null, params, atts); + +}; + +IriSP.PopcornReplacement.dailymotion.prototype = new IriSP.PopcornReplacement.player("", {}); + +IriSP.PopcornReplacement.dailymotion.prototype.ready = function() { + + this.player = document.getElementById(this.container); + + this.player.addEventListener("onStateChange", "onDailymotionStateChange"); + this.player.addEventListener("onVideoProgress", "onDailymotionVideoProgress"); + this.player.loadVideoByUrl(this._options.video); +}; + +IriSP.PopcornReplacement.dailymotion.prototype.progressHandler = function(progressInfo) { + + this.callbacks.onTime({ + position: progressInfo.mediaTime + }); +} + +IriSP.PopcornReplacement.dailymotion.prototype.stateHandler = function(state) { + + switch(state) { + case 1: + this.callbacks.onPlay(); + break; + + case 2: + this.callbacks.onPause(); + break; + + case 3: + this.callbacks.onSeek(); + break; + + case 5: + this.callbacks.onReady(); + break; + } + +}; diff -r 2ce658b19b96 -r 980163a156d1 src/js/pop.js --- a/src/js/pop.js Mon Feb 06 16:05:08 2012 +0100 +++ b/src/js/pop.js Tue Feb 07 14:41:05 2012 +0100 @@ -27,6 +27,8 @@ this.msgPump = {}; /* dictionnary used to receive and send messages */ this.__codes = []; /* used to schedule the execution of a piece of code in a segment (similar to the popcorn.code plugin). */ + + this._options = options; }; diff -r 2ce658b19b96 -r 980163a156d1 test/integration/polemic-youtube.htm --- a/test/integration/polemic-youtube.htm Mon Feb 06 16:05:08 2012 +0100 +++ b/test/integration/polemic-youtube.htm Tue Feb 07 14:41:05 2012 +0100 @@ -96,9 +96,9 @@ ] }, player:{ - type:'youtube', // player type + type:'dailymotion', // player type // the rest is player-dependent configuration options. - video: "http://www.youtube.com/watch?v=rrkrvAUbU9Y", + video: "http://www.dailymotion.com/video/xodjrx", height: 300, width: 640, }