# HG changeset patch # User hamidouk # Date 1328697977 -3600 # Node ID 364036384cb633fa6a197d4b4421fd1473bc3b6a # Parent 8589160ac9e3196bf12d2093e469b512b6f86083 new player version with support for dailymotion. diff -r 8589160ac9e3 -r 364036384cb6 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 */