Added a default subject in the Trace Widget V01.91
authorRaphael Velt <raph.velt@gmail.com>
Tue, 03 Jul 2012 18:17:17 +0200
changeset 652 b3ccfdbd581b
parent 651 d09df952fd81
child 653 c4c876db76fb
Added a default subject in the Trace Widget
web/player_embed.php
web/polemicaltimeline.php
web/res/metadataplayer/LdtPlayer-core.js
web/res/metadataplayer/Trace.js
--- a/web/player_embed.php	Tue Jun 26 19:14:44 2012 +0200
+++ b/web/player_embed.php	Tue Jul 03 18:17:17 2012 +0200
@@ -70,7 +70,7 @@
                 { type: "Mediafragment"},
                 {
                     type: "Trace",
-                    default_subject: "PolemicTweet-player"
+                    default_subject: "Polemic"
                 }
             ]
         },
--- a/web/polemicaltimeline.php	Tue Jun 26 19:14:44 2012 +0200
+++ b/web/polemicaltimeline.php	Tue Jul 03 18:17:17 2012 +0200
@@ -130,7 +130,7 @@
                 { type: "Mediafragment"},
                 {
                     type: "Trace",
-                    default_subject: "PolemicTweet-player"
+                    default_subject: "Polemic"
                 }
             ]
         },
--- a/web/res/metadataplayer/LdtPlayer-core.js	Tue Jun 26 19:14:44 2012 +0200
+++ b/web/res/metadataplayer/LdtPlayer-core.js	Tue Jul 03 18:17:17 2012 +0200
@@ -151,6 +151,9 @@
 }
 
 IriSP.Metadataplayer.prototype.onVideoDataLoaded = function() {
+    
+    /* Getting video URL from metadata if it's not in the player config options */
+   
     if (typeof this.videoData !== "undefined" && typeof this.config.player.video === "undefined") {
         
         var _media;
@@ -186,7 +189,129 @@
         }
         
     }
-    this.configurePopcorn();
+    
+    if (typeof this.config.player.video === "string" && this.config.player.url_transform === "function") {
+        this.config.player.video = this.config.player.url_transform(this.config.player.video);
+    }
+    
+    var _pop,
+        _divs = this.layoutDivs("video",this.config.player.height || undefined),
+        containerDiv = _divs[0],
+        spacerDiv = _divs[1],
+        _this = this,
+        _types = {
+            "html5" : /\.(ogg|ogv|webm)$/,
+            "youtube" : /^(https?:\/\/)?(www\.)?youtube\.com/,
+            "dailymotion" : /^(https?:\/\/)?(www\.)?dailymotion\.com/
+        };
+    
+    if (this.config.player.type === "auto") {
+        this.config.player.type = "jwplayer";
+        IriSP._(_types).each(function(_v, _k) {
+            if (_v.test(_this.config.player.video)) {
+                _this.config.player.type = _k
+            }
+        });
+    }
+
+    switch(this.config.player.type) {
+        case "html5":
+            var _tmpId = Popcorn.guid("video"),
+                _videoEl = IriSP.jQuery('<video>');
+            
+            _videoEl.attr({
+                "src" : this.config.player.video,
+                "id" : _tmpId
+            })
+
+            if(this.config.player.hasOwnProperty("width")) {
+                _videoEl.attr("width", this.config.player.width);
+            }
+            if(this.config.player.hasOwnProperty("height")) {
+                _videoEl.attr("height", this.config.player.height);
+            }
+            IriSP.jQuery("#" + containerDiv).append(_videoEl);
+            _pop = Popcorn("#" + _tmpId);
+            break;
+
+        case "html5-audio":
+            var _tmpId = Popcorn.guid("audio"),
+                _videoEl = IriSP.jQuery('<audio>');
+            
+            _videoEl.attr({
+                "src" : this.config.player.video,
+                "id" : _tmpId
+            })
+
+            if(this.config.player.hasOwnProperty("width")) {
+                _videoEl.attr("width", this.config.player.width);
+            }
+            if(this.config.player.hasOwnProperty("height")) {
+                _videoEl.attr("height", this.config.player.height);
+            }
+            IriSP.jQuery("#" + containerDiv).append(_videoEl);
+            _pop = Popcorn("#" + _tmpId);
+            break;
+
+        case "jwplayer":
+            var opts = IriSP.jQuery.extend({}, this.config.player);
+            delete opts.container;
+            delete opts.type;
+            opts.file = opts.video;
+            delete opts.video;
+
+            if(!opts.hasOwnProperty("flashplayer")) {
+                opts.flashplayer = IriSP.getLib("jwPlayerSWF");
+            }
+
+            if(!opts.hasOwnProperty("controlbar.position")) {
+                opts["controlbar.position"] = "none";
+            }
+            _pop = new IriSP.PopcornReplacement.jwplayer("#" + containerDiv, opts);
+            break;
+
+        case "youtube":
+            // Popcorn.youtube wants us to specify the size of the player in the style attribute of its container div.
+            IriSP.jQuery("#" + containerDiv).css({
+                width : this.config.player.width + "px",
+                height : this.config.player.height + "px"
+            });
+            var _urlparts = this.config.player.video.split(/[?&]/),
+                _params = {};
+            for (var _j = 1; _j < _urlparts.length; _j++) {
+                var _ppart = _urlparts[_j].split('=');
+                _params[_ppart[0]] = decodeURIComponent(_ppart[1]);
+            }
+            _params.controls = 0;
+            _params.modestbranding = 1;
+            _url = _urlparts[0] + '?' + IriSP.jQuery.param(_params);
+            _pop = Popcorn.youtube("#" + containerDiv, _url);
+            break;
+
+        case "dailymotion":
+            _pop = new IriSP.PopcornReplacement.dailymotion("#" + containerDiv, this.config.player);
+            break;
+
+        case "mashup":
+            _pop = new IriSP.PopcornReplacement.mashup("#" + containerDiv, this.config.player);
+            break;
+            
+        case "allocine":
+            _pop = new IriSP.PopcornReplacement.allocine("#" + containerDiv, this.config.player);
+            break;
+        
+        case "mashup-html":
+            _pop = new IriSP.PopcornReplacement.htmlMashup("#" + containerDiv, this.config.player, this.videoData);
+            break;
+        
+        default:
+            _pop = undefined;
+    };
+
+    this.popcorn = _pop;
+    
+    /* Now Loading Widgets */
+    
     this.widgets = [];
     var _this = this;
     for(var i = 0; i < this.config.gui.widgets.length; i++) {
@@ -223,130 +348,6 @@
     }
 }
 
