# HG changeset patch # User veltr # Date 1347889499 -32400 # Node ID 2aa7fdb0762aefc41da54fc625f54b1a5e1dc053 # Parent 4da0a5740b6cbbbb925d849cda34e909692acf52 Commit before branch switch (for tests) diff -r 4da0a5740b6c -r 2aa7fdb0762a doc/eventslist.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/eventslist.txt Mon Sep 17 22:44:59 2012 +0900 @@ -0,0 +1,8 @@ +Event Name Published by Subscribed by +============================== ============================== ============================== +Annotation.hide Annotation +Annotation.show Annotation +Annotation.minimize Annotation +Annotation.maximize Annotation +Annotation.getBounds Annotation +Arrow.updatePosition Annotation \ No newline at end of file diff -r 4da0a5740b6c -r 2aa7fdb0762a src/js/defaults.js --- a/src/js/defaults.js Mon Sep 17 00:17:06 2012 +0900 +++ b/src/js/defaults.js Mon Sep 17 22:44:59 2012 +0900 @@ -42,6 +42,14 @@ IriSP.widgetsDir = 'widgets'; IriSP.widgetsRequirements = { + PopcornPlayer: { + noCss: true, + requires: [ "popcorn" ] + }, + JwpPlayer: { + noCss: true, + requires: [ "swfObject", "jwplayer" ] + }, Sparkline: { noCss: true, requires: [ "raphael" ] diff -r 4da0a5740b6c -r 2aa7fdb0762a src/js/init.js --- a/src/js/init.js Mon Sep 17 00:17:06 2012 +0900 +++ b/src/js/init.js Mon Sep 17 22:44:59 2012 +0900 @@ -1,4 +1,4 @@ -/* init.js - initialization and configuration of Popcorn and the widgets +/* init.js - initialization and configuration of the widgets */ if (typeof window.IriSP === "undefined") { @@ -10,11 +10,11 @@ IriSP.Metadataplayer = function(config) { IriSP.log("IriSP.Metadataplayer constructor"); for (var key in IriSP.guiDefaults) { - if (IriSP.guiDefaults.hasOwnProperty(key) && !config.gui.hasOwnProperty(key)) { - config.gui[key] = IriSP.guiDefaults[key] + if (IriSP.guiDefaults.hasOwnProperty(key) && !config.hasOwnProperty(key)) { + config[key] = IriSP.guiDefaults[key] } } - var _container = document.getElementById(config.gui.container); + var _container = document.getElementById(config.container); _container.innerHTML = '

Loading... Chargement...

