Modified AutoPlayer for the platform platform-restapi
authorveltr
Mon, 05 Nov 2012 19:02:48 +0100
branchplatform-restapi
changeset 976 4b9ec475026a
parent 975 35aadec4131b
child 977 934a7b13a2ca
child 978 fcddc519938c
Modified AutoPlayer for the platform
src/js/model.js
src/widgets/AutoPlayer.js
src/widgets/PopcornPlayer.js
test/jwplayer.htm
test/mp4video.htm
test/oggvideo.htm
--- a/src/js/model.js	Fri Oct 26 18:37:55 2012 +0200
+++ b/src/js/model.js	Mon Nov 05 19:02:48 2012 +0100
@@ -356,7 +356,7 @@
     var _hms = this.getHMS(),
         _res = '';
     if (_hms.hours) {
-        _res += pad(_hms.hours) + ':'
+        _res += _hms.hours + ':'
     }
     _res += pad(_hms.minutes) + ':' + pad(_hms.seconds);
     return _res;
@@ -619,11 +619,17 @@
 Model.Annotation.prototype = new Model.Element();
 
 Model.Annotation.prototype.setBegin = function(_beginMs) {
-    this.begin.setMilliseconds(_beginMs);
+    this.begin.setMilliseconds(Math.max(0,_beginMs));
+    this.trigger("change-begin");
 }
 
-Model.Annotation.prototype.setEnd = function(_beginMs) {
-    this.end.setMilliseconds(_beginMs);
+Model.Annotation.prototype.setEnd = function(_endMs) {
+    this.end.setMilliseconds(Math.min(_endMs));
+    this.trigger("change-end");
+}
+
+Model.Annotation.prototype.setDuration = function(_durMs) {
+    this.setEnd(_durMs + this.begin.milliseconds);
 }
 
 Model.Annotation.prototype.setMedia = function(_idRef) {
--- a/src/widgets/AutoPlayer.js	Fri Oct 26 18:37:55 2012 +0200
+++ b/src/widgets/AutoPlayer.js	Mon Nov 05 19:02: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,7 +41,8 @@
                 regexp: /^(https?:\/\/)?(www\.)?dailymotion\.com/,
                 type: "DailymotionPlayer"
             }
-        ];
+        ],
+        _rtmprgx = /^rtmp:\/\//;
     
     for (var i = 0; i < _types.length; i++) {
         if (_types[i].regexp.test(this.video)) {
@@ -45,12 +54,16 @@
         _opts.type = this.default_type
     }
     
+    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/src/widgets/PopcornPlayer.js	Fri Oct 26 18:37:55 2012 +0200
+++ b/src/widgets/PopcornPlayer.js	Mon Nov 05 19:02:48 2012 +0100
@@ -11,7 +11,6 @@
 }
 
 IriSP.Widgets.PopcornPlayer.prototype.draw = function() {
-
     
     if (typeof this.video === "undefined") {
         this.video = this.media.video;
--- a/test/jwplayer.htm	Fri Oct 26 18:37:55 2012 +0200
+++ b/test/jwplayer.htm	Mon Nov 05 19:02:48 2012 +0100
@@ -32,9 +32,7 @@
         widgets: [
             {
                 type: "AutoPlayer",
-                live: true,
-                width: 550, 
-                provider: "rtmp",
+                width: 550,
                 autostart: true
             },
             { type: "Slider" },
--- a/test/mp4video.htm	Fri Oct 26 18:37:55 2012 +0200
+++ b/test/mp4video.htm	Mon Nov 05 19:02:48 2012 +0100
@@ -30,7 +30,7 @@
     css : 'metadataplayer/LdtPlayer-core.css',
     widgets: [
         {
-            type: "AdaptivePlayer",
+            type: "AutoPlayer",
             video: "trailer.mp4"
         },
         { type: "Sparkline" },
--- a/test/oggvideo.htm	Fri Oct 26 18:37:55 2012 +0200
+++ b/test/oggvideo.htm	Mon Nov 05 19:02:48 2012 +0100
@@ -29,7 +29,7 @@
     },
     css : 'metadataplayer/LdtPlayer-core.css',
     widgets: [
-        { type: "PopcornPlayer" },
+        { type: "AutoPlayer" },
         { type: "Slider" },
         { type: "Controller" },
         { type: "Polemic" },