-IriSP.Metadataplayer.prototype.configurePopcorn = function() {
-    IriSP.log("IriSP.Metadataplayer.prototype.configurePopcorn");
-    var pop,
-        ret = this.layoutDivs("video",this.config.player.height || undefined),
-        containerDiv = ret[0],
-        spacerDiv = ret[1],
-        _this = this,
-        _types = {
-            "html5" : /\.(ogg|ogv|webm)$/,
-            "youtube" : /^(https?:\/\/)?(www\.)?youtube\.com/,
-            "dailymotion" : /^(https?:\/\/)?(www\.)?dailymotion\.com/
-        };
-    
-    if (this.config.player.type === "auto") {
-        this.config.player.type = "jwplayer";
-        IriSP._(_types).each(function(_v, _k) {
-            if (_v.test(_this.config.player.video)) {
-                _this.config.player.type = _k
-            }
-        });
-    }
-
-    switch(this.config.player.type) {
-        /*
-         todo : dynamically create the div/video tag which
-         will contain the video.
-         */
-        case "html5":
-            var _tmpId = Popcorn.guid("video"),
-                _videoEl = IriSP.jQuery('<video>');
-            
-            _videoEl.attr({
-                "src" : this.config.player.video,
-                "id" : _tmpId
-            })
-
-            if(this.config.player.hasOwnProperty("width")) {
-                _videoEl.attr("width", this.config.player.width);
-            }
-            if(this.config.player.hasOwnProperty("height")) {
-                _videoEl.attr("height", this.config.player.height);
-            }
-            IriSP.jQuery("#" + containerDiv).append(_videoEl);
-            pop = Popcorn("#" + _tmpId);
-            break;
-
-        case "html5-audio":
-            var _tmpId = Popcorn.guid("audio"),
-                _videoEl = IriSP.jQuery('<audio>');
-            
-            _videoEl.attr({
-                "src" : this.config.player.video,
-                "id" : _tmpId
-            })
-
-            if(this.config.player.hasOwnProperty("width")) {
-                _videoEl.attr("width", this.config.player.width);
-            }
-            if(this.config.player.hasOwnProperty("height")) {
-                _videoEl.attr("height", this.config.player.height);
-            }
-            IriSP.jQuery("#" + containerDiv).append(_videoEl);
-            pop = Popcorn("#" + _tmpId);
-            break;
-
-        case "jwplayer":
-            var opts = IriSP.jQuery.extend({}, this.config.player);
-            delete opts.container;
-            delete opts.type;
-            opts.file = opts.video;
-            delete opts.video;
-
-            if(!opts.hasOwnProperty("flashplayer")) {
-                opts.flashplayer = IriSP.getLib("jwPlayerSWF");
-            }
-
-            if(!opts.hasOwnProperty("controlbar.position")) {
-                opts["controlbar.position"] = "none";
-            }
-            pop = new IriSP.PopcornReplacement.jwplayer("#" + containerDiv, opts);
-            break;
-
-        case "youtube":
-            // Popcorn.youtube wants us to specify the size of the player in the style attribute of its container div.
-            IriSP.jQuery("#" + containerDiv).css({
-                width : this.config.player.width + "px",
-                height : this.config.player.height + "px"
-            });
-            var _urlparts = this.config.player.video.split(/[?&]/),
-                _params = {};
-            for (var _j = 1; _j < _urlparts.length; _j++) {
-                var _ppart = _urlparts[_j].split('=');
-                _params[_ppart[0]] = decodeURIComponent(_ppart[1]);
-            }
-            _params.controls = 0;
-            _params.modestbranding = 1;
-            _url = _urlparts[0] + '?' + IriSP.jQuery.param(_params);
-            pop = Popcorn.youtube("#" + containerDiv, _url);
-            break;
-
-        case "dailymotion":
-            pop = new IriSP.PopcornReplacement.dailymotion("#" + containerDiv, this.config.player);
-            break;
-
-        case "mashup":
-            pop = new IriSP.PopcornReplacement.mashup("#" + containerDiv, this.config.player);
-            break;
-            
-        case "allocine":
-            /* pass the options as-is to the allocine player and let it handle everything */
-            pop = new IriSP.PopcornReplacement.allocine("#" + containerDiv, this.config.player);
-            break;
-        
-        case "mashup-html":
-            pop = new IriSP.PopcornReplacement.htmlMashup("#" + containerDiv, this.config.player, this.videoData);
-            break;
-        
-        default:
-            pop = undefined;
-    };
-
-    this.popcorn = pop;
-}
-
 /** create a subdiv with an unique id, and a spacer div as well.
     @param widgetName the name of the widget.
     @return an array of the form [createdivId, spacerdivId].
@@ -1535,6 +1536,13 @@
     return typeof this.annotation_type !== "undefined" && this.annotation_type ? _curmedia.getAnnotationsByTypeTitle(this.annotation_type) : _curmedia.getAnnotations();
 }
 
+IriSP.Widgets.Widget.prototype.getWidgetAnnotationsAtTime = function() {
+    var _time = Math.floor(this.player.popcorn.currentTime() * 1000);
+    return this.getWidgetAnnotations().filter(function(_annotation) {
+        return _annotation.begin <= _time && _annotation.end > _time;
+    });
+}
+
 /**
  * This method responsible of drawing a widget on screen.
  */
