new player version with support for dailymotion.
authorhamidouk
Wed, 08 Feb 2012 11:46:17 +0100
changeset 540 364036384cb6
parent 537 8589160ac9e3
child 541 ee852fed0ea5
new player version with support for dailymotion.
src/ldt/ldt/static/ldt/js/LdtPlayer-release.js
--- a/src/ldt/ldt/static/ldt/js/LdtPlayer-release.js	Mon Feb 06 16:03:56 2012 +0100
+++ b/src/ldt/ldt/static/ldt/js/LdtPlayer-release.js	Wed Feb 08 11:46:17 2012 +0100
@@ -1315,6 +1315,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;
                           
 };
 
@@ -2014,7 +2016,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);
@@ -2154,7 +2160,93 @@
               var widgets = IriSP.configureWidgets(pop, layoutManager, config.gui); 
               var modules = IriSP.configureModules(pop, config.modules); 
       });
-};/* To wrap a player the develop should create a new class derived from 
+};/* 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;
+    }
+    
+};
+/* 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 */