# HG changeset patch # User veltr # Date 1340713349 -7200 # Node ID 9720993040590c38e76ff3c132d8532c8c67bb4b # Parent 5cd368dba1b9276f31ec739b57dec04bcd32eb00 Improved HTML Mashup diff -r 5cd368dba1b9 -r 972099304059 src/js/init.js --- a/src/js/init.js Wed Jun 20 18:41:41 2012 +0200 +++ b/src/js/init.js Tue Jun 26 14:22:29 2012 +0200 @@ -130,8 +130,32 @@ IriSP.Metadataplayer.prototype.onVideoDataLoaded = function() { if (typeof this.videoData !== "undefined" && typeof this.config.player.video === "undefined") { - var _media = this.videoData.currentMedia; - if (typeof _media !== "undefined") { + + var _media; + + if (typeof this.videoData.mainMedia !== "undefined") { + _media = this.videoData.getElement(this.videoData.mainMedia); + } + + if (this.config.player.type === "mashup" || this.config.player.type === "mashup-html") { + if (typeof _media === "undefined" || _media.elementType !== "mashup") { + var _mashups = this.videoData.getMashups(); + if (_mashups.length) { + _media = _mashups[0]; + } + } + } else { + if (typeof _media === "undefined" || _media.elementType !== "media") { + var _medias = this.videoData.getMedias(); + if (_medias.length) { + _media = _medias[0]; + } + } + } + + this.videoData.currentMedia = _media; + + if (typeof _media !== "undefined" && typeof _media.video !== "undefined") { this.config.player.video = _media.video; if (typeof _media.streamer !== "undefined") { this.config.player.streamer = _media.streamer; diff -r 5cd368dba1b9 -r 972099304059 src/js/model.js --- a/src/js/model.js Wed Jun 20 18:41:41 2012 +0200 +++ b/src/js/model.js Tue Jun 26 14:22:29 2012 +0200 @@ -660,18 +660,6 @@ return this.directory.getElement(_elId); } -IriSP.Model.Source.prototype.setCurrentMediaId = function(_idRef) { - if (typeof _idRef !== "undefined") { - this.currentMedia = this.getElement(_idRef); - } -} - -IriSP.Model.Source.prototype.setDefaultCurrentMedia = function() { - if (typeof this.currentMedia === "undefined" && this.getMedias().length) { - this.currentMedia = this.getMedias()[0]; - } -} - IriSP.Model.Source.prototype.get = function() { this.status = IriSP.Model._SOURCE_STATUS_WAITING; this.handleCallbacks(); diff -r 5cd368dba1b9 -r 972099304059 src/js/players/player.allocine.js --- a/src/js/players/player.allocine.js Wed Jun 20 18:41:41 2012 +0200 +++ b/src/js/players/player.allocine.js Tue Jun 26 14:22:29 2012 +0200 @@ -77,13 +77,11 @@ this.player = document.getElementById(this.container); this.player.addEventListener("onStateChange", "onAllocineStateChange"); this.player.cueVideoByUrl(this._options.video); - this.callbacks.onReady(); + this.trigger("loadedmetadata"); }; IriSP.PopcornReplacement.allocine.prototype.progressHandler = function(progressInfo) { - this.callbacks.onTime({ - position: progressInfo.mediaTime - }); + this.trigger("timeupdate"); } @@ -105,27 +103,18 @@ } IriSP.PopcornReplacement.allocine.prototype.stateHandler = function(state) { - console.log("stateHandler"); switch(state) { case 1: - this.callbacks.onPlay(); + this.trigger("play"); break; case 2: - this.callbacks.onPause(); + this.trigger("pause"); break; case 3: - this.callbacks.onSeek({ - position: this.player.getCurrentTime() - }); + this.trigger("seeked"); break; - - /* - case 5: - this.callbacks.onReady(); - break; - */ } }; \ No newline at end of file diff -r 5cd368dba1b9 -r 972099304059 src/js/players/player.dailymotion.js --- a/src/js/players/player.dailymotion.js Wed Jun 20 18:41:41 2012 +0200 +++ b/src/js/players/player.dailymotion.js Tue Jun 26 14:22:29 2012 +0200 @@ -109,31 +109,26 @@ this.player.addEventListener("onVideoProgress", "onDailymotionVideoProgress"); this.player.cueVideoByUrl(this._options.video); - this.callbacks.onReady(); + this.trigger("loadedmetadata"); }; IriSP.PopcornReplacement.dailymotion.prototype.onProgress = function(progressInfo) { - - this.callbacks.onTime({ - position: progressInfo.mediaTime - }); + this.trigger("timeupdate"); } IriSP.PopcornReplacement.dailymotion.prototype.onStateChange = function(state) { switch(state) { case 1: - this.callbacks.onPlay(); + this.trigger("play"); break; case 2: - this.callbacks.onPause(); + this.trigger("pause"); break; case 3: - this.callbacks.onSeek({ - position: this.player.getCurrentTime() - }); + this.trigger("seeked"); break; } diff -r 5cd368dba1b9 -r 972099304059 src/js/players/player.jwplayer.js --- a/src/js/players/player.jwplayer.js Wed Jun 20 18:41:41 2012 +0200 +++ b/src/js/players/player.jwplayer.js Tue Jun 26 14:22:29 2012 +0200 @@ -8,12 +8,13 @@ this.media.duration = options.duration; /* optional */ - var _player = jwplayer(this.container); + var _player = jwplayer(this.container), + _this = this; /* Définition des fonctions de l'API - */ this.playerFns = { - play: function() { return _player.play(); }, - pause: function() { return _player.pause(); }, + play: function() { return _player.play(true); }, + pause: function() { return _player.pause(true); }, getPosition: function() { return _player.getPosition(); }, seek: function(pos) { return _player.seek(pos); }, getMute: function() { return _player.getMute() }, @@ -22,7 +23,23 @@ setVolume: function(p) { return _player.setVolume(Math.floor(100*p)); } } - options.events = this.callbacks; + options.events = { + onReady: function() { + _this.trigger("loadedmetadata"); + }, + onTime: function() { + _this.trigger("timeupdate"); + }, + onPlay: function() { + _this.trigger("play"); + }, + onPause: function() { + _this.trigger("pause"); + }, + onSeek: function() { + _this.trigger("seeked"); + } + }; _player.setup(options); }; diff -r 5cd368dba1b9 -r 972099304059 src/js/players/player.mashup-html.js --- a/src/js/players/player.mashup-html.js Wed Jun 20 18:41:41 2012 +0200 +++ b/src/js/players/player.mashup-html.js Tue Jun 26 14:22:29 2012 +0200 @@ -15,11 +15,15 @@ IriSP._(metadata.currentMedia.medias).each(function(_media) { var _tmpId = Popcorn.guid("video"), - _videoEl = IriSP.jQuery('