'; this.sourceManager = new IriSP.Model.Directory(); this.config = config; @@ -23,7 +23,7 @@ } IriSP.Metadataplayer.prototype.toString = function() { - return 'Metadataplayer in #' + this.config.gui.container; + return 'Metadataplayer in #' + this.config.container; } IriSP.Metadataplayer.prototype.on = function(_event, _callback) { @@ -45,8 +45,7 @@ var $L = $LAB .script(IriSP.getLib("underscore")) .script(IriSP.getLib("Mustache")) - .script(IriSP.getLib("jQuery")) - .script(IriSP.getLib("swfObject")); + .script(IriSP.getLib("jQuery")); if (typeof JSON == "undefined") { $L.script(IriSP.getLib("json")); @@ -55,17 +54,9 @@ $L.wait() .script(IriSP.getLib("jQueryUI")); - if (this.config.player.type === "jwplayer" || this.config.player.type === "auto") { - $L.script(IriSP.getLib("jwplayer")); - } - - if (this.config.player.type !== "jwplayer" && this.config.player.type !== "allocine" && this.config.player.type !== "dailymotion") { - $L.script(IriSP.getLib("popcorn")); - } - /* widget specific requirements */ - for(var _i = 0; _i < this.config.gui.widgets.length; _i++) { - var _t = this.config.gui.widgets[_i].type; + for(var _i = 0; _i < this.config.widgets.length; _i++) { + var _t = this.config.widgets[_i].type; if (typeof IriSP.widgetsRequirements[_t] !== "undefined" && typeof IriSP.widgetsRequirements[_t].requires !== "undefined" ) { for (var _j = 0; _j < IriSP.widgetsRequirements[_t].requires.length; _j++) { $L.script(IriSP.getLib(IriSP.widgetsRequirements[_t].requires[_j])); @@ -89,22 +80,22 @@ IriSP._ = window._; } IriSP.loadCss(IriSP.getLib("cssjQueryUI")); - IriSP.loadCss(this.config.gui.css); + IriSP.loadCss(this.config.css); // this.videoData = this.loadMetadata(this.config.player.metadata); - this.$ = IriSP.jQuery('#' + this.config.gui.container); + this.$ = IriSP.jQuery('#' + this.config.container); this.$.css({ - "width": this.config.gui.width, + "width": this.config.width, "clear": "both" }); - if (typeof this.config.gui.height !== "undefined") { - this.$.css("height", this.config.gui.height); + if (typeof this.config.height !== "undefined") { + this.$.css("height", this.config.height); } this.widgets = []; var _this = this; - for(var i = 0; i < this.config.gui.widgets.length; i++) { - this.loadWidget(this.config.gui.widgets[i], function(_widget) { + for(var i = 0; i < this.config.widgets.length; i++) { + this.loadWidget(this.config.widgets[i], function(_widget) { _this.widgets.push(_widget) }); }; @@ -313,8 +304,8 @@ this.widgets = []; var _this = this; - for(var i = 0; i < this.config.gui.widgets.length; i++) { - this.loadWidget(this.config.gui.widgets[i], function(_widget) { + for(var i = 0; i < this.config.widgets.length; i++) { + this.loadWidget(this.config.widgets[i], function(_widget) { _this.widgets.push(_widget) }); }; @@ -354,20 +345,20 @@ if (typeof(_name) === "undefined") { _name = ""; } - var newDiv = IriSP._.uniqueId(this.config.gui.container + "_widget_" + _name + "_"), + var newDiv = IriSP._.uniqueId(this.config.container + "_widget_" + _name + "_"), spacerDiv = IriSP._.uniqueId("LdtPlayer_spacer_"), divHtml = IriSP.jQuery('
') .attr("id",newDiv) .css({ - width: this.config.gui.width + "px", + width: this.config.width + "px", position: "relative", clear: "both" }), spacerHtml = IriSP.jQuery('
') .attr("id",spacerDiv) .css({ - width: this.config.gui.width + "px", - height: this.config.gui.spacer_div_height + "px", + width: this.config.width + "px", + height: this.config.spacer_div_height + "px", position: "relative", clear: "both" }); diff -r 4da0a5740b6c -r 2aa7fdb0762a src/js/players/player.jwplayer.js --- a/src/js/players/player.jwplayer.js Mon Sep 17 00:17:06 2012 +0900 +++ b/src/js/players/player.jwplayer.js Mon Sep 17 22:44:59 2012 +0900 @@ -13,7 +13,7 @@ this.trigger("play"); } - var _player = jwplayer(this.container), + var _player = jwplayer(this.$[0]), _this = this, _seekPause = false; diff -r 4da0a5740b6c -r 2aa7fdb0762a src/js/widgets.js --- a/src/js/widgets.js Mon Sep 17 00:17:06 2012 +0900 +++ b/src/js/widgets.js Mon Sep 17 22:44:59 2012 +0900 @@ -26,7 +26,7 @@ /* Setting all the configuration options */ var _type = config.type, - _config = IriSP._.defaults({}, config, player.config.gui.default_options, this.defaults), + _config = IriSP._.defaults({}, config, player.config.default_options, this.defaults), _this = this; IriSP._(_config).forEach(function(_value, _key) { @@ -34,7 +34,7 @@ }); if (typeof this.width === "undefined") { - this.width = player.config.gui.width; + this.width = player.config.width; } /* Setting this.player at the end in case it's been overriden diff -r 4da0a5740b6c -r 2aa7fdb0762a src/widgets/JwpPlayer.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/widgets/JwpPlayer.js Mon Sep 17 22:44:59 2012 +0900 @@ -0,0 +1,120 @@ +IriSP.Widgets.JwpPlayer = function(player, config) { + IriSP.Widgets.Widget.call(this, player, config); +}; + +IriSP.Widgets.JwpPlayer.prototype = new IriSP.Widgets.Widget(); + +IriSP.Widgets.JwpPlayer.prototype.defaults = { +} + +IriSP.Widgets.JwpPlayer.prototype.draw = function() { + + var _opts = {}, + _player = jwplayer("#" + this.container), + _seekPause = false, + _pauseState = true, + _props = [ "live", "provider", "autostart" ]; + + if (typeof this.video === "undefined") { + this.video = this.media.video; + } + + if (typeof this.streamer === "function") { + this.streamer = this.streamer(this.video); + } + + if (typeof this.streamer === "string") { + this.video = this.video.replace(this.streamer,""); + _opts.streamer = this.streamer; + } + + _opts.file = this.video; + _opts.flashplayer = IriSP.getLib("jwPlayerSWF"); + _opts["controlbar.position"] = "none"; + + for (var i = 0; i < _props.length; i++) { + if (typeof this[_props[i]] !== "undefined") { + _opts[_props[i]] = this[_props[i]]; + } + } + + if (this.autostart) { + _pauseState = false; + this.media.trigger("play"); + } + // Binding functions to jwplayer + + this.media.getCurrentTime = function() { + return new IriSP.Model.Time(1000*_player.getPosition()); + } + this.media.getVolume = function() { + return _player.getVolume() / 100; + } + this.media.getPaused = function() { + return _pauseState; + } + this.media.getMuted = function() { + return _player.getMute(); + } + this.media.setCurrentTime = function(_milliseconds) { + _seekPause = _pauseState; + return _player.seek(_milliseconds / 1000); + } + this.media.setVolume = function(_vol) { + return _player.setVolume(Math.floor(_vol*100)); + } + this.media.mute = function() { + return _player.setMute(true); + } + this.media.unmute = function() { + return _player.setMute(false); + } + this.media.play = function() { + return _player.play(true); + } + this.media.pause = function() { + return _player.pause(true); + } + + // Binding jwplater events to media + + var _media = this.media; + + _opts.events = { + onReady: function() { + _media.trigger("loadedmetadata"); + }, + onTime: function() { + if (_seekPause) { + _player.pause(true); + _seekPause = false; + } else { + if (_pauseState && _player.getState() === "PLAYING") { + _pauseState = false; + _media.trigger("play"); + } + } + _this.trigger("timeupdate", _media.getCurrentTime()); + }, + onPlay: function() { + if (!_seekPause) { + _pauseState = false; + _media.trigger("play"); + } + }, + onPause: function() { + _pauseState = true; + _media.trigger("pause"); + }, + onSeek: function() { + _media.trigger("seeked"); + } + } + console.log("Before Setup", _opts); + _player.setup(_opts); + + console.log("OK"); + + this.jwplayer = _player; + +} \ No newline at end of file diff -r 4da0a5740b6c -r 2aa7fdb0762a src/widgets/PopcornPlayer.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/widgets/PopcornPlayer.js Mon Sep 17 22:44:59 2012 +0900 @@ -0,0 +1,88 @@ +IriSP.Widgets.PopcornPlayer = function(player, config) { + IriSP.Widgets.Widget.call(this, player, config); +}; + +IriSP.Widgets.PopcornPlayer.prototype = new IriSP.Widgets.Widget(); + +IriSP.Widgets.PopcornPlayer.prototype.defaults = { +} + +IriSP.Widgets.PopcornPlayer.prototype.draw = function() { + var _tmpId = Popcorn.guid("video"), + _videoEl = IriSP.jQuery('