@@ -1823,12 +1831,18 @@
             _this.trigger("loadedmetadata");
         },
         onTime:   function() {
+            if (_this.media.paused && _player.getState() === "PLAYING") {
+                _this.media.paused = false;
+                _this.trigger("play");
+            }
             _this.trigger("timeupdate");
         },
         onPlay:   function() {
+            _this.media.paused = false;
             _this.trigger("play");
         },
         onPause:  function() {
+            _this.media.paused = true;
             _this.trigger("pause");
         },
         onSeek:   function() {
@@ -2391,7 +2405,6 @@
                     },
                     tags: _data.getTagTexts(),
                     media: _data.getMedia().id,
-                    title: _data.title,
                     type_title: _annType.title,
                     type: ( typeof _annType.dont_send_id !== "undefined" && _annType.dont_send_id ? "" : _annType.id )
                 }
@@ -2424,8 +2437,8 @@
         if (typeof _data.annotations == "object" && _data.annotations && _data.annotations.length) {
             var _anndata = _data.annotations[0],
                 _ann = new IriSP.Model.Annotation(_anndata.id, _source);
-            _ann.title = _anndata.content.title || "";
             _ann.description = _anndata.content.data || "";
+            _ann.title = _data.creator;
             _ann.created = new Date(_data.meta.created);
             _ann.setMedia(_anndata.media, _source);
             var _anntypes = _source.getAnnotationTypes(true).searchByTitle(_anndata.type_title);
--- a/web/res/metadataplayer/Trace.js	Tue Jun 26 19:14:44 2012 +0200
+++ b/web/res/metadataplayer/Trace.js	Tue Jul 03 18:17:17 2012 +0200
@@ -9,7 +9,8 @@
     js_console : false,
     url: "http://traces.advene.org:5000/",
     requestmode: 'GET',
-    syncmode: "sync"
+    syncmode: "sync",
+    default_subject: "IRI"
 }
 
 IriSP.Widgets.Trace.prototype.draw = function() {
@@ -49,7 +50,8 @@
     this.tracer = window.tracemanager.init_trace("test", {
         url: this.url,
         requestmode: this.requestmode,
-        syncmode: this.syncmode
+        syncmode: this.syncmode,
+        default_subject: this.default_subject
     });
     this.tracer.trace("StartTracing", {});