Added On-the-fly (file-less) metadata generation test
authorveltr
Tue, 02 Oct 2012 18:08:05 +0200
changeset 969 353b0881a0b9
parent 968 03c88ba5de2c
child 970 b1c3bf6eca78
Added On-the-fly (file-less) metadata generation test
.hgignore
sbin/build/compil-to-polemic-tweet.sh.tmpl
src/js/init.js
src/js/model.js
src/widgets/AnnotationsList.js
src/widgets/JwpPlayer.js
test/dailymotion.htm
test/jwplayer-audio.htm
test/jwplayer.htm
test/onthefly.htm
--- a/.hgignore	Tue Oct 02 12:44:37 2012 +0200
+++ b/.hgignore	Tue Oct 02 18:08:05 2012 +0200
@@ -34,4 +34,6 @@
 syntax: regexp
 \.webm$
 syntax: regexp
-^downloads/.+\.zip$
\ No newline at end of file
+^downloads/.+\.zip$
+syntax: regexp
+^sbin/build/compil-to-polemic-tweet\.sh$
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/build/compil-to-polemic-tweet.sh.tmpl	Tue Oct 02 18:08:05 2012 +0200
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+echo "Compiling Metadataplayer"
+
+sh ../res/ant/bin/ant -f client.xml
+
+echo "Copying to Polemic Tweet :"
+
+echo "  Copying core files and widgets"
+
+cp -R ../../test/metadataplayer/* ~/shared/tweet_live/web/res/metadataplayer
+
+echo "  Copying libs"
+
+cp -R ../../src/js/libs/* ~/shared/tweet_live/web/res/js
+
--- a/src/js/init.js	Tue Oct 02 12:44:37 2012 +0200
+++ b/src/js/init.js	Tue Oct 02 18:08:05 2012 +0200
@@ -102,12 +102,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 {
--- a/src/js/model.js	Tue Oct 02 12:44:37 2012 +0200
+++ b/src/js/model.js	Tue Oct 02 18:08:05 2012 +0200
@@ -267,6 +267,14 @@
     this.__events[_event].push(_callback);
 }
 
+IriSP.Model.List.prototype.off = function(_event, _callback) {
+    if (typeof this.__events[_event] !== "undefined") {
+        this.__events[_event] = IriSP._(this.__events[_event]).reject(function(_fn) {
+            return _fn === _callback;
+        });
+    }
+}
+
 IriSP.Model.List.prototype.trigger = function(_event, _data) {
     var _list = this;
     IriSP._(this.__events[_event]).each(function(_callback) {
@@ -421,7 +429,7 @@
     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);
     });
 }
 
@@ -432,6 +440,14 @@
     this.__events[_event].push(_callback);
 }
 
+IriSP.Model.Element.prototype.off = function(_event, _callback) {
+    if (typeof this.__events[_event] !== "undefined") {
+        this.__events[_event] = IriSP._(this.__events[_event]).reject(function(_fn) {
+            return _fn === _callback;
+        });
+    }
+}
+
 IriSP.Model.Element.prototype.trigger = function(_event, _data) {
     var _element = this;
     IriSP._(this.__events[_event]).each(function(_callback) {
@@ -535,6 +551,7 @@
     this.elementType = 'annotation';
     this.begin = new IriSP.Model.Time();
     this.end = new IriSP.Model.Time();
+    this.tag = new IriSP.Model.Reference(_source, []);
     this.playing = false;
     var _this = this;
     this.on("click", function() {
@@ -733,6 +750,7 @@
 
 IriSP.Model.Source = function(_config) {
     this.status = IriSP.Model._SOURCE_STATUS_EMPTY;
+    this.elementType = "source";
     if (typeof _config !== "undefined") {
         var _this = this;
         IriSP._(_config).forEach(function(_v, _k) {
@@ -744,6 +762,8 @@
     }
 }
 
+IriSP.Model.Source.prototype = new IriSP.Model.Element();
+
 IriSP.Model.Source.prototype.addList = function(_listId, _contents) {
     if (typeof this.contents[_listId] === "undefined") {
         this.contents[_listId] = new IriSP.Model.List(this.directory);
@@ -860,7 +880,7 @@
         } else {
             var _medias = this.getMedias();
             if (_medias.length) {
-                _media = _medias[0];
+                this.currentMedia = _medias[0];
             }
         }
     }
--- a/src/widgets/AnnotationsList.js	Tue Oct 02 12:44:37 2012 +0200
+++ b/src/widgets/AnnotationsList.js	Tue Oct 02 18:08:05 2012 +0200
@@ -223,8 +223,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 +239,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,7 +253,7 @@
         this.$.find('.Ldt-AnnotationsList-Tag-Li').each(function() {
             var _el = IriSP.jQuery(this);
             if (!_el.text().replace(/(^\s+|\s+$)/g,'')) {
-                _el.detach();
+                _el.remove();
             }
         });
     
--- a/src/widgets/JwpPlayer.js	Tue Oct 02 12:44:37 2012 +0200
+++ b/src/widgets/JwpPlayer.js	Tue Oct 02 18:08:05 2012 +0200
@@ -19,6 +19,10 @@
         this.video = this.media.video;
     }
     
+    if (typeof this.streamer === "undefined") {
+        this.streamer = this.media.streamer;
+    }
+    
     if (typeof this.streamer === "function") {
         this.streamer = this.streamer(this.video);
     }
--- a/test/dailymotion.htm	Tue Oct 02 12:44:37 2012 +0200
+++ b/test/dailymotion.htm	Tue Oct 02 18:08:05 2012 +0200
@@ -7,7 +7,6 @@
         <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
         <link href='test.css' rel='stylesheet' type='text/css'>
         <script type="text/javascript" src="metadataplayer/LdtPlayer-core.js" type="text/javascript"></script>
-        <script type="text/javascript" src="test-config.js" type="text/javascript"></script>
     </head>
 
     <body>
--- a/test/jwplayer-audio.htm	Tue Oct 02 12:44:37 2012 +0200
+++ b/test/jwplayer-audio.htm	Tue Oct 02 18:08:05 2012 +0200
@@ -7,7 +7,6 @@
         <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
         <link href='test.css' rel='stylesheet' type='text/css'>
         <script type="text/javascript" src="metadataplayer/LdtPlayer-core.js" type="text/javascript"></script>
-        <script type="text/javascript" src="test-config.js" type="text/javascript"></script>
     </head>
 
     <body>
--- a/test/jwplayer.htm	Tue Oct 02 12:44:37 2012 +0200
+++ b/test/jwplayer.htm	Tue Oct 02 18:08:05 2012 +0200
@@ -7,7 +7,6 @@
         <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
         <link href='test.css' rel='stylesheet' type='text/css'>
         <script type="text/javascript" src="metadataplayer/LdtPlayer-core.js" type="text/javascript"></script>
-        <script type="text/javascript" src="test-config.js" type="text/javascript"></script>
     </head>
 
     <body>
@@ -36,15 +35,7 @@
                 live: true,
                 width: 550, 
                 provider: "rtmp",
-                autostart: true,
-                streamer: function(_url) {
-                    var _matches = _url.match(/^[^\/]+\/\/[^\/]+\/[^\/]+\//);
-                    if (_matches) {
-                        return _matches[0];
-                    } else {
-                        return _url;
-                    }
-                }
+                autostart: true
             },
             { type: "Slider" },
             { type: "Controller" },
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/onthefly.htm	Tue Oct 02 18:08:05 2012 +0200
@@ -0,0 +1,71 @@
+<!doctype html>
+<html>
+
+    <head>
+        <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
+        <title>Metadataplayer test with HTML5 / OGG Video</title>
+        <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
+        <link href='test.css' rel='stylesheet' type='text/css'>
+        <script type="text/javascript" src="metadataplayer/LdtPlayer-core.js" type="text/javascript"></script>
+        <script type="text/javascript" src="libs/underscore-min.js" type="text/javascript"></script>
+    </head>
+
+    <body>
+        <h1>Metadataplayer test with HTML5 / H.264 Video - Uses Popcorn with compatible browsers, JwPlayer with others</h1>
+        <div id="LdtPlayer"></div>
+        <div id="AnnotationsListContainer"></div>
+        <script type="text/javascript">
+IriSP._ = _;
+IriSP.libFiles.defaultDir = "libs/";
+IriSP.widgetsDir = "metadataplayer";
+var _dir = new IriSP.Model.Directory(),
+    _src = _dir.newLocalSource(),
+    _media = new IriSP.Model.Media(false, _src),
+    _cutt = new IriSP.Model.AnnotationType(false, _src),
+    _ann1 = new IriSP.Model.Annotation(false, _src),
+    _ann2 = new IriSP.Model.Annotation(false, _src);
+_cutt.title = "Chapitrage";
+_ann1.setAnnotationType(_cutt.id);
+_ann2.setAnnotationType(_cutt.id);
+_ann1.setMedia(_media.id);
+_ann2.setMedia(_media.id);
+_ann1.setBegin(0);
+_ann1.setEnd(32000);
+_ann1.title = "Première Annotation";
+_ann2.setBegin(32000);
+_ann2.setEnd(64000);
+_ann2.title = "Deuxième Annotation";
+_media.video = "trailer.mp4";
+_media.setDuration(64000);
+console.log("OK");
+var _config = {
+    width : 620,
+    container : 'LdtPlayer',
+    default_options: {
+        metadata: _src
+    },
+    css : 'metadataplayer/LdtPlayer-core.css',
+    widgets: [
+        {
+            type: "AdaptivePlayer"
+        },
+        { type: "Sparkline" },
+        { type: "Slider" },
+        { type: "Controller" },
+        { type: "Polemic" },
+        { type: "Segments" },
+        { type: "Annotation" },
+        { type: "Tweet" },
+        { type: "Tagcloud" },
+        {
+            type: "AnnotationsList",
+            container: "AnnotationsListContainer"
+        },
+        { type: "Mediafragment"}
+    ]
+};
+_myPlayer = new IriSP.Metadataplayer(_config);
+        </script>
+    </body>
+</html>