--- a/src/js/defaults.js Tue Nov 06 10:59:57 2012 +0100
+++ b/src/js/defaults.js Fri Nov 09 14:33:03 2012 +0100
@@ -56,6 +56,9 @@
noCss: true,
requires: [ "swfObject" ]
},
+ AdaptivePlayer: {
+ noCss: true
+ },
AutoPlayer: {
noCss: true
},
--- a/src/js/model.js Tue Nov 06 10:59:57 2012 +0100
+++ b/src/js/model.js Fri Nov 09 14:33:03 2012 +0100
@@ -1,33 +1,30 @@
/* TODO: Separate Project-specific data from Source */
/* model.js is where data is stored in a standard form, whatever the serializer */
+
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 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;
- }
- 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 uidbase + pad(4, (++uidincrement % 0x10000), 16) + "-" + rand16(4) + "-" + rand16(6) + rand16(6);
},
regexpFromTextOrArray : function(_textOrArray, _testOnly, _iexact) {
var _testOnly = _testOnly || false,
@@ -75,13 +72,12 @@
return _res;
},
dateToIso : function(d) {
- function pad(n){return n<10 ? '0'+n : n}
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'
}
}
@@ -346,19 +342,12 @@
}
Model.Time.prototype.toString = function() {
- function pad(_n) {
- var _res = _n.toString();
- while (_res.length < 2) {
- _res = '0' + _res;
- }
- return _res;
- }
var _hms = this.getHMS(),
_res = '';
if (_hms.hours) {
_res += _hms.hours + ':'
}
- _res += pad(_hms.minutes) + ':' + pad(_hms.seconds);
+ _res += pad(2, _hms.minutes) + ':' + pad(2, _hms.seconds);
return _res;
}
--- a/src/widgets/AutoPlayer.js Tue Nov 06 10:59:57 2012 +0100
+++ b/src/widgets/AutoPlayer.js Fri Nov 09 14:33:03 2012 +0100
@@ -55,6 +55,11 @@
_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;
--- a/src/widgets/Sparkline.js Tue Nov 06 10:59:57 2012 +0100
+++ b/src/widgets/Sparkline.js Fri Nov 09 14:33:03 2012 +0100
@@ -20,11 +20,20 @@
_list = this.getWidgetAnnotations();
for (var _i = 0; _i < this.slice_count; _i++) {
- var _begin = new IriSP.Model.Time(_i*_duration/this.slice_count),
- _end = new IriSP.Model.Time((_i+1)*_duration/this.slice_count),
- _annotations = _list.filter(function(_annotation) {
- return _annotation.begin >= _begin && _annotation.end < _end;
- }).length;
+ var _begin = (_i*_duration/this.slice_count),
+ _end = ((_i+1)*_duration/this.slice_count),
+ _annotations = _list.reduce(function(_m, _annotation) {
+ if (_annotation.begin < _end && _annotation.begin >= _begin) {
+ var _d = _annotation.getDuration().milliseconds;
+ if (!_d) {
+ return _m + 1;
+ } else {
+ return _m + (Math.min(_annotation.end, _end) - Math.max(_annotation.begin, _begin)) / _d;
+ }
+ } else {
+ return _m
+ }
+ },0);
_max = Math.max(_max, _annotations);
_slices.push(_annotations);
}