Update Metadataplayer
authorRaphael Velt <raph.velt@gmail.com>
Wed, 28 Nov 2012 13:19:48 +0100
changeset 719 d0d3a9369f84
parent 718 930e6ee2dca1
child 720 b8f7ad30571f
Update Metadataplayer
web/player_embed.php
web/polemicaltimeline.php
web/res/metadataplayer/Annotation.css
web/res/metadataplayer/Annotation.js
web/res/metadataplayer/AnnotationsList.css
web/res/metadataplayer/AnnotationsList.js
web/res/metadataplayer/AutoPlayer.js
web/res/metadataplayer/Controller.js
web/res/metadataplayer/JwpPlayer.js
web/res/metadataplayer/LdtPlayer-core.js
web/res/metadataplayer/Polemic.js
web/res/metadataplayer/PopcornPlayer.js
web/res/metadataplayer/Segments.css
web/res/metadataplayer/Segments.js
web/res/metadataplayer/Slider.css
web/res/metadataplayer/Social.js
web/res/metadataplayer/Tagcloud.css
web/res/metadataplayer/Tagcloud.js
web/res/metadataplayer/Tweet.js
web/res/metadataplayer/img/socialbuttons.png
--- a/web/player_embed.php	Thu Nov 15 13:12:29 2012 +0100
+++ b/web/player_embed.php	Wed Nov 28 13:19:48 2012 +0100
@@ -84,12 +84,7 @@
                 disable_annotate_btn: true
             },
             {
-                type: "Segments",
-                annotation_type: [ "chap", "découpage" ]
-            },
-            {
-                type: "Annotation",
-                annotation_type: [ "chap", "découpage" ]
+                type: "MultiSegments"
             },
             { type: "Tweet" },
             { type: "Mediafragment"}
--- a/web/polemicaltimeline.php	Thu Nov 15 13:12:29 2012 +0100
+++ b/web/polemicaltimeline.php	Wed Nov 28 13:19:48 2012 +0100
@@ -164,12 +164,7 @@
             },
 <?php if ($protocol_level > 1): ?>
             {
-                type: "Segments",
-                annotation_type: [ "chap", "découpage" ]
-            },
-            {
-                type: "Annotation",
-                annotation_type: [ "chap", "découpage" ]
+                type: "MultiSegments"
             },
             { type: "Tweet" },
 <?php if (!$use_protocol): ?>
--- a/web/res/metadataplayer/Annotation.css	Thu Nov 15 13:12:29 2012 +0100
+++ b/web/res/metadataplayer/Annotation.css	Wed Nov 28 13:19:48 2012 +0100
@@ -6,6 +6,10 @@
     margin: 0;
 }
 
+.Ldt-Annotation-Highlight {
+    background: #ffa0fc;
+}
+
 .Ldt-Annotation-Widget.Ldt-Annotation-ShowTop {
     border-top-style: solid;
     padding-top: 1px;
@@ -23,6 +27,11 @@
     font-weight: bold;
 }
 
+.Ldt-Annotation-Description {
+    max-height: 150px;
+    overflow: auto;
+}
+
 .Ldt-Annotation-Cleared {
     clear: both;
 }
@@ -56,12 +65,17 @@
     color: #0068c4;
 }
 
+.Ldt-Annotation-Type {
+    color: #8080A0;
+}
+
 .Ldt-Annotation-Time {
     color: #ff3b77
 }
 
 .Ldt-Annotation-Inner p {
     font-size: 12px;
+    line-height: 16px;
 }
 
 .Ldt-Annotation-Label {
--- a/web/res/metadataplayer/Annotation.js	Thu Nov 15 13:12:29 2012 +0100
+++ b/web/res/metadataplayer/Annotation.js	Wed Nov 28 13:19:48 2012 +0100
@@ -15,14 +15,16 @@
         on_site: " sur ",
         tags_: "Mots-clés&nbsp;:",
         description_: "Description&nbsp;:",
-        excerpt_from: "Extrait de&nbsp;:"
+        excerpt_from: "Extrait de&nbsp;:",
+        untitled: "Segment sans titre"
     },
     en: {
         watching: "I'm watching ",
         on_site: " on ",
         tags_: "Keywords:",
         description_: "Description:",
-        excerpt_from: "Excerpt from:"
+        excerpt_from: "Excerpt from:",
+        untitled: "Untitled segment"
     }
 }
 
@@ -31,11 +33,11 @@
     + '<div class="Ldt-Annotation-Widget {{^show_arrow}}Ldt-Annotation-ShowTop{{/show_arrow}}">'
     + '<div class="Ldt-Annotation-Inner Ldt-Annotation-Empty{{#start_minimized}} Ldt-Annotation-Minimized{{/start_minimized}}">'
     + '<div class="Ldt-Annotation-HiddenWhenEmpty Ldt-Annotation-MaxMinButton"></div>'
-    + '<div class="Ldt-Annotation-Social Ldt-Annotation-HiddenWhenMinimized Ldt-Annotation-HiddenWhenEmpty"></div>'
-    + '<h3 class="Ldt-Annotation-HiddenWhenEmpty"><span class="Ldt-Annotation-Title"></span> <span class="Ldt-Annotation-Time">'
-    + '( <span class="Ldt-Annotation-Begin"></span> - <span class="Ldt-Annotation-End"></span> )</span></h3>'
-    + '<h3 class="Ldt-Annotation-MashupOrigin Ldt-Annotation-HiddenWhenEmpty">{{l10n.excerpt_from}} <span class="Ldt-Annotation-MashupMedia"></span> <span class="Ldt-Annotation-Time">'
-    + '( <span class="Ldt-Annotation-MashupBegin"></span> - <span class="Ldt-Annotation-MashupEnd"></span> )</span></h3>'
+    + '{{#show_social}}<div class="Ldt-Annotation-Social Ldt-Annotation-HiddenWhenMinimized Ldt-Annotation-HiddenWhenEmpty"></div>{{/show_social}}'
+    + '<h3 class="Ldt-Annotation-HiddenWhenEmpty">{{#show_annotation_type}}<span class="Ldt-Annotation-Type"></span> » {{/show_annotation_type}}<span class="Ldt-Annotation-Title"></span> <span class="Ldt-Annotation-Time Ldt-Annotation-HiddenWhenMinimized">'
+    + '(<span class="Ldt-Annotation-Begin"></span> - <span class="Ldt-Annotation-End"></span>)</span></h3>'
+    + '<h3 class="Ldt-Annotation-MashupOrigin Ldt-Annotation-HiddenWhenEmpty">{{l10n.excerpt_from}} <span class="Ldt-Annotation-MashupMedia"></span> <span class="Ldt-Annotation-Time Ldt-Annotation-HiddenWhenMinimized">'
+    + '(<span class="Ldt-Annotation-MashupBegin"></span> - <span class="Ldt-Annotation-MashupEnd"></span>)</span></h3>'
     + '<div class="Ldt-Annotation-Cleared Ldt-Annotation-HiddenWhenMinimized Ldt-Annotation-HiddenWhenEmpty Ldt-Annotation-Description-Block"><div class="Ldt-Annotation-Label">{{l10n.description_}}</div>'
     + '<p class="Ldt-Annotation-Labelled Ldt-Annotation-Description"></p></div>'
     + '<div class="Ldt-Annotation-Tags-Block Ldt-Annotation-HiddenWhenMinimized Ldt-Annotation-HiddenWhenEmpty Ldt-Annotation-Cleared">'
@@ -47,12 +49,15 @@
     start_minimized: false,
     show_arrow : true,
     site_name : "Lignes de Temps",
-    search_on_tag_click: true
+    search_on_tag_click: true,
+    show_social: true,
+    show_annotation_type: false
 }
 
 IriSP.Widgets.Annotation.prototype.draw = function() {
     
-    var _this = this;
+    var _this = this,
+        currentAnnotation;
     
     function timeupdate(_time) {
         var _list = _this.getWidgetAnnotationsAtTime();
@@ -66,7 +71,29 @@
         }
     }
     
+    function highlightTitleAndDescription() {
+        if (!currentAnnotation) {
+            return;
+        }
+        var title = currentAnnotation.title,
+            description = currentAnnotation.description.replace(/(^\s+|\s+$)/g,'');
+        if (currentAnnotation.found) {
+            var rgxp = _this.source.getAnnotations().regexp || /^$/,
+                repl = '<span class="Ldt-Annotation-Highlight">$1</span>';
+            title = title.replace(rgxp,repl);
+            description = description.replace(rgxp,repl);
+        }
+        _this.$.find(".Ldt-Annotation-Title").html(title || "(" + _this.l10n.untitled + ")");
+        if (description) {
+            _this.$.find(".Ldt-Annotation-Description-Block").removeClass("Ldt-Annotation-EmptyBlock");
+            _this.$.find(".Ldt-Annotation-Description").html(description);
+        } else {
+            _this.$.find(".Ldt-Annotation-Description-Block").addClass("Ldt-Annotation-EmptyBlock");
+        }
+    }
+    
     function drawAnnotation(_annotation) {
+        currentAnnotation = _annotation;
         var _url = (typeof _annotation.url !== "undefined" 
                 ? _annotation.url
                 : (document.location.href.replace(/#.*$/,'') + '#id='  + _annotation.id)),
@@ -81,7 +108,7 @@
                     var _el = IriSP.jQuery('<li class="Ldt-Annotation-TagLabel"></li>').append(IriSP.jQuery('<span>').text(_trimmedTitle));
                     _el.click(function() {
                         if (_this.search_on_tag_click) {
-                            _this.player.trigger("search.triggeredSearch",_trimmedTitle);
+                            _this.source.getAnnotations().search(_trimmedTitle);
                         }
                         _tag.trigger("click");
                     });
@@ -91,21 +118,17 @@
         } else {
             _this.$.find(".Ldt-Annotation-Tags-Block").addClass("Ldt-Annotation-EmptyBlock");
         }
-        _this.$.find(".Ldt-Annotation-Title").html(_annotation.title);
-        var _desc = _annotation.description.replace(/(^\s+|\s+$)/g,'');
-        if (_desc) {
-            _this.$.find(".Ldt-Annotation-Description-Block").removeClass("Ldt-Annotation-EmptyBlock");
-            _this.$.find(".Ldt-Annotation-Description").html(_desc);
-        } else {
-            _this.$.find(".Ldt-Annotation-Description-Block").addClass("Ldt-Annotation-EmptyBlock");
+        highlightTitleAndDescription();
+        if (_this.show_annotation_type) {
+            _this.$.find(".Ldt-Annotation-Type").text(_annotation.getAnnotationType().title)
         }
-        _this.$.find(".Ldt-Annotation-Begin").html(_annotation.begin.toString());
-        _this.$.find(".Ldt-Annotation-End").html(_annotation.end.toString());
+        _this.$.find(".Ldt-Annotation-Begin").text(_annotation.begin.toString());
+        _this.$.find(".Ldt-Annotation-End").text(_annotation.end.toString());
         if (_annotation.elementType === "mashedAnnotation") {
             _this.$.find('.Ldt-Annotation-Inner').addClass("Ldt-Annotation-isMashup");
-            _this.$.find(".Ldt-Annotation-MashupMedia").html(_annotation.getMedia().title);
-            _this.$.find(".Ldt-Annotation-MashupBegin").html(_annotation.annotation.begin.toString());
-            _this.$.find(".Ldt-Annotation-MashupEnd").html(_annotation.annotation.end.toString());
+            _this.$.find(".Ldt-Annotation-MashupMedia").text(_annotation.getMedia().title);
+            _this.$.find(".Ldt-Annotation-MashupBegin").text(_annotation.annotation.begin.toString());
+            _this.$.find(".Ldt-Annotation-MashupEnd").text(_annotation.annotation.end.toString());
         } else {
             _this.$.find('.Ldt-Annotation-Inner').removeClass("Ldt-Annotation-isMashup");
         }
@@ -127,7 +150,11 @@
     }
     
     this.renderTemplate();
-    this.insertSubwidget(this.$.find(".Ldt-Annotation-Social"), { type: "Social" }, "socialWidget");
+    
+    if (this.show_social) {
+        this.insertSubwidget(this.$.find(".Ldt-Annotation-Social"), { type: "Social" }, "socialWidget");
+    }
+    
     this.insertSubwidget(this.$.find(".Ldt-Annotation-Arrow"), { type: "Arrow" }, "arrow");
     this.onMediaEvent("timeupdate",timeupdate);
     this.onMdpEvent("Annotation.hide","hide");
@@ -141,6 +168,9 @@
             drawAnnotation(_a)
         });
     });
+    this.source.getAnnotations().on("found", highlightTitleAndDescription);
+    this.source.getAnnotations().on("not-found", highlightTitleAndDescription);
+    this.source.getAnnotations().on("search-cleared", highlightTitleAndDescription);
 }
 
 IriSP.Widgets.Annotation.prototype.sendBounds = function() {
--- a/web/res/metadataplayer/AnnotationsList.css	Thu Nov 15 13:12:29 2012 +0100
+++ b/web/res/metadataplayer/AnnotationsList.css	Wed Nov 28 13:19:48 2012 +0100
@@ -1,6 +1,9 @@
 /* AnnotationsListWidget */
 
 .Ldt-AnnotationsListWidget {
+    border: none; margin: 0; padding: 0;
+    overflow: auto;
+    max-height: 480px;
 }
 .Ldt-AnnotationsListWidget a {
     text-decoration: none;
@@ -26,8 +29,7 @@
     background-image: url(img/pinstripe-grey.png);
 }
 .Ldt-AnnotationsList-highlight {
-    background: #F7268E;
-    color: #ffffff;
+    background: #FFA0FC;
 }
 .Ldt-AnnotationsList-ThumbContainer {
     float: left;
--- a/web/res/metadataplayer/AnnotationsList.js	Thu Nov 15 13:12:29 2012 +0100
+++ b/web/res/metadataplayer/AnnotationsList.js	Wed Nov 28 13:19:48 2012 +0100
@@ -1,11 +1,12 @@
 IriSP.Widgets.AnnotationsList = function(player, config) {
     IriSP.Widgets.Widget.call(this, player, config);
-    this.searchString = false;
     this.lastIds = [];
     var _this = this;
     this.throttledRefresh = IriSP._.throttle(function() {
         _this.refresh(false);
-    }, 1500);
+    }, 800);
+    this.searchString = false;
+    this.lastSearch = false;
 };
 
 IriSP.Widgets.AnnotationsList.prototype = new IriSP.Widgets.Widget();
@@ -87,18 +88,6 @@
     + '{{#audio}}<div class="Ldt-AnnotationsList-Play" data-audio={{audio}}>{{l10n.voice_annotation}}</div>{{/audio}}'
     + '</li>';
 
-IriSP.Widgets.AnnotationsList.prototype.onSearch = function(searchString) {
-    this.searchString = typeof searchString !== "undefined" ? searchString : '';
-    var _n = this.refresh(true);
-    if (this.searchString) {
-        if (_n) {
-            this.player.trigger("search.matchFound");
-        } else {
-            this.player.trigger("search.noMatchFound");
-        }
-    }
-}
-
 //obj.url = this.project_url + "/" + media + "/" + annotations[i].meta.project + "/" + annotations[i].meta["id-ref"] + '#id=' + annotations[i].id;
 
 IriSP.Widgets.AnnotationsList.prototype.ajaxSource = function() {
@@ -150,9 +139,9 @@
             });
         }
     }
-    if (this.searchString) {
-        _list = _list.searchByTextFields(this.searchString);
-    }
+    _list = _list.filter(function(_annotation) {
+        return _annotation.found !== false;
+    });
     if (this.limit_count) {
         /* Get the n annotations closest to current timecode */
         _list = _list.sortBy(function(_annotation) {
@@ -171,8 +160,9 @@
     
     var _ids = _list.idIndex;
     
-    if (_forceRedraw || !IriSP._.isEqual(_ids, this.lastIds)) {
+    if (_forceRedraw || !IriSP._.isEqual(_ids, this.lastIds) || this.searchString !== this.lastSearch) {
         /* This part only gets executed if the list needs updating */
+        this.lastSearch = this.searchString;
         this.lastIds = _ids;
         this.list_$.html("");
         _list.forEach(function(_annotation) {
@@ -223,8 +213,15 @@
                 audio : (_this.show_audio && _annotation.audio && _annotation.audio.href && _annotation.audio.href != "null" ? _annotation.audio.href : undefined),
                 l10n: _this.l10n
             };
-            var _html = Mustache.to_html(_this.annotationTemplate, _data);
-            var _el = IriSP.jQuery(_html);
+            var _html = Mustache.to_html(_this.annotationTemplate, _data),
+                _el = IriSP.jQuery(_html),
+                _onselect = function() {
+                    _this.annotations_$.removeClass("selected");
+                    _el.addClass("selected");
+                },
+                _onunselect = function() {
+                    _this.annotations_$.removeClass("selected");
+                };
             _el.mouseover(function() {
                     _annotation.trigger("select");
                 })
@@ -232,13 +229,12 @@
                     _annotation.trigger("unselect");
                 })
                 .appendTo(_this.list_$);
-            _annotation.on("select", function() {
-                _this.annotations_$.removeClass("selected");
-                _el.addClass("selected");
+            _el.on("remove", function() {
+                _annotation.off("select", _onselect);
+                _annotation.off("unselect", _onunselect);
             });
-            _annotation.on("unselect", function() {
-                _this.annotations_$.removeClass("selected");
-            });;
+            _annotation.on("select", _onselect);
+            _annotation.on("unselect", _onunselect);
         });
         
         this.annotations_$ = this.$.find('.Ldt-AnnotationsList-li');
@@ -247,12 +243,12 @@
         this.$.find('.Ldt-AnnotationsList-Tag-Li').each(function() {
             var _el = IriSP.jQuery(this);
             if (!_el.text().replace(/(^\s+|\s+$)/g,'')) {
-                _el.detach();
+                _el.remove();
             }
         });
     
         this.$.find('.Ldt-AnnotationsList-Tag-Li').click(function() {
-            _this.player.trigger("search.triggeredSearch", IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,''));
+            _this.source.getAnnotations().search(IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,''));
         });
         
         this.$.find(".Ldt-AnnotationsList-Play").click(function() {
@@ -268,11 +264,10 @@
             _this.jw_paused_media = true;
         });
         
-        if(this.searchString) {
-            var _searchRe = IriSP.Model.regexpFromTextOrArray(this.searchString);
+        if (this.source.getAnnotations().searching) {
             this.$.find(".Ldt-AnnotationsList-Title a, .Ldt-AnnotationsList-Description").each(function() {
                 var _$ = IriSP.jQuery(this);
-                _$.html(_$.text().replace(/(^\s+|\s+$)/g,'').replace(_searchRe, '<span class="Ldt-AnnotationsList-highlight">$1</span>'))
+                _$.html(_$.text().replace(/(^\s+|\s+$)/g,'').replace(_this.source.getAnnotations().regexp, '<span class="Ldt-AnnotationsList-highlight">$1</span>'))
             })
         }
     }
@@ -322,9 +317,29 @@
     this.list_$ = this.$.find(".Ldt-AnnotationsList-ul");
     
     
-    this.onMdpEvent("search", "onSearch");
-    this.onMdpEvent("search.closed", "onSearch");
-    this.onMdpEvent("search.cleared", "onSearch");
+    this.source.getAnnotations().on("search", function(_text) {
+        _this.searchString = _text;
+        if (_this.source !== _this.currentSource) {
+            _this.currentSource.getAnnotations().search(_text);
+            _this.throttledRefresh();
+        }
+    });
+    this.source.getAnnotations().on("found", function() {
+        _this.throttledRefresh();
+    });
+    this.source.getAnnotations().on("not-found", function() {
+        _this.throttledRefresh();
+    });
+    this.source.getAnnotations().on("clear-search", function() {
+        _this.searchString = false;
+        if (_this.source !== _this.currentSource) {
+            _this.currentSource.getAnnotations().trigger("clear-search");
+        }
+    });
+    this.source.getAnnotations().on("search-cleared", function() {
+        _this.throttledRefresh();
+    });
+    
     this.onMdpEvent("AnnotationsList.refresh", function() {
         if (_this.ajax_url) {
             if (_this.mashupMode) {
--- a/web/res/metadataplayer/AutoPlayer.js	Thu Nov 15 13:12:29 2012 +0100
+++ b/web/res/metadataplayer/AutoPlayer.js	Wed Nov 28 13:19:48 2012 +0100
@@ -18,6 +18,14 @@
         _opts = {},
         _types = [
             {
+                regexp: /^rtmp:\/\//,
+                type: "JwpPlayer"
+            },
+            {
+                regexp: /\.(mp4|m4v)$/,
+                type: "AdaptivePlayer"
+            },
+            {
                 regexp: /\.(ogg|ogv|webm)$/,
                 type: "PopcornPlayer"
             },
@@ -33,11 +41,13 @@
                 regexp: /^(https?:\/\/)?(www\.)?dailymotion\.com/,
                 type: "DailymotionPlayer"
             }
-        ];
+        ],
+        _rtmprgx = /^rtmp:\/\//;
     
     for (var i = 0; i < _types.length; i++) {
         if (_types[i].regexp.test(this.video)) {
-            _opts.type =  _types[i].type
+            _opts.type =  _types[i].type;
+            break;
         }
     }
     
@@ -45,12 +55,21 @@
         _opts.type = this.default_type
     }
     
+    if (_opts.type === "AdaptivePlayer") {
+        var _canPlayType = document.createElement('video').canPlayType("video/mp4");
+        _opts.type = (_canPlayType == "maybe" || _canPlayType == "probably") ? "PopcornPlayer" : "JwpPlayer";
+    }
+    
+    if (_rtmprgx.test(this.video)) {
+        _opts.provider = "rtmp";
+        _opts.live = true;
+    }
+    
     for (var i = 0; i < _props.length; i++) {
         if (typeof this[_props[i]] !== "undefined") {
             _opts[_props[i]] = this[_props[i]];
         }
     }
-    
 
     this.insertSubwidget(this.$, _opts);
     
--- a/web/res/metadataplayer/Controller.js	Thu Nov 15 13:12:29 2012 +0100
+++ b/web/res/metadataplayer/Controller.js	Wed Nov 28 13:19:48 2012 +0100
@@ -56,7 +56,7 @@
         annotate: "Annotate",
         search: "Search",
         elapsed_time: "Elapsed time",
-        total_time: "Total time",
+        total_time: "Total duration",
         volume: "Volume",
         volume_control: "Volume control"
     },
@@ -69,7 +69,7 @@
         unmute: "Activer le son",
         annotate: "Annoter",
         search: "Rechercher",
-        elapsed_time: "Durée écoulée",
+        elapsed_time: "Temps écoulé",
         total_time: "Durée totale",
         volume: "Niveau sonore",
         volume_control: "Réglage du niveau sonore"
@@ -92,10 +92,6 @@
     this.onMediaEvent("volumechange","volumeUpdater");
     this.onMediaEvent("timeupdate","timeDisplayUpdater");
     this.onMediaEvent("loadedmetadata","volumeUpdater");
-    this.onMdpEvent("search.matchFound","searchMatch");
-    this.onMdpEvent("search.noMatchFound","searchNoMatch");
-    this.onMdpEvent("search.triggeredSearch","triggeredSearch");
-    this.onMdpEvent("search.cleared","hideSearchBlock");
     
     // handle clicks
     this.$playButton.click(this.functionWrapper("playHandler"));
@@ -157,9 +153,21 @@
         });
     
     this.timeDisplayUpdater(new IriSP.Model.Time(0));
-    /* some players - including jwplayer - save the state of the mute button between sessions */
-   //TODO: MOVE TO THE PLAYER/
-    window.setTimeout(this.functionWrapper("volumeUpdater"), 1000);
+    
+    var annotations = this.source.getAnnotations();
+    annotations.on("search", function(_text) {
+        _this.$searchInput.val(_text);
+        _this.showSearchBlock();
+    });
+    annotations.on("found", function(_text) {
+        _this.$searchInput.css('background-color','#e1ffe1');
+    });
+    annotations.on("not-found", function(_text) {
+        _this.$searchInput.css('background-color', "#d62e3a");
+    });
+    annotations.on("search-cleared", function() {
+        _this.hideSearchBlock();
+    });
    
 };
 
@@ -201,11 +209,7 @@
 };
 
 IriSP.Widgets.Controller.prototype.muteHandler = function() {
-    if (this.media.getMuted()) {
-        this.media.unmute();
-    } else {
-        this.media.mute();
-    }
+    this.media.setMuted(!this.media.getMuted());
 };
 
 IriSP.Widgets.Controller.prototype.volumeUpdater = function() {
@@ -229,23 +233,11 @@
 IriSP.Widgets.Controller.prototype.showSearchBlock = function() {
     this.$searchBlock.animate({ width:"160px" }, 200);
     this.$searchInput.css('background-color','#fff');
-   
     this.$searchInput.focus();
-    
-    // we need this variable because some widgets can find a match in
-    // their data while at the same time others don't. As we want the
-    // search field to become green when there's a match, we need a 
-    // variable to remember that we had one.
-    this._positiveMatch = false;
-
-    // tell the world the field is open
-    this.player.trigger("search.open");
 };
 
 IriSP.Widgets.Controller.prototype.hideSearchBlock = function() {
     this.$searchBlock.animate( { width: 0 }, 200);
-    this._positiveMatch = false;
-    this.player.trigger("search.closed");
 };
 
 /** react to clicks on the search button */
@@ -254,7 +246,7 @@
         this.showSearchBlock();
         var _val = this.$searchInput.val();
         if (_val) {
-            this.player.trigger("search", _val); // trigger the search to make it more natural.
+            this.source.getAnnotations().search(_val);
         }
 	} else {
         this.hideSearchBlock();
@@ -274,37 +266,12 @@
     // do nothing if the search field is empty, instead of highlighting everything.
     if (_val !== this.lastSearchValue) {
         if (_val) {
-            this.player.trigger("search", _val);
+            this.source.getAnnotations().search(_val);
         } else {
-            this.player.trigger("search.cleared");
+            this.source.getAnnotations().trigger("clear-search");
             this.$searchInput.css('background-color','');
         }
     }
     this.lastSearchValue = _val;
 };
 
-/**
-  handler for the IriSP.search.found message, which is sent by some views when they
-  highlight a match.
-*/
-IriSP.Widgets.Controller.prototype.searchMatch = function() {
-    this._positiveMatch = true;
-    this.$searchInput.css('background-color','#e1ffe1');
-};
-
-/** the same, except that no value could be found */
-IriSP.Widgets.Controller.prototype.searchNoMatch = function() {
-    if (this._positiveMatch !== true) {
-        this.$searchInput.css('background-color', "#d62e3a");
-    }
-};
-
-/** react to an IriSP.Player.triggeredSearch - that is, when
-    a widget ask the.Player to do a search on his behalf */
-IriSP.Widgets.Controller.prototype.triggeredSearch = function(searchString) {
-    this.showSearchBlock();
-    this.$searchInput.attr('value', searchString);      
-    this.player.trigger("search", searchString); // trigger the search to make it more natural.
-};
-
-
--- a/web/res/metadataplayer/JwpPlayer.js	Thu Nov 15 13:12:29 2012 +0100
+++ b/web/res/metadataplayer/JwpPlayer.js	Wed Nov 28 13:19:48 2012 +0100
@@ -48,46 +48,47 @@
         _pauseState = false;
         this.media.trigger("play");
     }
+
     // Binding functions to jwplayer
 
-    this.media.getCurrentTime = function() {
-        return new IriSP.Model.Time(1000*_player.getPosition() || 0);
-    }
-    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) {
+    var _media = this.media;
+    
+    _media.on("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);
-    }
+        _player.seek(_milliseconds / 1000);
+    });
+    
+    _media.on("setvolume", function(_vol) {
+        _player.setVolume(Math.floor(_vol*100));
+        _media.volume = _vol;
+    });
+    
+    _media.on("setmuted", function(_muted) {
+        _player.setMute(_muted);
+        _media.muted = _muted;
+    });
+    
+    _media.on("setplay", function() {
+        _player.play(true);
+        _media.paused = false;
+    });
+    
+    _media.on("setpause", function() {
+        _player.pause(true);
+        _media.paused = true;
+    });
     
     // Binding jwplater events to media
     
-    var _media = this.media;
+    function getVolume() {
+        _media.muted = _player.getMute();
+        _media.volume = _player.getVolume() / 100;
+    }
     
     _opts.events = {
         onReady: function() {
+            getVolume();
+            _media.currentTime = new IriSP.Model.Time(1000*_player.getPosition() || 0);
             _media.trigger("loadedmetadata");
         },
         onTime: function(_progress) {
@@ -114,6 +115,14 @@
         },
         onSeek: function() {
             _media.trigger("seeked");
+        },
+        onMute: function(_event) {
+            _media.muted = _event.mute;
+            _media.trigger("volumechange");
+        },
+        onVolume: function(_event) {
+            _media.volume = _event.volume / 100;
+            _media.trigger("volumechange");
         }
     }
     _player.setup(_opts);
--- a/web/res/metadataplayer/LdtPlayer-core.js	Thu Nov 15 13:12:29 2012 +0100
+++ b/web/res/metadataplayer/LdtPlayer-core.js	Wed Nov 28 13:19:48 2012 +0100
@@ -124,12 +124,12 @@
 }
 
 IriSP.Metadataplayer.prototype.loadMetadata = function(_metadataInfo) {
+    if (_metadataInfo.elementType === "source") {
+        return _metadataInfo;
+    }
     if (typeof _metadataInfo.serializer === "undefined" && typeof _metadataInfo.format !== "undefined") {
         _metadataInfo.serializer = IriSP.serializers[_metadataInfo.format];
     }
-    if (typeof _metadataInfo.url === "undefined" && typeof _metadataInfo.src !== "undefined") {
-        _metadataInfo.url = _metadataInfo.src;
-    }
     if (typeof _metadataInfo.url !== "undefined" && typeof _metadataInfo.serializer !== "undefined") {
         return this.sourceManager.remoteSource(_metadataInfo);
     } else {
@@ -235,47 +235,94 @@
 /* TODO: Separate Project-specific data from Source */
 
 /* model.js is where data is stored in a standard form, whatever the serializer */
-
-IriSP.Model = {
+IriSP.Model = (function (ns) {
+    
+    function pad(n, x, b) {
+        b = b || 10;
+        var s = (x).toString(b);
+        while (s.length < n) {
+            s = "0" + s;
+        }
+        return s;
+    }
+    
+    function rand16(n) {
+        return pad(n, Math.floor(Math.random()*Math.pow(16,n)), 16);
+    }
+    
+    var uidbase = rand16(8) + "-" + rand16(4) + "-", uidincrement = Math.floor(Math.random()*0x10000);
+    
+    var charsub = [
+        [ 'a', 'á', 'à', 'â', 'ä' ],
+        [ 'c', 'ç' ],
+        [ 'e', 'é', 'è', 'ê', 'ë' ],
+        [ 'i', 'í', 'ì', 'î', 'ï' ],
+        [ 'o', 'ó', 'ò', 'ô', 'ö' ]
+    ];
+    
+    var removeChars = [
+        String.fromCharCode(768), String.fromCharCode(769), String.fromCharCode(770), String.fromCharCode(771), String.fromCharCode(807),
+        "{", "}", "(", ")", "[", "]", "【", "】", "、", "・", "‥", "。", "「", "」", "『", "』", "〜", ":", "!", "?", " ",
+        ",", " ", ";", "(", ")", ".", "*", "+", "\\", "?", "|", "{", "}", "[", "]", "^", "#", "/"
+    ]
+    
+var Model = {
     _SOURCE_STATUS_EMPTY : 0,
     _SOURCE_STATUS_WAITING : 1,
     _SOURCE_STATUS_READY : 2,
-    _ID_AUTO_INCREMENT : 0,
-    _ID_BASE : (function(_d) {
-        function pad(n){return n<10 ? '0'+n : n}
-        function fillrand(n) {
-            var _res = ''
-            for (var i=0; i<n; i++) {
-                _res += Math.floor(16*Math.random()).toString(16);
-            }
-            return _res;
+    getUID : function() {
+        return uidbase + pad(4, (++uidincrement % 0x10000), 16) + "-" + rand16(4) + "-" + rand16(6) + rand16(6);
+    },
+    isLocalURL : function(url) {
+        var matches = url.match(/^(\w+:)\/\/([^/]+)/);
+        if (matches) {
+            return(matches[1] === document.location.protocol && matches[2] === document.location.host)
         }
-        return _d.getUTCFullYear() + '-'  
-            + pad(_d.getUTCMonth()+1) + '-'  
-            + pad(_d.getUTCDate()) + '-'
-            + fillrand(16);
-    })(new Date()),
-    getUID : function() {
-        var _n = (++this._ID_AUTO_INCREMENT).toString();
-        while (_n.length < 4) {
-            _n = '0' + _n
-        }
-        return "autoid-" + this._ID_BASE + '-' + _n;
+        return true;
     },
-    regexpFromTextOrArray : function(_textOrArray, _testOnly) {
-        var _testOnly = _testOnly || false;
+    regexpFromTextOrArray : function(_textOrArray, _testOnly, _iexact) {
+        var _testOnly = _testOnly || false,
+            _iexact = _iexact || false;
         function escapeText(_text) {
             return _text.replace(/([\\\*\+\?\|\{\[\}\]\(\)\^\$\.\#\/])/gm, '\\$1');
         }
         var _source = 
             typeof _textOrArray === "string"
             ? escapeText(_textOrArray)
-            : IriSP._(_textOrArray).map(escapeText).join("|");
-        if (_testOnly) {
-            return new RegExp( _source, 'im');
-        } else {
-            return new RegExp( '(' + _source + ')', 'gim');
+            : ns._(_textOrArray).map(escapeText).join("|"),
+            _flags = 'im';
+        if (!_testOnly) {
+            _source = '(' + _source + ')';
+            _flags += 'g';
+        }
+        if (_iexact) {
+            _source = '^' + _source + '$';
         }
+        return new RegExp( _source, _flags);
+    },
+    fullTextRegexps: function(_text) {
+        var remsrc = "[\\" + removeChars.join("\\") + "]",
+            remrx = new RegExp(remsrc,"gm"),
+            txt = _text.toLowerCase().replace(remrx,"")
+            res = [],
+            charsrc = ns._(charsub).map(function(c) {
+                return "(" + c.join("|") + ")";
+            }),
+            charsrx = ns._(charsrc).map(function(c) {
+                return new RegExp(c);
+            }),
+            src = "";
+        for (var j = 0; j < txt.length; j++) {
+            if (j) {
+                src += remsrc + "*";
+            }
+            var l = txt[j];
+            ns._(charsrc).each(function(v, k) {
+                l = l.replace(charsrx[k], v);
+            });
+            src += l;
+        }
+        return "(" + src + ")";
     },
     isoToDate : function(_str) {
         // http://delete.me.uk/2005/03/iso8601.html
@@ -302,95 +349,104 @@
         _res.setTime(Number(time));
         return _res;
     },
-    dateToIso : function(d) {
-        function pad(n){return n<10 ? '0'+n : n}  
+    dateToIso : function(_d) {
+        var d = _d ? new Date(_d) : new Date();
         return d.getUTCFullYear()+'-'  
-            + pad(d.getUTCMonth()+1)+'-'  
-            + pad(d.getUTCDate())+'T'  
-            + pad(d.getUTCHours())+':'  
-            + pad(d.getUTCMinutes())+':'  
-            + pad(d.getUTCSeconds())+'Z'  
+            + pad(2, d.getUTCMonth()+1)+'-'  
+            + pad(2, d.getUTCDate())+'T'  
+            + pad(2, d.getUTCHours())+':'  
+            + pad(2, d.getUTCMinutes())+':'  
+            + pad(2, d.getUTCSeconds())+'Z'  
     }
 }
 
 /*
- * IriSP.Model.List is a class for a list of elements (e.g. annotations, medias, etc. that each have a distinct ID)
+ * Model.List is a class for a list of elements (e.g. annotations, medias, etc. that each have a distinct ID)
  */
-IriSP.Model.List = function(_directory) {
+Model.List = function(_directory) {
     Array.call(this);
     this.directory = _directory;
     this.idIndex = [];
     this.__events = {};
     if (typeof _directory == "undefined") {
         console.trace();
-        throw "Error : new IriSP.Model.List(directory): directory is undefined";
+        throw "Error : new Model.List(directory): directory is undefined";
     }
+    var _this =  this;
+    this.on("clear-search", function() {
+        _this.searching = false;
+        _this.regexp = undefined;
+        _this.forEach(function(_element) {
+            _element.found = undefined;
+        });
+        _this.trigger("search-cleared");
+    })
 }
 
-IriSP.Model.List.prototype = new Array();
+Model.List.prototype = new Array();
 
-IriSP.Model.List.prototype.hasId = function(_id) {
-    return IriSP._(this.idIndex).include(_id);
+Model.List.prototype.hasId = function(_id) {
+    return ns._(this.idIndex).include(_id);
 }
 
 /* On recent browsers, forEach and map are defined and do what we want.
  * Otherwise, we'll use the Underscore.js functions
  */
 if (typeof Array.prototype.forEach === "undefined") {
-    IriSP.Model.List.prototype.forEach = function(_callback) {
+    Model.List.prototype.forEach = function(_callback) {
         var _this = this;
-        IriSP._(this).forEach(function(_value, _key) {
+        ns._(this).forEach(function(_value, _key) {
             _callback(_value, _key, _this);
         });
     }
 }
 
 if (typeof Array.prototype.map === "undefined") {
-    IriSP.Model.List.prototype.map = function(_callback) {
+    Model.List.prototype.map = function(_callback) {
         var _this = this;
-        return IriSP._(this).map(function(_value, _key) {
+        return ns._(this).map(function(_value, _key) {
             return _callback(_value, _key, _this);
         });
     }
 }
 
-IriSP.Model.List.prototype.pluck = function(_key) {
+Model.List.prototype.pluck = function(_key) {
     return this.map(function(_value) {
         return _value[_key];
     });
 }
 
-/* We override Array's filter function because it doesn't return an IriSP.Model.List
+/* We override Array's filter function because it doesn't return an Model.List
  */
-IriSP.Model.List.prototype.filter = function(_callback) {
+Model.List.prototype.filter = function(_callback) {
     var _this = this,
-        _res = new IriSP.Model.List(this.directory);
-    _res.addElements(IriSP._(this).filter(function(_value, _key) {
+        _res = new Model.List(this.directory);
+    _res.addElements(ns._(this).filter(function(_value, _key) {
         return _callback(_value, _key, _this);
     }));
     return _res;
 }
 
-IriSP.Model.List.prototype.slice = function(_start, _end) {
-    var _res = new IriSP.Model.List(this.directory);
+Model.List.prototype.slice = function(_start, _end) {
+    var _res = new Model.List(this.directory);
     _res.addElements(Array.prototype.slice.call(this, _start, _end));
     return _res;
 }
 
-IriSP.Model.List.prototype.splice = function(_start, _end) {
-    var _res = new IriSP.Model.List(this.directory);
+Model.List.prototype.splice = function(_start, _end) {
+    var _res = new Model.List(this.directory);
     _res.addElements(Array.prototype.splice.call(this, _start, _end));
     this.idIndex.splice(_start, _end);
     return _res;
 }
 
 /* Array has a sort function, but it's not as interesting as Underscore.js's sortBy
- * and won't return a new IriSP.Model.List
+ * and won't return a new Model.List
  */
-IriSP.Model.List.prototype.sortBy = function(_callback) {
+Model.List.prototype.sortBy = function(_callback) {
     var _this = this,
-        _res = new IriSP.Model.List(this.directory);
-    _res.addElements(IriSP._(this).sortBy(function(_value, _key) {
+        _res = new Model.List(this.directory);
+    _res.addElements(ns._(this).sortBy(function(_value, _key) {
         return _callback(_value, _key, _this);
     }));
     return _res;
@@ -399,34 +455,59 @@
 /* Title and Description are basic information for (almost) all element types,
  * here we can search by these criteria
  */
-IriSP.Model.List.prototype.searchByTitle = function(_text) {
-    var _rgxp = IriSP.Model.regexpFromTextOrArray(_text, true);
+Model.List.prototype.searchByTitle = function(_text, _iexact) {
+    var _iexact = _iexact || false,
+        _rgxp = Model.regexpFromTextOrArray(_text, true);
     return this.filter(function(_element) {
         return _rgxp.test(_element.title);
     });
 }
 
-IriSP.Model.List.prototype.searchByDescription = function(_text) {
-    var _rgxp = IriSP.Model.regexpFromTextOrArray(_text, true);
+Model.List.prototype.searchByDescription = function(_text, _iexact) {
+    var _iexact = _iexact || false,
+        _rgxp = Model.regexpFromTextOrArray(_text, true);
     return this.filter(function(_element) {
         return _rgxp.test(_element.description);
     });
 }
 
-IriSP.Model.List.prototype.searchByTextFields = function(_text) {
-    var _rgxp =  IriSP.Model.regexpFromTextOrArray(_text, true);
+Model.List.prototype.searchByTextFields = function(_text, _iexact) {
+    var _iexact = _iexact || false,
+        _rgxp =  Model.regexpFromTextOrArray(_text, true);
     return this.filter(function(_element) {
         return _rgxp.test(_element.description) || _rgxp.test(_element.title);
     });
 }
 
-IriSP.Model.List.prototype.getTitles = function() {
+Model.List.prototype.search = function(_text) {
+    if (!_text) {
+        this.trigger("clear-search");
+        return this;
+    }
+    this.searching = true;
+    this.trigger("search", _text);
+    var rxsource = Model.fullTextRegexps(_text)
+        rgxp = new RegExp(rxsource,"im"),
+        this.regexp = new RegExp(rxsource,"gim");
+    var res = this.filter(function(_element, _k) {
+        var titlematch = rgxp.test(_element.title),
+            descmatch = rgxp.test(_element.description),
+            _isfound = !!(titlematch || descmatch);
+        _element.found = _isfound;
+        _element.trigger(_isfound ? "found" : "not-found");
+        return _isfound;
+    });
+    this.trigger(res.length ? "found" : "not-found",res);
+    return res;
+}
+
+Model.List.prototype.getTitles = function() {
     return this.map(function(_el) {
         return _el.title;
     });
 }
 
-IriSP.Model.List.prototype.addId = function(_id) {
+Model.List.prototype.addId = function(_id) {
     var _el = this.directory.getElement(_id)
     if (!this.hasId(_id) && typeof _el !== "undefined") {
         this.idIndex.push(_id);
@@ -434,11 +515,11 @@
     }
 }
 
-IriSP.Model.List.prototype.push = function(_el) {
+Model.List.prototype.push = function(_el) {
     if (typeof _el === "undefined") {
         return;
     }
-    var _index = (IriSP._(this.idIndex).indexOf(_el.id));
+    var _index = (ns._(this.idIndex).indexOf(_el.id));
     if (_index === -1) {
         this.idIndex.push(_el.id);
         Array.prototype.push.call(this, _el);
@@ -447,24 +528,24 @@
     }
 }
 
-IriSP.Model.List.prototype.addIds = function(_array) {
+Model.List.prototype.addIds = function(_array) {
     var _l = _array.length,
         _this = this;
-    IriSP._(_array).forEach(function(_id) {
+    ns._(_array).forEach(function(_id) {
         _this.addId(_id);
     });
 }
 
-IriSP.Model.List.prototype.addElements = function(_array) {
+Model.List.prototype.addElements = function(_array) {
     var _this = this;
-    IriSP._(_array).forEach(function(_el) {
+    ns._(_array).forEach(function(_el) {
         _this.push(_el);
     });
 }
 
-IriSP.Model.List.prototype.removeId = function(_id, _deleteFromDirectory) {
+Model.List.prototype.removeId = function(_id, _deleteFromDirectory) {
     var _deleteFromDirectory = _deleteFromDirectory || false,
-        _index = (IriSP._(this.idIndex).indexOf(_id));
+        _index = (ns._(this.idIndex).indexOf(_id));
     if (_index !== -1) {
         this.splice(_index,1);
     }
@@ -473,37 +554,45 @@
     }
 }
 
-IriSP.Model.List.prototype.removeElement = function(_el, _deleteFromDirectory) {
+Model.List.prototype.removeElement = function(_el, _deleteFromDirectory) {
     var _deleteFromDirectory = _deleteFromDirectory || false;
     this.removeId(_el.id);
 }
 
-IriSP.Model.List.prototype.removeIds = function(_list, _deleteFromDirectory) {
+Model.List.prototype.removeIds = function(_list, _deleteFromDirectory) {
     var _deleteFromDirectory = _deleteFromDirectory || false,
         _this = this;
-    IriSP._(_list).forEach(function(_id) {
+    ns._(_list).forEach(function(_id) {
         _this.removeId(_id);
     });
 }
 
-IriSP.Model.List.prototype.removeElements = function(_list, _deleteFromDirectory) {
+Model.List.prototype.removeElements = function(_list, _deleteFromDirectory) {
     var _deleteFromDirectory = _deleteFromDirectory || false,
         _this = this;
-    IriSP._(_list).forEach(function(_el) {
+    ns._(_list).forEach(function(_el) {
         _this.removeElement(_el);
     });
 }
 
-IriSP.Model.List.prototype.on = function(_event, _callback) {
+Model.List.prototype.on = function(_event, _callback) {
     if (typeof this.__events[_event] === "undefined") {
         this.__events[_event] = [];
     }
     this.__events[_event].push(_callback);
 }
 
-IriSP.Model.List.prototype.trigger = function(_event, _data) {
+Model.List.prototype.off = function(_event, _callback) {
+    if (typeof this.__events[_event] !== "undefined") {
+        this.__events[_event] = ns._(this.__events[_event]).reject(function(_fn) {
+            return _fn === _callback;
+        });
+    }
+}
+
+Model.List.prototype.trigger = function(_event, _data) {
     var _list = this;
-    IriSP._(this.__events[_event]).each(function(_callback) {
+    ns._(this.__events[_event]).each(function(_callback) {
         _callback.call(_list, _data);
     });
 }
@@ -512,22 +601,22 @@
  * without the clumsiness of the original Date object.
  */
 
-IriSP.Model.Time = function(_milliseconds) {
+Model.Time = function(_milliseconds) {
     this.milliseconds = 0;
     this.setMilliseconds(_milliseconds);
 }
 
-IriSP.Model.Time.prototype.setMilliseconds = function(_milliseconds) {
-    var _ante = _milliseconds;
+Model.Time.prototype.setMilliseconds = function(_milliseconds) {
+    var _ante = this.milliseconds;
     switch(typeof _milliseconds) {
         case "string":
-            this.milliseconds = parseFloat(_milliseconds);
+            this.milliseconds = parseInt(_milliseconds);
             break;
         case "number":
-            this.milliseconds = _milliseconds;
+            this.milliseconds = Math.floor(_milliseconds);
             break;
         case "object":
-            this.milliseconds = parseFloat(_milliseconds.valueOf());
+            this.milliseconds = parseInt(_milliseconds.valueOf());
             break;
         default:
             this.milliseconds = 0;
@@ -537,52 +626,49 @@
     }
 }
 
-IriSP.Model.Time.prototype.setSeconds = function(_seconds) {
+Model.Time.prototype.setSeconds = function(_seconds) {
     this.milliseconds = 1000 * _seconds;
 }
 
-IriSP.Model.Time.prototype.getSeconds = function() {
+Model.Time.prototype.getSeconds = function() {
     return this.milliseconds / 1000;
 }
 
-IriSP.Model.Time.prototype.getHMS = function() {
+Model.Time.prototype.getHMS = function() {
     var _totalSeconds = Math.abs(Math.floor(this.getSeconds()));
     return {
         hours : Math.floor(_totalSeconds / 3600),
         minutes : (Math.floor(_totalSeconds / 60) % 60),
-        seconds : _totalSeconds % 60
+        seconds : _totalSeconds % 60,
+        milliseconds: this.milliseconds % 1000
     } 
 }
 
-IriSP.Model.Time.prototype.add = function(_milliseconds) {
-    this.milliseconds += new IriSP.Model.Time(_milliseconds).milliseconds;
+Model.Time.prototype.add = function(_milliseconds) {
+    this.milliseconds += new Model.Time(_milliseconds).milliseconds;
 }
 
-IriSP.Model.Time.prototype.valueOf = function() {
+Model.Time.prototype.valueOf = function() {
     return this.milliseconds;
 }
 
-IriSP.Model.Time.prototype.toString = function() {
-    function pad(_n) {
-        var _res = _n.toString();
-        while (_res.length < 2) {
-            _res = '0' + _res;
-        }
-        return _res;
-    }
+Model.Time.prototype.toString = function(showCs) {
     var _hms = this.getHMS(),
         _res = '';
     if (_hms.hours) {
-        _res += pad(_hms.hours) + ':'
+        _res += _hms.hours + ':'
     }
-    _res += pad(_hms.minutes) + ':' + pad(_hms.seconds);
+    _res += pad(2, _hms.minutes) + ':' + pad(2, _hms.seconds);
+    if (showCs) {
+        _res += "." + Math.round(_hms.milliseconds / 100)
+    }
     return _res;
 }
 
-/* IriSP.Model.Reference handles references between elements
+/* Model.Reference handles references between elements
  */
 
-IriSP.Model.Reference = function(_source, _idRef) {
+Model.Reference = function(_source, _idRef) {
     this.source = _source;
     this.id = _idRef;
     if (typeof _idRef === "object") {
@@ -593,9 +679,9 @@
     this.refresh();
 }
 
-IriSP.Model.Reference.prototype.refresh = function() {
+Model.Reference.prototype.refresh = function() {
     if (this.isList) {
-        this.contents = new IriSP.Model.List(this.source.directory);
+        this.contents = new Model.List(this.source.directory);
         this.contents.addIds(this.id);
     } else {
         this.contents = this.source.getElement(this.id);
@@ -603,16 +689,16 @@
     
 }
 
-IriSP.Model.Reference.prototype.getContents = function() {
+Model.Reference.prototype.getContents = function() {
     if (typeof this.contents === "undefined" || (this.isList && this.contents.length != this.id.length)) {
         this.refresh();
     }
     return this.contents;
 }
 
-IriSP.Model.Reference.prototype.isOrHasId = function(_idRef) {
+Model.Reference.prototype.isOrHasId = function(_idRef) {
     if (this.isList) {
-        return (IriSP._(this.id).indexOf(_idRef) !== -1)
+        return (ns._(this.id).indexOf(_idRef) !== -1)
     } else {
         return (this.id == _idRef);
     }
@@ -620,155 +706,216 @@
 
 /* */
 
-IriSP.Model.Element = function(_id, _source) {
+Model.Element = function(_id, _source) {
     this.elementType = 'element';
+    this.title = "";
+    this.description = "";
+    this.__events = {}
     if (typeof _source === "undefined") {
         return;
     }
     if (typeof _id === "undefined" || !_id) {
-        _id = IriSP.Model.getUID();
+        _id = Model.getUID();
     }
-    this.source = _source;
     this.id = _id;
-    this.title = "";
-    this.description = "";
-    this.__events = {}
-    this.source.directory.addElement(this);
+    this.source = _source;
+    if (_source !== this) {
+        this.source.directory.addElement(this);
+    }
 }
 
-IriSP.Model.Element.prototype.toString = function() {
+Model.Element.prototype.toString = function() {
     return this.elementType + (this.elementType !== 'element' ? ', id=' + this.id + ', title="' + this.title + '"' : '');
 }
 
-IriSP.Model.Element.prototype.setReference = function(_elementType, _idRef) {
-    this[_elementType] = new IriSP.Model.Reference(this.source, _idRef);
+Model.Element.prototype.setReference = function(_elementType, _idRef) {
+    this[_elementType] = new Model.Reference(this.source, _idRef);
 }
 
-IriSP.Model.Element.prototype.getReference = function(_elementType) {
+Model.Element.prototype.getReference = function(_elementType) {
     if (typeof this[_elementType] !== "undefined") {
         return this[_elementType].getContents();
     }
 }
 
-IriSP.Model.Element.prototype.getRelated = function(_elementType, _global) {
+Model.Element.prototype.getRelated = function(_elementType, _global) {
     _global = (typeof _global !== "undefined" && _global);
     var _this = this;
     return this.source.getList(_elementType, _global).filter(function(_el) {
         var _ref = _el[_this.elementType];
-        return _ref.isOrHasId(_this.id);
+        return _ref && _ref.isOrHasId(_this.id);
     });
 }
 
-IriSP.Model.Element.prototype.on = function(_event, _callback) {
+Model.Element.prototype.on = function(_event, _callback) {
     if (typeof this.__events[_event] === "undefined") {
         this.__events[_event] = [];
     }
     this.__events[_event].push(_callback);
 }
 
-IriSP.Model.Element.prototype.trigger = function(_event, _data) {
+Model.Element.prototype.off = function(_event, _callback) {
+    if (typeof this.__events[_event] !== "undefined") {
+        this.__events[_event] = ns._(this.__events[_event]).reject(function(_fn) {
+            return _fn === _callback;
+        });
+    }
+}
+
+Model.Element.prototype.trigger = function(_event, _data) {
     var _element = this;
-    IriSP._(this.__events[_event]).each(function(_callback) {
+    ns._(this.__events[_event]).each(function(_callback) {
         _callback.call(_element, _data);
     });
 }
 
 /* */
 
-IriSP.Model.Media = function(_id, _source) {
-    IriSP.Model.Element.call(this, _id, _source);
-    this.elementType = 'media';
-    this.duration = new IriSP.Model.Time();
-    this.video = '';
+Model.Playable = function(_id, _source) {
+    Model.Element.call(this, _id, _source);
+    if (typeof _source === "undefined") {
+        return;
+    }
+    this.elementType = 'playable';
+    this.currentTime = new Model.Time();
+    this.volume = .5;
+    this.paused = true;
+    this.muted = false;
     var _this = this;
+    this.on("play", function() {
+        _this.paused = false;
+    });
+    this.on("pause", function() {
+        _this.paused = true;
+    });
     this.on("timeupdate", function(_time) {
+        _this.currentTime = _time;
         _this.getAnnotations().filter(function(_a) {
             return (_a.end <= _time || _a.begin > _time) && _a.playing
         }).forEach(function(_a) {
             _a.playing = false;
             _a.trigger("leave");
+            _this.trigger("leave-annotation",_a);
         });
         _this.getAnnotations().filter(function(_a) {
             return _a.begin <= _time && _a.end > _time && !_a.playing
         }).forEach(function(_a) {
             _a.playing = true;
             _a.trigger("enter");
+            _this.trigger("enter-annotation",_a);
         });
     });
 }
 
-IriSP.Model.Media.prototype = new IriSP.Model.Element();
+Model.Playable.prototype = new Model.Element();
+
+Model.Playable.prototype.getCurrentTime = function() { 
+    return this.currentTime;
+}
+
+Model.Playable.prototype.getVolume = function() {
+    return this.volume;
+}
+
+Model.Playable.prototype.getPaused = function() {
+    return this.paused;
+}
+
+Model.Playable.prototype.getMuted = function() {
+    return this.muted;
+}
+
+Model.Playable.prototype.setCurrentTime = function(_time) {
+    this.trigger("setcurrenttime",_time);
+}
+
+Model.Playable.prototype.setVolume = function(_vol) {
+    this.trigger("setvolume",_vol);
+}
+
+Model.Playable.prototype.setMuted = function(_muted) {
+    this.trigger("setmuted",_muted);
+}
+
+Model.Playable.prototype.play = function() {
+    this.trigger("setplay");
+}
+
+Model.Playable.prototype.pause = function() {
+    this.trigger("setpause");
+}
+
+Model.Playable.prototype.show = function() {}
+
+Model.Playable.prototype.hide = function() {}
+
+/* */
+
+Model.Media = function(_id, _source) {
+    Model.Playable.call(this, _id, _source);
+    this.elementType = 'media';
+    this.duration = new Model.Time();
+    this.video = '';
+    var _this = this;
+}
+
+Model.Media.prototype = new Model.Playable();
 
 /* Default functions to be overriden by players */
-
-IriSP.Model.Media.prototype.getCurrentTime = function() {  return new IriSP.Model.Time(0); }
-
-IriSP.Model.Media.prototype.getVolume = function() { return .5; }
-
-IriSP.Model.Media.prototype.getPaused = function() { return true; }
-
-IriSP.Model.Media.prototype.getMuted = function() { return false; }
-
-IriSP.Model.Media.prototype.setCurrentTime
-    = IriSP.Model.Media.prototype.setVolume
-    = IriSP.Model.Media.prototype.setMuted
-    = IriSP.Model.Media.prototype.play
-    = IriSP.Model.Media.prototype.pause
-    = function() {}
     
-IriSP.Model.Media.prototype.setDuration = function(_durationMs) {
+Model.Media.prototype.setDuration = function(_durationMs) {
     this.duration.setMilliseconds(_durationMs);
 }
 
-IriSP.Model.Media.prototype.getAnnotations = function() {
+Model.Media.prototype.getAnnotations = function() {
     return this.getRelated("annotation");
 }
 
-IriSP.Model.Media.prototype.getAnnotationsByTypeTitle = function(_title) {
+Model.Media.prototype.getAnnotationsByTypeTitle = function(_title) {
     var _annTypes = this.source.getAnnotationTypes().searchByTitle(_title).pluck("id");
     if (_annTypes.length) {
         return this.getAnnotations().filter(function(_annotation) {
-            return IriSP._(_annTypes).indexOf(_annotation.getAnnotationType().id) !== -1;
+            return ns._(_annTypes).indexOf(_annotation.getAnnotationType().id) !== -1;
         });
     } else {
-        return new IriSP.Model.List(this.source.directory)
+        return new Model.List(this.source.directory)
     }
 }
 
 /* */
 
-IriSP.Model.Tag = function(_id, _source) {
-    IriSP.Model.Element.call(this, _id, _source);
+Model.Tag = function(_id, _source) {
+    Model.Element.call(this, _id, _source);
     this.elementType = 'tag';
 }
 
-IriSP.Model.Tag.prototype = new IriSP.Model.Element();
+Model.Tag.prototype = new Model.Element();
 
-IriSP.Model.Tag.prototype.getAnnotations = function() {
+Model.Tag.prototype.getAnnotations = function() {
     return this.getRelated("annotation");
 }
 
 /* */
-
-IriSP.Model.AnnotationType = function(_id, _source) {
-    IriSP.Model.Element.call(this, _id, _source);
+Model.AnnotationType = function(_id, _source) {
+    Model.Element.call(this, _id, _source);
     this.elementType = 'annotationType';
 }
 
-IriSP.Model.AnnotationType.prototype = new IriSP.Model.Element();
+Model.AnnotationType.prototype = new Model.Element();
 
-IriSP.Model.AnnotationType.prototype.getAnnotations = function() {
+Model.AnnotationType.prototype.getAnnotations = function() {
     return this.getRelated("annotation");
 }
 
 /* Annotation
  * */
 
-IriSP.Model.Annotation = function(_id, _source) {
-    IriSP.Model.Element.call(this, _id, _source);
+Model.Annotation = function(_id, _source) {
+    Model.Element.call(this, _id, _source);
     this.elementType = 'annotation';
-    this.begin = new IriSP.Model.Time();
-    this.end = new IriSP.Model.Time();
+    this.begin = new Model.Time();
+    this.end = new Model.Time();
+    this.tag = new Model.Reference(_source, []);
     this.playing = false;
     var _this = this;
     this.on("click", function() {
@@ -776,56 +923,69 @@
     });
 }
 
-IriSP.Model.Annotation.prototype = new IriSP.Model.Element(null);
+Model.Annotation.prototype = new Model.Element();
 
-IriSP.Model.Annotation.prototype.setBegin = function(_beginMs) {
-    this.begin.setMilliseconds(_beginMs);
+Model.Annotation.prototype.setBegin = function(_beginMs) {
+    this.begin.setMilliseconds(Math.max(0,_beginMs));
+    this.trigger("change-begin");
+    if (this.end < this.begin) {
+        this.setEnd(this.begin);
+    }
 }
 
-IriSP.Model.Annotation.prototype.setEnd = function(_beginMs) {
-    this.end.setMilliseconds(_beginMs);
+Model.Annotation.prototype.setEnd = function(_endMs) {
+    this.end.setMilliseconds(Math.min(_endMs, this.getMedia().duration.milliseconds));
+    this.trigger("change-end");
+    if (this.end < this.begin) {
+        this.setBegin(this.end);
+    }
 }
 
-IriSP.Model.Annotation.prototype.setMedia = function(_idRef) {
+Model.Annotation.prototype.setDuration = function(_durMs) {
+    this.setEnd(_durMs + this.begin.milliseconds);
+}
+
+Model.Annotation.prototype.setMedia = function(_idRef) {
     this.setReference("media", _idRef);
 }
 
-IriSP.Model.Annotation.prototype.getMedia = function() {
+Model.Annotation.prototype.getMedia = function() {
     return this.getReference("media");
 }
 
-IriSP.Model.Annotation.prototype.setAnnotationType = function(_idRef) {
+Model.Annotation.prototype.setAnnotationType = function(_idRef) {
     this.setReference("annotationType", _idRef);
 }
 
-IriSP.Model.Annotation.prototype.getAnnotationType = function() {
+Model.Annotation.prototype.getAnnotationType = function() {
     return this.getReference("annotationType");
 }
 
-IriSP.Model.Annotation.prototype.setTags = function(_idRefs) {
+Model.Annotation.prototype.setTags = function(_idRefs) {
     this.setReference("tag", _idRefs);
 }
 
-IriSP.Model.Annotation.prototype.getTags = function() {
+Model.Annotation.prototype.getTags = function() {
     return this.getReference("tag");
 }
 
-IriSP.Model.Annotation.prototype.getTagTexts = function() {
+Model.Annotation.prototype.getTagTexts = function() {
     return this.getTags().getTitles();
 }
 
-IriSP.Model.Annotation.prototype.getDuration = function() {
-    return new IriSP.Model.Time(this.end.milliseconds - this.begin.milliseconds)
+Model.Annotation.prototype.getDuration = function() {
+    return new Model.Time(this.end.milliseconds - this.begin.milliseconds)
 }
 
 /* */
 
-IriSP.Model.MashedAnnotation = function(_mashup, _annotation) {
-    IriSP.Model.Element.call(this, _mashup.id + "_" + _annotation.id, _annotation.source);
+Model.MashedAnnotation = function(_mashup, _annotation) {
+    Model.Element.call(this, _mashup.id + "_" + _annotation.id, _annotation.source);
     this.elementType = 'mashedAnnotation';
     this.annotation = _annotation;
-    this.begin = new IriSP.Model.Time(_mashup.duration);
-    this.end = new IriSP.Model.Time(_mashup.duration + _annotation.getDuration());
+    this.begin = new Model.Time();
+    this.end = new Model.Time();
+    this.duration = new Model.Time();
     this.title = this.annotation.title;
     this.description = this.annotation.description;
     this.color = this.annotation.color;
@@ -833,100 +993,202 @@
     this.on("click", function() {
         _mashup.setCurrentTime(_this.begin);
     });
+    this.on("enter", function() {
+        _this.annotation.trigger("enter");
+    });
+    this.on("leave", function() {
+        _this.annotation.trigger("leave");
+    });
 }
 
-IriSP.Model.MashedAnnotation.prototype = new IriSP.Model.Element(null);
+Model.MashedAnnotation.prototype = new Model.Element(null);
 
-IriSP.Model.MashedAnnotation.prototype.getMedia = function() {
+Model.MashedAnnotation.prototype.getMedia = function() {
     return this.annotation.getReference("media");
 }
 
-IriSP.Model.MashedAnnotation.prototype.getAnnotationType = function() {
+Model.MashedAnnotation.prototype.getAnnotationType = function() {
     return this.annotation.getReference("annotationType");
 }
 
-IriSP.Model.MashedAnnotation.prototype.getTags = function() {
+Model.MashedAnnotation.prototype.getTags = function() {
     return this.annotation.getReference("tag");
 }
 
-IriSP.Model.MashedAnnotation.prototype.getTagTexts = function() {
+Model.MashedAnnotation.prototype.getTagTexts = function() {
     return this.annotation.getTags().getTitles();
 }
 
-IriSP.Model.MashedAnnotation.prototype.getDuration = function() {
+Model.MashedAnnotation.prototype.getDuration = function() {
     return this.annotation.getDuration();
 }
 
+Model.MashedAnnotation.prototype.setBegin = function(_begin) {
+    this.begin.setMilliseconds(_begin);
+    this.duration.setMilliseconds(this.annotation.getDuration());
+    this.end.setMilliseconds(_begin + this.duration);
+}
+
 /* */
 
-IriSP.Model.Mashup = function(_id, _source) {
-    IriSP.Model.Element.call(this, _id, _source);
+Model.Mashup = function(_id, _source) {
+    Model.Playable.call(this, _id, _source);
     this.elementType = 'mashup';
-    this.duration = new IriSP.Model.Time();
-    this.segments = new IriSP.Model.List(_source.directory);
-    this.medias = new IriSP.Model.List(_source.directory);
-    var _currentMedia = null;
+    this.duration = new Model.Time();
+    this.segments = new Model.List(_source.directory);
+    this.loaded = false;
     var _this = this;
-    this.on("timeupdate", function(_time) {
-        _this.getAnnotations().filter(function(_a) {
-            return (_a.end <= _time || _a.begin > _time) && _a.playing
-        }).forEach(function(_a) {
-            _a.playing = false;
-            _a.trigger("leave");
-        });
-        _this.getAnnotations().filter(function(_a) {
-            return _a.begin <= _time && _a.end > _time && !_a.playing
-        }).forEach(function(_a) {
-            _a.playing = true;
-            _a.trigger("enter");
-            var _m = _a.getMedia();
-            if (_m !== _currentMedia) {
-                if (_currentMedia) {
-                    _currentMedia.trigger("leave");
-                }
-                _m.trigger("enter");
-                _currentMedia = _m;
-            }
-        });
+    this._updateTimes = function() {
+        _this.updateTimes();
+        _this.trigger("change");
+    }
+    this.on("add", this._updateTimes);
+    this.on("remove", this._updateTimes);
+}
+
+Model.Mashup.prototype = new Model.Playable();
+
+Model.Mashup.prototype.checkLoaded = function() {
+    var loaded = !!this.segments.length;
+    this.getMedias().forEach(function(_m) {
+        loaded = loaded && _m.loaded;
+    });
+    this.loaded = loaded;
+    if (loaded) {
+        this.trigger("loadedmetadata");
+    }
+}
+
+Model.Mashup.prototype.updateTimes = function() {
+    var _time = 0;
+    this.segments.forEach(function(_segment) {
+        _segment.setBegin(_time);
+        _time = _segment.end;
+    });
+    this.duration.setMilliseconds(_time);
+}
+
+Model.Mashup.prototype.addAnnotation = function(_annotation, _defer) {
+    var _mashedAnnotation = new Model.MashedAnnotation(this, _annotation),
+        _defer = _defer || false;
+    this.segments.push(_mashedAnnotation);
+    _annotation.on("change-begin", this._updateTimes);
+    _annotation.on("change-end", this._updateTimes);
+    if (!_defer) {
+        this.trigger("add");
+    }
+}
+
+Model.Mashup.prototype.addAnnotationById = function(_elId, _defer) {
+    var _annotation = this.source.getElement(_elId),
+        _defer = _defer || false;
+    if (typeof _annotation !== "undefined") {
+        this.addAnnotation(_annotation, _defer);
+    }
+}
+
+Model.Mashup.prototype.addAnnotations = function(_segments) {
+    var _this = this;
+    ns._(_segments).forEach(function(_segment) {
+        _this.addAnnotation(_segment, true);
+    });
+    this.trigger("add");
+}
+
+Model.Mashup.prototype.addAnnotationsById = function(_segments) {
+    var _this = this;
+    ns._(_segments).forEach(function(_segment) {
+        _this.addAnnotationById(_segment, true);
+    });
+    this.trigger("add");
+}
+
+Model.Mashup.prototype.removeAnnotation = function(_annotation, _defer) {
+    var _defer = _defer || false;
+    _annotation.off("change-begin", this._updateTimes);
+    _annotation.off("change-end", this._updateTimes);
+    this.segments.removeId(this.id + "_" + _annotation.id);
+    if (!_defer) {
+        this.trigger("remove");
+    }
+}
+
+Model.Mashup.prototype.removeAnnotationById = function(_annId, _defer) {
+    var _defer = _defer || false;
+    var _annotation = this.source.getElement(_annId);
+
+    if (_annotation) {
+        this.removeAnnotation(_annotation, _defer);
+    }
+    if (!_defer) {
+        this.trigger("remove");
+    }
+}
+
+Model.Mashup.prototype.setAnnotations = function(_segments) {
+    while (this.segments.length) {
+        this.removeAnnotation(this.segments[0].annotation, true);
+    }
+    this.addAnnotations(_segments);
+}
+
+Model.Mashup.prototype.setAnnotationsById = function(_segments) {
+    while (this.segments.length) {
+        this.removeAnnotation(this.segments[0].annotation, true);
+    }
+    this.addAnnotationsById(_segments);
+}
+
+Model.Mashup.prototype.hasAnnotation = function(_annotation) {
+    return !!ns._(this.segments).find(function(_s) {
+        return _s.annotation === _annotation
     });
 }
 
-IriSP.Model.Mashup.prototype = new IriSP.Model.Element();
+Model.Mashup.prototype.getAnnotation = function(_annotation) {
+    return ns._(this.segments).find(function(_s) {
+        return _s.annotation === _annotation
+    });
+}
 
-IriSP.Model.Mashup.prototype.addSegment = function(_annotation) {
-    var _mashedAnnotation = new IriSP.Model.MashedAnnotation(this, _annotation);
-    this.duration.setMilliseconds(_mashedAnnotation.end);
-    this.segments.push(_mashedAnnotation);
-    this.medias.push(_annotation.getMedia());
+Model.Mashup.prototype.getAnnotationById = function(_id) {
+    return ns._(this.segments).find(function(_s) {
+        return _s.annotation.id === _id
+    });
+}
+
+Model.Mashup.prototype.getAnnotations = function() {
+    return this.segments;
 }
 
-IriSP.Model.Mashup.prototype.addSegmentById = function(_elId) {
-    var _annotation = this.source.getElement(_elId);
-    if (typeof _annotation !== "undefined") {
-        this.addSegment(_annotation);
+Model.Mashup.prototype.getOriginalAnnotations = function() {
+    var annotations = new Model.List(this.source.directory);
+    this.segments.forEach(function(_s) {
+        annotations.push(_s.annotation);
+    });
+    return annotations;
+}
+
+Model.Mashup.prototype.getMedias = function() {
+    var medias = new Model.List(this.source.directory);
+    this.segments.forEach(function(_annotation) {
+        medias.push(_annotation.getMedia())
+    })
+    return medias;
+}
+
+Model.Mashup.prototype.getAnnotationsByTypeTitle = function(_title) {
+    var _annTypes = this.source.getAnnotationTypes().searchByTitle(_title).pluck("id");
+    if (_annTypes.length) {
+        return this.getAnnotations().filter(function(_annotation) {
+            return ns._(_annTypes).indexOf(_annotation.getAnnotationType().id) !== -1;
+        });
+    } else {
+        return new Model.List(this.source.directory)
     }
 }
 
-IriSP.Model.Mashup.prototype.getAnnotations = function() {
-    return this.segments;
-}
-
-IriSP.Model.Mashup.prototype.getMedias = function() {
-    return this.medias;
-}
-
-IriSP.Model.Mashup.prototype.getAnnotationsByTypeTitle = function(_title) {
-    var _annTypes = this.source.getAnnotationTypes().searchByTitle(_title).pluck("id");
-    if (_annTypes.length) {
-        return this.getAnnotations().filter(function(_annotation) {
-            return IriSP._(_annTypes).indexOf(_annotation.getAnnotationType().id) !== -1;
-        });
-    } else {
-        return new IriSP.Model.List(this.source.directory)
-    }
-}
-
-IriSP.Model.Mashup.prototype.getAnnotationAtTime = function(_time) {
+Model.Mashup.prototype.getAnnotationAtTime = function(_time) {
     var _list = this.segments.filter(function(_annotation) {
         return _annotation.begin <= _time && _annotation.end > _time;
     });
@@ -937,7 +1199,7 @@
     }
 }
 
-IriSP.Model.Mashup.prototype.getMediaAtTime = function(_time) {
+Model.Mashup.prototype.getMediaAtTime = function(_time) {
     var _annotation = this.getAnnotationAtTime(_time);
     if (typeof _annotation !== "undefined") {
         return _annotation.getMedia();
@@ -946,30 +1208,15 @@
     }
 }
 
-/* Default functions to be overriden by players */
-
-IriSP.Model.Mashup.prototype.getCurrentTime = function() { return new IriSP.Model.Time(0); }
-
-IriSP.Model.Mashup.prototype.getVolume = function() { return .5; }
-
-IriSP.Model.Mashup.prototype.getPaused = function() { return true; }
-
-IriSP.Model.Mashup.prototype.getMuted = function() { return false; }
-
-IriSP.Model.Mashup.prototype.setCurrentTime
-    = IriSP.Model.Mashup.prototype.setVolume
-    = IriSP.Model.Mashup.prototype.setMuted
-    = IriSP.Model.Mashup.prototype.play
-    = IriSP.Model.Mashup.prototype.pause
-    = function() {}
-
 /* */
 
-IriSP.Model.Source = function(_config) {
-    this.status = IriSP.Model._SOURCE_STATUS_EMPTY;
+Model.Source = function(_config) {
+    Model.Element.call(this, false, this);
+    this.status = Model._SOURCE_STATUS_EMPTY;
+    this.elementType = "source";
     if (typeof _config !== "undefined") {
         var _this = this;
-        IriSP._(_config).forEach(function(_v, _k) {
+        ns._(_config).forEach(function(_v, _k) {
             _this[_k] = _v;
         })
         this.callbackQueue = [];
@@ -978,14 +1225,16 @@
     }
 }
 
-IriSP.Model.Source.prototype.addList = function(_listId, _contents) {
+Model.Source.prototype = new Model.Element();
+
+Model.Source.prototype.addList = function(_listId, _contents) {
     if (typeof this.contents[_listId] === "undefined") {
-        this.contents[_listId] = new IriSP.Model.List(this.directory);
+        this.contents[_listId] = new Model.List(this.directory);
     }
     this.contents[_listId].addElements(_contents);
 }
 
-IriSP.Model.Source.prototype.getList = function(_listId, _global) {
+Model.Source.prototype.getList = function(_listId, _global) {
     _global = (typeof _global !== "undefined" && _global);
     if (_global || typeof this.contents[_listId] === "undefined") {
         return this.directory.getGlobalList().filter(function(_e) {
@@ -996,80 +1245,80 @@
     }
 }
 
-IriSP.Model.Source.prototype.forEach = function(_callback) {
+Model.Source.prototype.forEach = function(_callback) {
     var _this = this;
-    IriSP._(this.contents).forEach(function(_value, _key) {
+    ns._(this.contents).forEach(function(_value, _key) {
         _callback.call(_this, _value, _key);
     })
 }
 
-IriSP.Model.Source.prototype.getElement = function(_elId) {
+Model.Source.prototype.getElement = function(_elId) {
     return this.directory.getElement(_elId);
 }
 
-IriSP.Model.Source.prototype.get = function() {
-    this.status = IriSP.Model._SOURCE_STATUS_WAITING;
+Model.Source.prototype.get = function() {
+    this.status = Model._SOURCE_STATUS_WAITING;
     this.handleCallbacks();
 }
 
 /* We defer the callbacks calls so they execute after the queue is cleared */
-IriSP.Model.Source.prototype.deferCallback = function(_callback) {
+Model.Source.prototype.deferCallback = function(_callback) {
     var _this = this;
-    IriSP._.defer(function() {
+    ns._.defer(function() {
         _callback.call(_this);
     });
 }
 
-IriSP.Model.Source.prototype.handleCallbacks = function() {
-    this.status = IriSP.Model._SOURCE_STATUS_READY;
+Model.Source.prototype.handleCallbacks = function() {
+    this.status = Model._SOURCE_STATUS_READY;
     while (this.callbackQueue.length) {
         this.deferCallback(this.callbackQueue.splice(0,1)[0]);
     }
 }
-IriSP.Model.Source.prototype.onLoad = function(_callback) {
-    if (this.status === IriSP.Model._SOURCE_STATUS_READY) {
+Model.Source.prototype.onLoad = function(_callback) {
+    if (this.status === Model._SOURCE_STATUS_READY) {
         this.deferCallback(_callback);
     } else {
         this.callbackQueue.push(_callback);
     }
 }
 
-IriSP.Model.Source.prototype.serialize = function() {
+Model.Source.prototype.serialize = function() {
     return this.serializer.serialize(this);
 }
 
-IriSP.Model.Source.prototype.deSerialize = function(_data) {
+Model.Source.prototype.deSerialize = function(_data) {
     this.serializer.deSerialize(_data, this);
 }
 
-IriSP.Model.Source.prototype.getAnnotations = function(_global) {
+Model.Source.prototype.getAnnotations = function(_global) {
     _global = (typeof _global !== "undefined" && _global);
     return this.getList("annotation", _global);
 }
 
-IriSP.Model.Source.prototype.getMedias = function(_global) {
+Model.Source.prototype.getMedias = function(_global) {
     _global = (typeof _global !== "undefined" && _global);
     return this.getList("media", _global);
 }
 
-IriSP.Model.Source.prototype.getTags = function(_global) {
+Model.Source.prototype.getTags = function(_global) {
     _global = (typeof _global !== "undefined" && _global);
     return this.getList("tag", _global);
 }
 
-IriSP.Model.Source.prototype.getMashups = function(_global) {
+Model.Source.prototype.getMashups = function(_global) {
     _global = (typeof _global !== "undefined" && _global);
     return this.getList("mashup", _global);
 }
 
-IriSP.Model.Source.prototype.getAnnotationTypes = function(_global) {
+Model.Source.prototype.getAnnotationTypes = function(_global) {
     _global = (typeof _global !== "undefined" && _global);
     return this.getList("annotationType", _global);
 }
 
-IriSP.Model.Source.prototype.getAnnotationsByTypeTitle = function(_title, _global) {
+Model.Source.prototype.getAnnotationsByTypeTitle = function(_title, _global) {
     _global = (typeof _global !== "undefined" && _global);
-    var _res = new IriSP.Model.List(this.directory),
+    var _res = new Model.List(this.directory),
         _annTypes = this.getAnnotationTypes(_global).searchByTitle(_title);
     _annTypes.forEach(function(_annType) {
         _res.addElements(_annType.getAnnotations(_global));
@@ -1077,14 +1326,14 @@
     return _res;
 }
 
-IriSP.Model.Source.prototype.getDuration = function() {
+Model.Source.prototype.getDuration = function() {
     var _m = this.currentMedia;
     if (typeof _m !== "undefined") {
         return this.currentMedia.duration;
     }
 }
 
-IriSP.Model.Source.prototype.getCurrentMedia = function(_opts) {
+Model.Source.prototype.getCurrentMedia = function(_opts) {
     if (typeof this.currentMedia === "undefined") {
         if (_opts.is_mashup) {
             var _mashups = this.getMashups();
@@ -1094,14 +1343,14 @@
         } else {
             var _medias = this.getMedias();
             if (_medias.length) {
-                _media = _medias[0];
+                this.currentMedia = _medias[0];
             }
         }
     }
     return this.currentMedia;
 }
 
-IriSP.Model.Source.prototype.merge = function(_source) {
+Model.Source.prototype.merge = function(_source) {
     var _this = this;
     _source.forEach(function(_value, _key) {
         _this.getList(_key).addElements(_value);
@@ -1110,60 +1359,72 @@
 
 /* */
 
-IriSP.Model.RemoteSource = function(_config) {
-    IriSP.Model.Source.call(this, _config);
+Model.RemoteSource = function(_config) {
+    Model.Source.call(this, _config);
 }
 
-IriSP.Model.RemoteSource.prototype = new IriSP.Model.Source();
+Model.RemoteSource.prototype = new Model.Source();
 
-IriSP.Model.RemoteSource.prototype.get = function() {
-    this.status = IriSP.Model._SOURCE_STATUS_WAITING;
-    var _this = this;
-    this.serializer.loadData(this.url, function(_result) {
-        _this.deSerialize(_result);
-        _this.handleCallbacks();
+Model.RemoteSource.prototype.get = function() {
+    this.status = Model._SOURCE_STATUS_WAITING;
+    var _this = this,
+        urlparams = this.url_params || {},
+        dataType = (Model.isLocalURL(this.url) ? "json" : "jsonp");
+    urlparams.format = dataType;
+    ns.jQuery.ajax({
+        url: this.url,
+        dataType: dataType,
+        data: urlparams,
+        success: function(_result) {
+            _this.deSerialize(_result);
+            _this.handleCallbacks();
+        }
     });
 }
 
 /* */
 
-IriSP.Model.Directory = function() {
+Model.Directory = function() {
     this.remoteSources = {};
     this.elements = {};
 }
 
-IriSP.Model.Directory.prototype.remoteSource = function(_properties) {
+Model.Directory.prototype.remoteSource = function(_properties) {
     if (typeof _properties !== "object" || typeof _properties.url === "undefined") {
-        throw "Error : IriSP.Model.Directory.remoteSource(configuration): configuration.url is undefined";
+        throw "Error : Model.Directory.remoteSource(configuration): configuration.url is undefined";
     }
-    var _config = IriSP._({ directory: this }).extend(_properties);
-    if (typeof this.remoteSources[_properties.url] === "undefined") {
-        this.remoteSources[_properties.url] = new IriSP.Model.RemoteSource(_config);
+    var _config = ns._({ directory: this }).extend(_properties);
+    _config.url_params = _config.url_params || {};
+    var _hash = _config.url + "?" + ns.jQuery.param(_config.url_params);
+    if (typeof this.remoteSources[_hash] === "undefined") {
+        this.remoteSources[_hash] = new Model.RemoteSource(_config);
     }
-    return this.remoteSources[_properties.url];
+    return this.remoteSources[_hash];
 }
 
-IriSP.Model.Directory.prototype.newLocalSource = function(_properties) {
-    var _config = IriSP._({ directory: this }).extend(_properties),
-        _res = new IriSP.Model.Source(_config);
+Model.Directory.prototype.newLocalSource = function(_properties) {
+    var _config = ns._({ directory: this }).extend(_properties),
+        _res = new Model.Source(_config);
     return _res;
 }
 
-IriSP.Model.Directory.prototype.getElement = function(_id) {
+Model.Directory.prototype.getElement = function(_id) {
     return this.elements[_id];
 }
 
-IriSP.Model.Directory.prototype.addElement = function(_element) {
+Model.Directory.prototype.addElement = function(_element) {
     this.elements[_element.id] = _element;
 }
 
-IriSP.Model.Directory.prototype.getGlobalList = function() {
-    var _res = new IriSP.Model.List(this);
-    _res.addIds(IriSP._(this.elements).keys());
+Model.Directory.prototype.getGlobalList = function() {
+    var _res = new Model.List(this);
+    _res.addIds(ns._(this.elements).keys());
     return _res;
 }
 
-/* */
+return Model;
+
+})(IriSP);
 IriSP.language = 'en';
 
 IriSP.libFiles = {
@@ -1222,10 +1483,10 @@
         noCss: true,
         requires: [ "swfObject" ]
     },
-    AutoPlayer: {
+    AdaptivePlayer: {
         noCss: true
     },
-    MashupPlayer: {
+    AutoPlayer: {
         noCss: true
     },
     AnnotationsList: {
@@ -1257,6 +1518,9 @@
     },
     KnowledgeConcierge: {
         requires: [ "processing" ]
+    },
+    MultiSegments: {
+        noCss: true
     }
 }
 
@@ -1388,7 +1652,13 @@
 }
 
 IriSP.Widgets.Widget.prototype.getWidgetAnnotations = function() {
-    return typeof this.annotation_type !== "undefined" && this.annotation_type ? this.media.getAnnotationsByTypeTitle(this.annotation_type) : this.media.getAnnotations();
+    if (typeof this.annotation_type === "undefined") {
+        return this.media.getAnnotations();
+    }
+    if (this.annotation_type.elementType === "annotationType") {
+        return this.annotation_type.getAnnotations();
+    }
+    return this.media.getAnnotationsByTypeTitle(this.annotation_type);
 }
 
 IriSP.Widgets.Widget.prototype.getWidgetAnnotationsAtTime = function() {
@@ -1460,16 +1730,42 @@
                 }
                 return _res;        
             },
-            serializer : function(_data, _source) {
-                return {
+            serializer : function(_data, _source, _dest) {
+                var _res = {
                     id : _data.id,
                     url : _data.video,
                     meta : {
-                        "dc:title" : _data.title,
-                        "dc:description" : _data.description,
+                        "dc:title": _data.title || "",
+                        "dc:description": _data.description || "",
+                        "dc:created" : IriSP.Model.dateToIso(_data.created || _source.created),
+                        "dc:modified" : IriSP.Model.dateToIso(_data.modified || _source.modified),
+                        "dc:creator" : _data.creator || _source.creator,
+                        "dc:contributor" : _data.contributor || _source.contributor || _data.creator || _source.creator,
                         "dc:duration" : _data.duration.milliseconds
                     }
                 }
+                _dest.medias.push(_res);
+                var _list = {
+                    id: IriSP.Model.getUID(),
+                    meta : {
+                        "dc:title": _data.title || "",
+                        "dc:description": _data.description || "",
+                        "dc:created" : IriSP.Model.dateToIso(_data.created || _source.created),
+                        "dc:modified" : IriSP.Model.dateToIso(_data.modified || _source.modified),
+                        "dc:creator" : _data.creator || _source.creator,
+                        "dc:contributor" : _data.contributor || _source.contributor || _data.creator || _source.creator,
+                        "id-ref": _data.id
+                    },
+                    items: _source.getAnnotationTypes().filter(function(_at) {
+                        return _at.media === _data;
+                    }).map(function(_at) {
+                        return {
+                            "id-ref": _at.id
+                        }
+                    })
+                }
+                _dest.lists.push(_list);
+                _dest.views[0].contents.push(_data.id);
             }
         },
         tag : {
@@ -1480,13 +1776,19 @@
                 _res.title = _data.meta["dc:title"];
                 return _res;        
             },
-            serializer : function(_data, _source) {
-                return {
+            serializer : function(_data, _source, _dest) {
+                var _res = {
                     id : _data.id,
                     meta : {
-                        "dc:title" : _data.title
+                        "dc:title": _data.title || "",
+                        "dc:description": _data.description || "",
+                        "dc:created" : IriSP.Model.dateToIso(_data.created || _source.created),
+                        "dc:modified" : IriSP.Model.dateToIso(_data.modified || _source.modified),
+                        "dc:creator" : _data.creator || _source.creator,
+                        "dc:contributor" : _data.contributor || _source.contributor || _data.creator || _source.creator,
                     }
                 }
+                _dest.tags.push(_res);
             }
         },
         annotationType : {
@@ -1497,12 +1799,18 @@
                 _res.description = _data["dc:description"];
                 return _res;        
             },
-            serializer : function(_data, _source) {
-                return {
+            serializer : function(_data, _source, _dest) {
+                var _res = {
                     id : _data.id,
-                    "dc:title" : _data.title,
-                    "dc:description" : _data.description
+                    "dc:title": _data.title || "",
+                    "dc:description": _data.description || "",
+                    "dc:created" : IriSP.Model.dateToIso(_data.created || _source.created),
+                    "dc:modified" : IriSP.Model.dateToIso(_data.modified || _source.modified),
+                    "dc:creator" : _data.creator || _source.creator,
+                    "dc:contributor" : _data.contributor || _source.contributor || _data.creator || _source.creator,
                 }
+                _dest["annotation-types"].push(_res);
+                _dest.views[0].annotation_types.push(_data.id);
             }
         },
         annotation : {
@@ -1525,6 +1833,7 @@
                 _res.setMedia(_data.media);
                 _res.setAnnotationType(_data.meta["id-ref"]);
                 _res.setTags(IriSP._(_data.tags).pluck("id-ref"));
+                _res.keywords = _res.getTagTexts();
                 _res.setBegin(_data.begin);
                 _res.setEnd(_data.end);
                 _res.creator = _data.meta["dc:creator"] || "";
@@ -1537,22 +1846,29 @@
                 }
                 return _res;
             },
-            serializer : function(_data, _source) {
-                return {
+            serializer : function(_data, _source, _dest) {
+                var _color = parseInt(_data.color.replace(/^#/,''),16).toString();
+                var _res = {
                     id : _data.id,
                     begin : _data.begin.milliseconds,
                     end : _data.end.milliseconds,
                     content : {
-                        title : _data.title,
-                        description : _data.description,
-                        audio : _data.audio
+                        title : _data.title || "",
+                        description : _data.description || "",
+                        audio : _data.audio,
+                        img: {
+                            src: _data.thumbnail
+                        }
                     },
+                    color: _color,
                     media : _data.media.id,
                     meta : {
-                        "id-ref" : _data.annotationType.id,
-                        "dc:created" : IriSP.Model.dateToIso(_data.created),
-                        "dc:creator" : _data.creator,
-                        project : _source.projectId
+                        "id-ref" : _data.getAnnotationType().id,
+                        "dc:created" : IriSP.Model.dateToIso(_data.created || _source.created),
+                        "dc:modified" : IriSP.Model.dateToIso(_data.modified || _source.modified),
+                        "dc:creator" : _data.creator || _source.creator,
+                        "dc:contributor" : _data.contributor || _source.contributor || _data.creator || _source.creator,
+//                        project : _source.projectId
                     },
                     tags : IriSP._(_data.tag.id).map(function(_id) {
                        return {
@@ -1560,6 +1876,7 @@
                        } 
                     })
                 }
+                _dest.annotations.push(_res);
             }
         },
         mashup : {
@@ -1571,41 +1888,64 @@
                 var _res = new IriSP.Model.Mashup(_data.id, _source);
                 _res.title = _data.meta["dc:title"];
                 _res.description = _data.meta["dc:description"];
-                for (var _i = 0; _i < _data.items.length; _i++) {
-                    _res.addSegmentById(_data.items[_i]);
-                }
+                _res.creator = _data.meta["dc:creator"];
+                _res.setAnnotationsById(_data.items);
                 return _res;        
             },
-            serializer : function(_data, _source) {
-                return {
+            serializer : function(_data, _source, _dest) {
+                var _res = {
                     meta : {
-                        "dc:title": _data.title,
-                        "dc:description": _data.description,
+                        "dc:title": _data.title || "",
+                        "dc:description": _data.description || "",
+                        "dc:created" : IriSP.Model.dateToIso(_data.created || _source.created),
+                        "dc:modified" : IriSP.Model.dateToIso(_data.modified || _source.modified),
+                        "dc:creator" : _data.creator || _source.creator,
+                        "dc:contributor" : _data.contributor || _source.contributor || _data.creator || _source.creator,
                         listtype: "mashup"
                     },
                     items: _data.segments.map(function(_annotation) {
-                        return _id;
+                        return _annotation.annotation.id;
                     }),
                     id: _data.id
                 }
+                _dest.lists.push(_res);
             }
         }
     },
     serialize : function(_source) {
-        var _res = {},
+        var _res = {
+                meta: {
+                    "dc:creator": _source.creator,
+                    "dc:contributor" : _source.contributor || _source.creator,
+                    "dc:created": IriSP.Model.dateToIso(_source.created),
+                    "dc:modified" : IriSP.Model.dateToIso(_source.modified),
+                    "dc:title": _source.title || "",
+                    "dc:description": _source.description || "",
+                    id: _source.projectId || _source.id
+                },
+                views: [
+                    {
+                        id: IriSP.Model.getUID(),
+                        contents: [],
+                        annotation_types: []
+                    }
+                ],
+                lists: [],
+                "annotation-types": [],
+                medias: [],
+                tags: [],
+                annotations: []
+            },
             _this = this;
         _source.forEach(function(_list, _typename) {
             if (typeof _this.types[_typename] !== "undefined") {
-                _res[_this.types[_typename].serialized_name] = _list.map(function(_el) {
-                    return _this.types[_typename].serializer(_el, _source);
+                _list.forEach(function(_el) {
+                    _this.types[_typename].serializer(_el, _source, _res);
                 });
             }
         });
         return JSON.stringify(_res);
     },
-    loadData : function(_url, _callback) {
-        IriSP.jQuery.getJSON(_url, _callback)
-    },
     deSerialize : function(_data, _source) {
         if (typeof _data !== "object" || _data === null) {
             return;
@@ -1649,85 +1989,71 @@
 }
 
 IriSP.serializers.ldt_annotate = {
-    types :  {
-        annotation : {
-            serialized_name : "annotations",
-            serializer : function(_data, _source) {
-                var _annType = _data.getAnnotationType();
-                return {
-                    begin: _data.begin.milliseconds,
-                    end: _data.end.milliseconds,
-                    content: {
-                        data: _data.description,
-                        audio: _data.audio
-                    },
-                    tags: _data.getTagTexts(),
-                    media: _data.getMedia().id,
-                    type_title: _annType.title,
-                    type: ( typeof _annType.dont_send_id !== "undefined" && _annType.dont_send_id ? "" : _annType.id )
-                }
+    serializeAnnotation : function(_data, _source) {
+        var _annType = _data.getAnnotationType();
+        return {
+            begin: _data.begin.milliseconds,
+            end: _data.end.milliseconds,
+            content: {
+                description: _data.description,
+                title: _data.title,
+                audio: _data.audio
+            },
+            tags: _data.getTagTexts(),
+            media: _data.getMedia().id,
+            type_title: _annType.title,
+            type: ( typeof _annType.dont_send_id !== "undefined" && _annType.dont_send_id ? "" : _annType.id ),
+            meta: {
+                created: _data.created,
+                creator: _data.creator
             }
         }
     },
+    deserializeAnnotation : function(_anndata, _source) {
+        var _ann = new IriSP.Model.Annotation(_anndata.id, _source);
+        _ann.description = _anndata.content.description || "";
+        _ann.title = _anndata.content.title || "";
+        _ann.creator = _anndata.meta.creator || "";
+        _ann.created = new Date(_anndata.meta.created);
+        _ann.setMedia(_anndata.media, _source);
+        var _anntype = _source.getElement(_anndata.type);
+        if (!_anntype) {
+            _anntype = new IriSP.Model.AnnotationType(_anndata.type, _source);
+            _anntype.title = _anndata.type_title;
+            _source.getAnnotationTypes().push(_anntype);
+        }
+        _ann.setAnnotationType(_anntype.id);
+        var _tagIds = IriSP._(_anndata.tags).map(function(_title) {
+            var _tags = _source.getTags(true).searchByTitle(_title, true);
+            if (_tags.length) {
+                var _tag = _tags[0];
+            }
+            else {
+                _tag = new IriSP.Model.Tag(_title.replace(/\W/g,'_'),_source);
+                _tag.title = _title;
+                _source.getTags().push(_tag);
+            }
+            return _tag.id;
+        });
+        _ann.setTags(_tagIds);
+        _ann.setBegin(_anndata.begin);
+        _ann.setEnd(_anndata.end);
+        if (typeof _anndata.content.audio !== "undefined" && _anndata.content.audio.href) {
+            _ann.audio = _anndata.content.audio;
+        }
+        _source.getAnnotations().push(_ann);
+    },
     serialize : function(_source) {
-        var _res = {},
-            _this = this;
-        _source.forEach(function(_list, _typename) {
-            if (typeof _this.types[_typename] !== "undefined") {
-                _res[_this.types[_typename].serialized_name] = _list.map(function(_el) {
-                    return _this.types[_typename].serializer(_el, _source);
-                });
-            }
-        });
-        _res.meta = {
-            creator: _source.creator,
-            created: _source.created
-        }
-        return JSON.stringify(_res);
+        return JSON.stringify(this.serializeAnnotation(_source.getAnnotations()[0], _source));
     },
     deSerialize : function(_data, _source) {
         if (typeof _data == "string") {
             _data = JSON.parse(_data);
         }
+        
         _source.addList('tag', new IriSP.Model.List(_source.directory));
         _source.addList('annotationType', new IriSP.Model.List(_source.directory));
         _source.addList('annotation', new IriSP.Model.List(_source.directory));
-        if (typeof _data.annotations == "object" && _data.annotations && _data.annotations.length) {
-            var _anndata = _data.annotations[0],
-                _ann = new IriSP.Model.Annotation(_anndata.id, _source);
-            _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);
-            if (_anntypes.length) {
-                var _anntype = _anntypes[0];
-            } else {
-                var _anntype = new IriSP.Model.AnnotationType(_anndata.type, _source);
-                _anntype.title = _anndata.type_title;
-                _source.getAnnotationTypes().push(_anntype);
-            }
-            _ann.setAnnotationType(_anntype.id);
-            var _tagIds = IriSP._(_anndata.tags).map(function(_title) {
-                var _tags = _source.getTags(true).searchByTitle(_title);
-                if (_tags.length) {
-                    var _tag = _tags[0];
-                }
-                else {
-                    _tag = new IriSP.Model.Tag(_title.replace(/\W/g,'_'),_source);
-                    _tag.title = _title;
-                    _source.getTags().push(_tag);
-                }
-                return _tag.id;
-            });
-            _ann.setTags(_tagIds);
-            _ann.setBegin(_anndata.begin);
-            _ann.setEnd(_anndata.end);
-            _ann.creator = _data.meta.creator;
-            if (typeof _anndata.content.audio !== "undefined" && _anndata.content.audio.href) {
-                _ann.audio = _anndata.content.audio;
-            }
-            _source.getAnnotations().push(_ann);
-        }
+        this.deserializeAnnotation(_data, _source);
     }
 }
\ No newline at end of file
--- a/web/res/metadataplayer/Polemic.js	Thu Nov 15 13:12:29 2012 +0100
+++ b/web/res/metadataplayer/Polemic.js	Wed Nov 28 13:19:48 2012 +0100
@@ -47,42 +47,6 @@
     ]
 };
 
-IriSP.Widgets.Polemic.prototype.onSearch = function(searchString) {
-    this.searchString = typeof searchString !== "undefined" ? searchString : '';
-    var _found = 0,
-        _re = IriSP.Model.regexpFromTextOrArray(searchString, true),
-        _this = this;
-    this.$tweets.each(function() {
-        var _el = IriSP.jQuery(this);
-        if (_this.searchString) {
-            if (_re.test(_el.attr("tweet-title"))) {
-                _el.css({
-                    "background" : _this.foundcolor,
-                    "opacity" : 1
-                });
-                _found++;
-            } else {
-                _el.css({
-                    "background" : _el.attr("polemic-color"),
-                    "opacity" : .3
-                });
-            }
-        } else {
-            _el.css({
-                "background" : _el.attr("polemic-color"),
-                "opacity" : 1
-            });
-        }
-    });
-    if (this.searchString) {
-        if (_found) {
-            this.player.trigger("search.matchFound");
-        } else {
-            this.player.trigger("search.noMatchFound");
-        }
-    }
-}
-
 IriSP.Widgets.Polemic.prototype.draw = function() {
     
     this.onMediaEvent("timeupdate", "onTimeupdate");
@@ -189,6 +153,18 @@
                     _this.tooltip.hide();
                     _this.$tweets.css("opacity",1);
                 });
+                _annotation.on("found", function() {
+                    _el.css({
+                        "background" : _this.foundcolor,
+                        "opacity" : 1
+                    });
+                });
+                _annotation.on("not-found", function() {
+                    _el.css({
+                        "background" : _col,
+                        "opacity" : .3
+                    });
+                });
                 _this.$zone.append(_el);
             }
             
@@ -213,9 +189,15 @@
             
             this.$tweets = this.$.find(".Ldt-Polemic-TweetDiv");
             
-            this.onMdpEvent("search", "onSearch");
-            this.onMdpEvent("search.closed", "onSearch");
-            this.onMdpEvent("search.cleared", "onSearch");
+            this.source.getAnnotations().on("search-cleared", function() {
+                _this.$tweets.each(function() {
+                    var _el = IriSP.jQuery(this);
+                    _el.css({
+                        "background" : _el.attr("polemic-color"),
+                        "opacity" : 1
+                    });
+                });
+            });
             
         } else {
             this.$zone.hide();
--- a/web/res/metadataplayer/PopcornPlayer.js	Thu Nov 15 13:12:29 2012 +0100
+++ b/web/res/metadataplayer/PopcornPlayer.js	Wed Nov 28 13:19:48 2012 +0100
@@ -83,57 +83,64 @@
         }
     }
     
-
+    var _media = this.media;
+    
     // Binding functions to Popcorn
     
-    this.media.getCurrentTime = function() {
-        return new IriSP.Model.Time(1000*_popcorn.currentTime());
-    }
-    this.media.getVolume = function() {
-        return _popcorn.volume();
-    }
-    this.media.getPaused = function() {
-        return _popcorn.media.paused;
-    }
-    this.media.getMuted = function() {
-        return _popcorn.muted();
-    }
-    this.media.setCurrentTime = function(_milliseconds) {
-        return _popcorn.currentTime(_milliseconds / 1000);
-    }
-    this.media.setVolume = function(_vol) {
-        return _popcorn.volume(_vol);
-    }
-    this.media.mute = function() {
-        return _popcorn.muted(true);
-    }
-    this.media.unmute = function() {
-        return _popcorn.muted(false);
-    }
-    this.media.play = function() {
-        return _popcorn.play();
-    }
-    this.media.pause = function() {
-        return _popcorn.pause();
-    }
+    _media.on("setcurrenttime", function(_milliseconds) {
+        _popcorn.currentTime(_milliseconds / 1000);
+    });
+    
+    _media.on("setvolume", function(_vol) {
+        _popcorn.volume(_vol);
+        _media.volume = _vol;
+    });
+    
+    _media.on("setmuted", function(_muted) {
+        _popcorn.muted(_muted);
+        _media.muted = _muted;
+    });
+    
+    _media.on("setplay", function() {
+        _popcorn.play();
+    });
+    
+    _media.on("setpause", function() {
+        _popcorn.pause();
+    });
     
     // Binding Popcorn events to media
     
-    var _media = this.media;
+    function getVolume() {
+        _media.muted = _popcorn.muted();
+        _media.volume = _popcorn.volume();
+    }
+    
+    _popcorn.on("loadedmetadata", function() {
+        getVolume();
+        _media.trigger("loadedmetadata");
+        _media.trigger("volumechange");
+    })
+    
     _popcorn.on("timeupdate", function() {
-        _media.trigger("timeupdate", _media.getCurrentTime());
+        _media.trigger("timeupdate", new IriSP.Model.Time(1000*_popcorn.currentTime()));
     });
     
-    function simpleEventBind(_eventname) {
-        _popcorn.on(_eventname, function() {
-            _media.trigger(_eventname);
-        });
-    }
+    _popcorn.on("volumechange", function() {
+        getVolume();
+        _media.trigger("volumechange");
+    })
     
-    simpleEventBind("play");
-    simpleEventBind("pause");
-    simpleEventBind("seeked");
-    simpleEventBind("loadedmetadata");
-    simpleEventBind("volumechange");
+    _popcorn.on("play", function() {
+        _media.trigger("play");
+    });
+    
+    _popcorn.on("pause", function() {
+        _media.trigger("pause");
+    });
+    
+    _popcorn.on("seeked", function() {
+        _media.trigger("seeked");
+    });
     
 }
\ No newline at end of file
--- a/web/res/metadataplayer/Segments.css	Thu Nov 15 13:12:29 2012 +0100
+++ b/web/res/metadataplayer/Segments.css	Wed Nov 28 13:19:48 2012 +0100
@@ -2,28 +2,17 @@
  * Segments Widget
  */
 
-.Ldt-Segments-List {
-    width: 100%; height: 100%;
-}
-
 .Ldt-Segments-Segment {
-    position: absolute; height: 100%; opacity: .5; filter:alpha(opacity=50); margin-left: -1px; border-left: 1px solid #ffffff;
-}
-
-.Ldt-Segments-Segment.inactive, .Ldt-Segments-Segment.unfound {
-    opacity: .2; filter:alpha(opacity=20);
-}
-
-.Ldt-Segments-Segment.active, .Ldt-Segments-Segment.found {
-    opacity: 1; filter:alpha(opacity=100);
+    position: absolute; margin-left: -1px; border: 1px solid #ffffff;
 }
 
 .Ldt-Segments-Position {
     background: #fc00ff;
     position: absolute;
-    top: 0;
+    top: -1px;
     left: 0;
     margin-left: -1px;
     width: 2px;
-    height: 100%;
+    bottom: -1px;
+    z-index: 80000;
 }
\ No newline at end of file
--- a/web/res/metadataplayer/Segments.js	Thu Nov 15 13:12:29 2012 +0100
+++ b/web/res/metadataplayer/Segments.js	Wed Nov 28 13:19:48 2012 +0100
@@ -9,7 +9,11 @@
 IriSP.Widgets.Segments.prototype.defaults = {
     annotation_type : "chap",
     colors: ["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"],
-    height: 10
+    line_height: 8,
+    background: "#e0e0e0",
+    overlap: .25,
+    found_color: "#FF00FC",
+    faded_found_color: "#ff80fc"
 };
 
 IriSP.Widgets.Segments.prototype.template =
@@ -19,37 +23,65 @@
 
 IriSP.Widgets.Segments.prototype.annotationTemplate =
     '<div class="Ldt-Segments-Segment Ldt-TraceMe" trace-info="segment-id:{{id}}, media-id:{{media_id}}" segment-text="{{text}}"'
-    + 'style="left:{{left}}px; width:{{width}}px; background:{{color}}"></div>'
+    + 'style="top:{{top}}px; height:{{height}}px; left:{{left}}px; width:{{width}}px; background:{{medcolor}}" data-base-color="{{color}}" data-low-color="{{lowcolor}}" data-medium-color="{{medcolor}}"></div>'
 
 
 IriSP.Widgets.Segments.prototype.draw = function() {
-    this.onMdpEvent("search", "onSearch");
-    this.onMdpEvent("search.closed", "onSearch");
-    this.onMdpEvent("search.cleared", "onSearch");
     this.onMediaEvent("timeupdate", "onTimeupdate");
-    
     this.renderTemplate();
     
-    var _list = this.getWidgetAnnotations(),
+    var _list = this.getWidgetAnnotations().filter(function(_ann) {
+            return _ann.getDuration() > 0;
+        }),
         _this = this,
-        _scale = this.width / this.source.getDuration();
-    this.$.css({
-        width : this.width + "px",
-        height : (this.height - 2) + "px",
-        margin : "1px 0"
-    });
-    this.list_$ = this.$.find('.Ldt-Segments-List');
+        _scale = this.width / this.source.getDuration(),
+        list_$ = this.$.find('.Ldt-Segments-List'),
+        lines = [],
+        zindex = 1,
+        searching = false;
+    
+    function saturate(r, g, b, s) {
+        function satcomp(c) {
+            return Math.floor(240 * (1 - s) + c * s);
+        }
+        var res = ( 0x10000 * satcomp(r) + 0x100 * satcomp(g) + satcomp(b)).toString(16);
+        while (res.length < 6) {
+            res = "0" + res;
+        }
+        return "#" + res;
+    }
     
     _list.forEach(function(_annotation, _k) {
         var _left = _annotation.begin * _scale,
             _width = ( _annotation.getDuration() ) * _scale,
             _center = Math.floor( _left + _width / 2 ),
-            _fulltext = _annotation.title + ( _annotation.description ? ( '<br/>' + _annotation.description ) : '' );
+            _fulltext = _annotation.title + ( _annotation.description ? ( '<br/>' + _annotation.description ) : '' ),
+            line = IriSP._(lines).find(function(line) {
+                return !IriSP._(line.annotations).find(function(a) {
+                    return a.begin < _annotation.end && a.end > _annotation.begin
+                });
+            });
+        if (!line) {
+            line = { index: lines.length, annotations: []};
+            lines.push(line); 
+        }
+        line.annotations.push(_annotation);
+        var _top = ((1 - _this.overlap) * line.index) * _this.line_height,
+            color = ( typeof _annotation.color !== "undefined" && _annotation.color ? _annotation.color : _this.colors[_k % _this.colors.length] ),
+            r = parseInt(color.substr(1,2),16),
+            g = parseInt(color.substr(3,2),16),
+            b = parseInt(color.substr(5,2),16),
+            medcolor = saturate(r, g, b, .5),
+            lowcolor = saturate(r, g, b, .2);
         var _data = {
-            color : ( typeof _annotation.color !== "undefined" && _annotation.color ? _annotation.color : _this.colors[_k % _this.colors.length] ),
+            color : color,
+            medcolor: medcolor,
+            lowcolor: lowcolor,
             text: _fulltext.replace(/(\n|\r|\r\n)/mg,' ').replace(/(^.{120,140})[\s].+$/m,'$1&hellip;'),
-            left : Math.floor( _left ),
-            width : Math.floor( _width ),
+            left : _left,
+            width : _width,
+            top: _top,
+            height: _this.line_height - 1,
             id : _annotation.id,
             media_id : _annotation.getMedia().id
         };
@@ -64,43 +96,53 @@
             .click(function() {
                 _annotation.trigger("click");
             })
-            .appendTo(_this.list_$)
+            .appendTo(list_$)
         _annotation.on("select", function() {
-            _this.$segments.removeClass("active").addClass("inactive");
-            _this.tooltip.show( _center, 0, _data.text, _data.color );
-            _el.removeClass("inactive").addClass("active");
+            _this.$segments.each(function() {
+                var _segment = IriSP.jQuery(this);
+                _segment.css({
+                    background: _segment.hasClass("found") ? _this.faded_found_color : _segment.attr("data-low-color")
+                });
+            });
+            _el.css({
+                background: _el.hasClass("found") ? _this.found_color: color,
+                "z-index": ++zindex
+            });
+            _this.tooltip.show( _center, _top, _data.text, _data.color );
         });
         _annotation.on("unselect", function() {
             _this.tooltip.hide();
-            _this.$segments.removeClass("inactive active");
+            _this.$segments.each(function() {
+                var _segment = IriSP.jQuery(this);
+                _segment.css("background", _segment.hasClass("found") ? _this.found_color : _segment.attr(searching ? "data-low-color" : "data-medium-color"));
+            });
+        });
+        _annotation.on("found", function() {
+            _el.css("background", _this.found_color).addClass("found");
         });
+        _annotation.on("not-found", function() {
+            _el.css("background", lowcolor).removeClass("found");
+        });
+    });
+    
+    this.$.css({
+        width : this.width + "px",
+        height : (((1 - this.overlap) * lines.length + this.overlap) * this.line_height) + "px",
+        background : this.background,
+        margin: "1px 0"
     });
     this.insertSubwidget(this.$.find(".Ldt-Segments-Tooltip"), { type: "Tooltip" }, "tooltip");
     this.$segments = this.$.find('.Ldt-Segments-Segment');
-}
-
-IriSP.Widgets.Segments.prototype.onSearch = function(searchString) {
-    this.searchString = typeof searchString !== "undefined" ? searchString : '';
-    var _found = 0,
-        _re = IriSP.Model.regexpFromTextOrArray(searchString, true);
-    if (this.searchString) {
-        this.$segments.each(function() {
-            var _el = IriSP.jQuery(this);
-            if (_re.test(_el.attr("segment-text"))) {
-                _el.removeClass("unfound").addClass("found");
-                _found++;
-            } else {
-                _el.removeClass("found").addClass("unfound");
-            }
+    this.source.getAnnotations().on("search", function() {
+        searching = true;
+    });
+    this.source.getAnnotations().on("search-cleared", function() {
+        searching = false;
+        _this.$segments.each(function() {
+            var _segment = IriSP.jQuery(this);
+            _segment.css("background", _segment.attr("data-medium-color")).removeClass("found");
         });
-        if (_found) {
-            this.player.trigger("search.matchFound");
-        } else {
-            this.player.trigger("search.noMatchFound");
-        }
-    } else {
-        this.$segments.removeClass("found unfound");
-    }
+    });
 }
 
 IriSP.Widgets.Segments.prototype.onTimeupdate = function(_time) {
--- a/web/res/metadataplayer/Slider.css	Thu Nov 15 13:12:29 2012 +0100
+++ b/web/res/metadataplayer/Slider.css	Wed Nov 28 13:19:48 2012 +0100
@@ -14,6 +14,6 @@
 
 .Ldt-Slider-Time {
     position: absolute; top: -16px; background: #ffffc0; color: #000000; border-radius: 3px; z-index: 8;
-    font-size: 9px; width: 34px; border: 1px solid #999999; padding: 1px; margin-left: -20px;
+    font-size: 10px; width: 34px; border: 1px solid #999999; padding: 1px; margin-left: -20px;
     display: none; text-align: center; font-weight: bold;
 }
--- a/web/res/metadataplayer/Social.js	Thu Nov 15 13:12:29 2012 +0100
+++ b/web/res/metadataplayer/Social.js	Wed Nov 28 13:19:48 2012 +0100
@@ -20,9 +20,9 @@
 IriSP.Widgets.Social.prototype.template =
     '<span class="Ldt-Social">{{#show_url}}<div class="Ldt-Social-Url-Container"><a href="#" target="_blank" class="Ldt-Social-Square Ldt-Social-Url Ldt-TraceMe" title="{{l10n.share_link}}">'
     + '</a><div class="Ldt-Social-UrlPop"><input class="Ldt-Social-Input"/><div class="Ldt-Social-CopyBtn">{{l10n.copy}}</div></div></div>{{/show_url}}'
-    + '{{#show_fb}}<a href="#" target="_blank" class="Ldt-Social-Fb Ldt-TraceMe" title="{{l10n.share_on}} Facebook"></a>{{/show_fb}}'
-    + '{{#show_twitter}}<a href="#" target="_blank" class="Ldt-Social-Twitter Ldt-TraceMe" title="{{l10n.share_on}} Twitter"></a>{{/show_twitter}}'
-    + '{{#show_gplus}}<a href="#" target="_blank" class="Ldt-Social-Gplus Ldt-TraceMe" title="{{l10n.share_on}} Google+"></a>{{/show_gplus}}'
+    + '{{#show_fb}}<a href="#" target="_blank" class="Ldt-Social-Fb Ldt-Social-Ext Ldt-TraceMe" title="{{l10n.share_on}} Facebook"></a>{{/show_fb}}'
+    + '{{#show_twitter}}<a href="#" target="_blank" class="Ldt-Social-Twitter Ldt-Social-Ext Ldt-TraceMe" title="{{l10n.share_on}} Twitter"></a>{{/show_twitter}}'
+    + '{{#show_gplus}}<a href="#" target="_blank" class="Ldt-Social-Gplus Ldt-Social-Ext Ldt-TraceMe" title="{{l10n.share_on}} Google+"></a>{{/show_gplus}}'
     + '{{#show_mail}}<a href="#" target="_blank" class="Ldt-Social-Mail Ldt-TraceMe" title="{{l10n.share_mail}}"></a>{{/show_mail}}</span>';
 
 IriSP.Widgets.Social.prototype.messages = {
@@ -52,6 +52,13 @@
     this.$.find(".Ldt-Social-Input").focus(function() {
         this.select();
     });
+    this.$.find(".Ldt-Social-Ext").click(function() {
+        window.open(
+            IriSP.jQuery(this).attr("href"),
+            "_blank",
+            "height=300,width=450,left=100,top=100,toolbar=0,menubar=0,status=0,location=0");
+        return false;
+    });
     this.updateUrls(this.url, this.text);
 }
 
@@ -82,6 +89,6 @@
     this.text = _text;
     this.$.find(".Ldt-Social-Fb").attr("href", "http://www.facebook.com/share.php?" + IriSP.jQuery.param({ u: _url, t: _text }));
     this.$.find(".Ldt-Social-Twitter").attr("href", "https://twitter.com/intent/tweet?" + IriSP.jQuery.param({ url: _url, text: _text }));
-    this.$.find(".Ldt-Social-Gplus").attr("href", "https://plusone.google.com/_/+1/confirm?" + IriSP.jQuery.param({ url: _url, title: _text }));
+    this.$.find(".Ldt-Social-Gplus").attr("href", "https://plus.google.com/share?" + IriSP.jQuery.param({ url: _url, title: _text }));
     this.$.find(".Ldt-Social-Mail").attr("href", "mailto:?" + IriSP.jQuery.param({ subject: _text, body: _text + ": " + _url }));
 }
--- a/web/res/metadataplayer/Tagcloud.css	Thu Nov 15 13:12:29 2012 +0100
+++ b/web/res/metadataplayer/Tagcloud.css	Wed Nov 28 13:19:48 2012 +0100
@@ -2,9 +2,13 @@
  * 
  */
 .Ldt-Tagcloud-Container {
+    border: 1px solid #b7b7b7;
+    padding: 1px;
+    margin: 0;
 }
 
 ul.Ldt-Tagcloud-List {
+    background: url(img/pinstripe.png);
     padding: 5px;
     margin: 0;
     list-style: none;
--- a/web/res/metadataplayer/Tagcloud.js	Thu Nov 15 13:12:29 2012 +0100
+++ b/web/res/metadataplayer/Tagcloud.js	Wed Nov 28 13:19:48 2012 +0100
@@ -39,9 +39,6 @@
 }
 
 IriSP.Widgets.Tagcloud.prototype.draw = function() {
-    this.onMdpEvent("search", "onSearch");
-    this.onMdpEvent("search.closed", "onSearch");
-    this.onMdpEvent("search.cleared", "onSearch");
     
     if (this.segment_annotation_type) {
         var _this = this;
@@ -108,9 +105,10 @@
     this.$.html(Mustache.to_html(this.template,  {words: _words }));
     this.$.find(".Ldt-Tagcloud-item").click(function() {
         var _txt = IriSP.jQuery(this).attr("content");
-        _this.player.trigger("search.triggeredSearch", _txt);
+        _this.source.getAnnotations().search(_txt);
     });
-    
+    this.source.getAnnotations().on("search", this.functionWrapper("onSearch"));
+    this.source.getAnnotations().on("search-cleared", this.functionWrapper("onSearch"));
 }
 
 IriSP.Widgets.Tagcloud.prototype.onSearch = function(searchString) {
--- a/web/res/metadataplayer/Tweet.js	Thu Nov 15 13:12:29 2012 +0100
+++ b/web/res/metadataplayer/Tweet.js	Wed Nov 28 13:19:48 2012 +0100
@@ -33,7 +33,7 @@
     "fr": {
         retweet: "Retweeter",
         reply: "Répondre",
-        keep_visible: "Garder visible",
+        keep_visible: "Empêcher la fermeture automatique",
         dont_keep_visible: "Permettre la fermeture automatique",
         close_widget: "Fermer l'affichage du tweet",
         original_time: "Heure d'envoi&nbsp;: ",
Binary file web/res/metadataplayer/img/socialbuttons.png has changed