# HG changeset patch
# User veltr
# Date 1347808626 -32400
# Node ID 4da0a5740b6cbbbb925d849cda34e909692acf52
# Parent 7c1d08cf6956ef3490389c354a430f1bf79b52a3
Starting 'players-as-widgets' branch
diff -r 7c1d08cf6956 -r 4da0a5740b6c src/js/init.js
--- a/src/js/init.js Fri Sep 14 10:38:04 2012 +0900
+++ b/src/js/init.js Mon Sep 17 00:17:06 2012 +0900
@@ -18,8 +18,7 @@
_container.innerHTML = '
');
this.$zone.addClass("Ldt-Polemic");
this.$.append(this.$zone);
@@ -168,8 +168,8 @@
}).mouseout(function() {
_annotation.trigger("unselect");
}).click(function() {
- _this.player.popcorn.trigger("IriSP.Mediafragment.setHashToAnnotation", _annotation.id);
- _this.player.popcorn.trigger("IriSP.Tweet.show", _annotation.id);
+ _this.player.trigger("Mediafragment.setHashToAnnotation", _annotation.id);
+ _this.player.trigger("Tweet.show", _annotation.id);
});
_annotation.on("select", function() {
_this.tooltip.show(
@@ -214,9 +214,9 @@
this.$tweets = this.$.find(".Ldt-Polemic-TweetDiv");
- this.bindPopcorn("IriSP.search", "onSearch");
- this.bindPopcorn("IriSP.search.closed", "onSearch");
- this.bindPopcorn("IriSP.search.cleared", "onSearch");
+ this.onMdpEvent("search", "onSearch");
+ this.onMdpEvent("search.closed", "onSearch");
+ this.onMdpEvent("search.cleared", "onSearch");
} else {
this.$zone.hide();
@@ -303,7 +303,7 @@
this.$zone.click(function(_e) {
var _x = _e.pageX - _this.$zone.offset().left;
- _this.player.popcorn.currentTime(_this.source.getDuration().getSeconds() * _x / _this.width);
+ _this.media.setCurrentTime(_this.media.duration * _x / _this.width);
});
this.$.append('
');
@@ -311,8 +311,8 @@
this.insertSubwidget(this.$.find(".Ldt-Polemic-Tooltip"), "tooltip", { type: "Tooltip" });
}
-IriSP.Widgets.Polemic.prototype.onTimeupdate = function() {
- var _x = Math.floor( this.width * this.player.popcorn.currentTime() / this.source.getDuration().getSeconds());
+IriSP.Widgets.Polemic.prototype.onTimeupdate = function(_time) {
+ var _x = Math.floor( this.width * _time / this.media.duration);
this.$elapsed.css({
width: _x + "px"
});
diff -r 7c1d08cf6956 -r 4da0a5740b6c src/widgets/Renkan.js
--- a/src/widgets/Renkan.js Fri Sep 14 10:38:04 2012 +0900
+++ b/src/widgets/Renkan.js Mon Sep 17 00:17:06 2012 +0900
@@ -82,27 +82,26 @@
}
});
_node.on("click", function() {
- _this.player.popcorn.currentTime(_ann.begin.getSeconds());
- _this.player.popcorn.trigger("IriSP.Mediafragment.setHashToAnnotation", _ann.id);
+ _this.media.setCurrentTime(_ann.begin);
+ _this.player.trigger("Mediafragment.setHashToAnnotation", _ann.id);
});
});
}
var _tagmatch = _uri.match(_this.tag_regexp);
if (_tagmatch) {
_node.on("select", function() {
- _this.player.popcorn.trigger("IriSP.search.triggeredSearch",_tagmatch[1]);
+ _this.player.trigger("search.triggeredSearch",_tagmatch[1]);
})
_node.on("unselect", function() {
- _this.player.popcorn.trigger("IriSP.search.cleared");
+ _this.player.trigger("search.cleared");
})
}
});
})
- this.bindPopcorn("timeupdate","onTimeupdate");
+ this.onMediaEvent("timeupdate","onTimeupdate");
}
-IriSP.Widgets.Renkan.prototype.onTimeupdate = function() {
- var _time = 1000 * this.player.popcorn.currentTime();
+IriSP.Widgets.Renkan.prototype.onTimeupdate = function(_time) {
IriSP._(this.node_times).each(function(_nt) {
if (_nt.begin <= _time && _nt.end >= _time) {
if (!_nt.selected) {
diff -r 7c1d08cf6956 -r 4da0a5740b6c src/widgets/Segments.js
--- a/src/widgets/Segments.js Fri Sep 14 10:38:04 2012 +0900
+++ b/src/widgets/Segments.js Mon Sep 17 00:17:06 2012 +0900
@@ -23,10 +23,10 @@
IriSP.Widgets.Segments.prototype.draw = function() {
- this.bindPopcorn("IriSP.search", "onSearch");
- this.bindPopcorn("IriSP.search.closed", "onSearch");
- this.bindPopcorn("IriSP.search.cleared", "onSearch");
- this.bindPopcorn("timeupdate", "onTimeupdate");
+ this.onMdpEvent("search", "onSearch");
+ this.onMdpEvent("search.closed", "onSearch");
+ this.onMdpEvent("search.cleared", "onSearch");
+ this.onMediaEvent("timeupdate", "onTimeupdate");
this.renderTemplate();
@@ -44,8 +44,7 @@
var _left = _annotation.begin * _scale,
_width = ( _annotation.getDuration() ) * _scale,
_center = Math.floor( _left + _width / 2 ),
- _fulltext = _annotation.title + ( _annotation.description ? ( '
' + _annotation.description ) : '' ),
- _beginseconds = _annotation.begin.getSeconds();
+ _fulltext = _annotation.title + ( _annotation.description ? ( '
' + _annotation.description ) : '' );
var _data = {
color : ( typeof _annotation.color !== "undefined" && _annotation.color ? _annotation.color : _this.colors[_k % _this.colors.length] ),
text: _fulltext.replace(/(\n|\r|\r\n)/mg,' ').replace(/(^.{120,140})[\s].+$/m,'$1…'),
@@ -63,8 +62,8 @@
_annotation.trigger("unselect");
})
.click(function() {
- _this.player.popcorn.currentTime(_beginseconds);
- _this.player.popcorn.trigger("IriSP.Mediafragment.setHashToAnnotation", _data.id);
+ _this.media.setCurrentTime(_annotation.begin);
+ _this.player.trigger("Mediafragment.setHashToAnnotation", _data.id);
})
.appendTo(_this.list_$)
_annotation.on("select", function() {
@@ -96,17 +95,17 @@
}
});
if (_found) {
- this.player.popcorn.trigger("IriSP.search.matchFound");
+ this.player.trigger("search.matchFound");
} else {
- this.player.popcorn.trigger("IriSP.search.noMatchFound");
+ this.player.trigger("search.noMatchFound");
}
} else {
this.$segments.removeClass("found unfound");
}
}
-IriSP.Widgets.Segments.prototype.onTimeupdate = function() {
- var _x = Math.floor( this.width * this.player.popcorn.currentTime() / this.source.getDuration().getSeconds());
+IriSP.Widgets.Segments.prototype.onTimeupdate = function(_time) {
+ var _x = Math.floor( this.width * _time / this.media.duration);
this.$.find('.Ldt-Segments-Position').css({
left: _x + "px"
})
diff -r 7c1d08cf6956 -r 4da0a5740b6c src/widgets/Slice.js
--- a/src/widgets/Slice.js Fri Sep 14 10:38:04 2012 +0900
+++ b/src/widgets/Slice.js Mon Sep 17 00:17:06 2012 +0900
@@ -40,28 +40,28 @@
min: 0,
max: this.max,
change: function(event, ui) {
- _this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{
+ _this.player.trigger("Arrow.updatePosition",{
widget:_this.type,
time:Math.floor((ui.values[0]+ui.values[1])/2)
});
- _this.player.popcorn.trigger("IriSP.Slice.boundsChanged",[ui.values[0], ui.values[1]]);
+ _this.player.trigger("Slice.boundsChanged",[ui.values[0], ui.values[1]]);
},
start: function() {
_this.sliding = true;
- if (!_this.player.popcorn.media.paused) {
- _this.player.popcorn.pause();
+ if (!_this.media.getPaused) {
+ _this.media.pause();
}
- _currentTime = _this.player.popcorn.currentTime();
+ _currentTime = _this.media.getCurrentTime();
},
slide: function(event, ui) {
if (!_this.override_bounds && (ui.value < _this.min || ui.value > _this.max)) {
return false;
}
- _this.player.popcorn.currentTime(ui.value / 1000);
+ _this.media.setCurrentTime(ui.value);
},
stop: function() {
_this.sliding = false;
- _this.player.popcorn.currentTime(_currentTime);
+ _this.media.setCurrentTime(_currentTime);
}
});
this.$slider.find(".ui-slider-handle:first").addClass("Ldt-Slice-left-handle");
@@ -71,25 +71,25 @@
} else {
this.hide();
}
- this.bindPopcorn("IriSP.Slice.show","show");
- this.bindPopcorn("IriSP.Slice.hide","hide");
- this.bindPopcorn("IriSP.Annotation.boundsChanged","storeBounds");
- this.player.popcorn.trigger("IriSP.Annotation.getBounds");
+ this.onMdpEvent("Slice.show","show");
+ this.onMdpEvent("Slice.hide","hide");
+ this.onMdpEvent("Annotation.boundsChanged","storeBounds");
+ this.player.trigger("Annotation.getBounds");
};
IriSP.Widgets.Slice.prototype.show = function() {
this.$slider.show();
- this.player.popcorn.trigger("IriSP.Arrow.takeover",this.type);
+ this.player.trigger("Arrow.takeover",this.type);
this.$slider.slider("values", [this.min, this.max]);
}
IriSP.Widgets.Slice.prototype.hide = function() {
this.$slider.hide();
- this.player.popcorn.trigger("IriSP.Arrow.release");
+ this.player.trigger("Arrow.release");
}
IriSP.Widgets.Slice.prototype.storeBounds = function(_values) {
- if (!this.player.popcorn.media.paused && (this.min != _values[0] || this.max != _values[1])) {
+ if (!this.media.getPaused() && (this.min != _values[0] || this.max != _values[1])) {
this.min = _values[0];
this.max = _values[1];
if (this.live_update && !this.sliding) {
diff -r 7c1d08cf6956 -r 4da0a5740b6c src/widgets/Slider.js
--- a/src/widgets/Slider.js Fri Sep 14 10:38:04 2012 +0900
+++ b/src/widgets/Slider.js Mon Sep 17 00:17:06 2012 +0900
@@ -30,16 +30,16 @@
min: 0,
max: this.source.getDuration().milliseconds,
slide: function(event, ui) {
- _this.player.popcorn.currentTime(ui.value / 1000);
- _this.player.popcorn.trigger("IriSP.Mediafragment.setHashToTime");
+ _this.media.setCurrentTime(ui.value);
+ _this.player.trigger("Mediafragment.setHashToTime");
}
});
this.$handle = this.$slider.find('.ui-slider-handle');
- this.bindPopcorn("timeupdate","onTimeupdate");
- this.bindPopcorn("IriSP.PlayerWidget.MouseOver","onMouseover");
- this.bindPopcorn("IriSP.PlayerWidget.MouseOut","onMouseout");
+ this.onMediaEvent("timeupdate","onTimeupdate");
+ this.onMdpEvent("PlayerWidget.MouseOver","onMouseover");
+ this.onMdpEvent("PlayerWidget.MouseOut","onMouseout");
if (this.minimize_timeout) {
this.$slider.css(this.calculateSliderCss(this.minimized_height));
@@ -54,10 +54,9 @@
}
};
-IriSP.Widgets.Slider.prototype.onTimeupdate = function() {
- var _time = 1000 * this.player.popcorn.currentTime();
+IriSP.Widgets.Slider.prototype.onTimeupdate = function(_time) {
this.$slider.slider("value",_time);
- this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{widget: this.type, time: _time});
+ this.player.trigger("Arrow.updatePosition",{widget: this.type, time: _time});
}
IriSP.Widgets.Slider.prototype.onMouseover = function() {
diff -r 7c1d08cf6956 -r 4da0a5740b6c src/widgets/Slideshare.js
--- a/src/widgets/Slideshare.js Fri Sep 14 10:38:04 2012 +0900
+++ b/src/widgets/Slideshare.js Mon Sep 17 00:17:06 2012 +0900
@@ -42,12 +42,12 @@
} else {
this.renderTemplate();
this.$container = this.$.find(".Ldt-SlideShare-Container");
- this.bindPopcorn("timeupdate","onTimeupdate");
- this.onTimeupdate();
+ this.onMediaEvent("timeupdate","onTimeupdate");
+ this.onTimeupdate(0);
}
}
-IriSP.Widgets.Slideshare.prototype.onTimeupdate = function() {
+IriSP.Widgets.Slideshare.prototype.onTimeupdate = function(_time) {
var _list = this.getWidgetAnnotationsAtTime();
if (_list.length) {
var _description = _list[0].description,
diff -r 7c1d08cf6956 -r 4da0a5740b6c src/widgets/Sparkline.js
--- a/src/widgets/Sparkline.js Fri Sep 14 10:38:04 2012 +0900
+++ b/src/widgets/Sparkline.js Mon Sep 17 00:17:06 2012 +0900
@@ -1,6 +1,5 @@
IriSP.Widgets.Sparkline = function(player, config) {
IriSP.Widgets.Widget.call(this, player, config);
- //this.bindPopcorn("timeupdate", "onTimeupdate");
};
IriSP.Widgets.Sparkline.prototype = new IriSP.Widgets.Widget();
@@ -68,14 +67,14 @@
this.$.click(function(_e) {
var _x = _e.pageX - _this.$.offset().left;
- _this.player.popcorn.currentTime(_this.source.getDuration().getSeconds() * _x / _this.width);
+ _this.media.setCurrentTime(_this.media.duration * _x / _this.width);
});
- this.bindPopcorn("timeupdate","onTimeupdate");
+ this.onMediaEvent("timeupdate","onTimeupdate");
}
-IriSP.Widgets.Sparkline.prototype.onTimeupdate = function() {
- var _x = Math.floor( this.width * this.player.popcorn.currentTime() / this.source.getDuration().getSeconds());
+IriSP.Widgets.Sparkline.prototype.onTimeupdate = function(_time) {
+ var _x = Math.floor( this.width * _time / this.media.duration);
this.rectangleProgress.attr({
"width" : _x
});
diff -r 7c1d08cf6956 -r 4da0a5740b6c src/widgets/Tagcloud.js
--- a/src/widgets/Tagcloud.js Fri Sep 14 10:38:04 2012 +0900
+++ b/src/widgets/Tagcloud.js Mon Sep 17 00:17:06 2012 +0900
@@ -39,20 +39,19 @@
}
IriSP.Widgets.Tagcloud.prototype.draw = function() {
- this.bindPopcorn("IriSP.search", "onSearch");
- this.bindPopcorn("IriSP.search.closed", "onSearch");
- this.bindPopcorn("IriSP.search.cleared", "onSearch");
+ this.onMdpEvent("search", "onSearch");
+ this.onMdpEvent("search.closed", "onSearch");
+ this.onMdpEvent("search.cleared", "onSearch");
if (this.segment_annotation_type) {
- this.bindPopcorn("timeupdate","onTimeupdate");
+ this.onMediaEvent("timeupdate","onTimeupdate");
} else {
this.redraw();
}
}
-IriSP.Widgets.Tagcloud.prototype.onTimeupdate = function() {
- var _time = Math.floor(this.player.popcorn.currentTime() * 1000),
- _list = this.source.getAnnotationsByTypeTitle(this.segment_annotation_type).filter(function(_annotation) {
+IriSP.Widgets.Tagcloud.prototype.onTimeupdate = function(_time) {
+ var _list = this.source.getAnnotationsByTypeTitle(this.segment_annotation_type).filter(function(_annotation) {
return _annotation.begin <= _time && _annotation.end > _time;
});
if (_list.length) {
@@ -117,7 +116,7 @@
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.popcorn.trigger("IriSP.search.triggeredSearch", _txt);
+ _this.player.trigger("search.triggeredSearch", _txt);
});
}
diff -r 7c1d08cf6956 -r 4da0a5740b6c src/widgets/Tagger.js
--- a/src/widgets/Tagger.js Fri Sep 14 10:38:04 2012 +0900
+++ b/src/widgets/Tagger.js Mon Sep 17 00:17:06 2012 +0900
@@ -130,7 +130,7 @@
_this.player.popcorn.play();
}
/* On force le rafraîchissement du widget AnnotationsList */
- _this.player.popcorn.trigger("IriSP.AnnotationsList.refresh");
+ _this.player.trigger("AnnotationsList.refresh");
},
error: function(_xhr, _error, _thrown) {
console.log("Error when sending annotation", _thrown);
diff -r 7c1d08cf6956 -r 4da0a5740b6c src/widgets/Tooltip.js
--- a/src/widgets/Tooltip.js Fri Sep 14 10:38:04 2012 +0900
+++ b/src/widgets/Tooltip.js Mon Sep 17 00:17:06 2012 +0900
@@ -1,6 +1,6 @@
/* this widget displays a small tooltip */
-IriSP.Widgets.Tooltip = function(Popcorn, config, Serializer) {
- IriSP.Widgets.Widget.call(this, Popcorn, config, Serializer);
+IriSP.Widgets.Tooltip = function(player, config) {
+ IriSP.Widgets.Widget.call(this, player, config);
};
IriSP.Widgets.Tooltip.prototype = new IriSP.Widgets.Widget();
diff -r 7c1d08cf6956 -r 4da0a5740b6c src/widgets/Trace.js
--- a/src/widgets/Trace.js Fri Sep 14 10:38:04 2012 +0900
+++ b/src/widgets/Trace.js Mon Sep 17 00:17:06 2012 +0900
@@ -22,15 +22,17 @@
return;
}
var _this = this,
- _listeners = {
- "IriSP.search.open" : 0,
- "IriSP.search.closed" : 0,
- "IriSP.search" : 0,
- "IriSP.search.cleared" : 0,
- "IriSP.search.matchFound" : 0,
- "IriSP.search.noMatchFound" : 0,
- "IriSP.search.triggeredSearch" : 0,
- "IriSP.TraceWidget.MouseEvents" : 0,
+ _mdplisteners = {
+ "search.open" : 0,
+ "search.closed" : 0,
+ "search" : 0,
+ "search.cleared" : 0,
+ "search.matchFound" : 0,
+ "search.noMatchFound" : 0,
+ "search.triggeredSearch" : 0,
+ "TraceWidget.MouseEvents" : 0
+ }
+ _medialisteners = {
"play" : 0,
"pause" : 0,
"volumechange" : 0,
@@ -39,14 +41,23 @@
"pause" : 0,
"timeupdate" : 2000
};
- IriSP._(_listeners).each(function(_ms, _listener) {
+ IriSP._(_mdplisteners).each(function(_ms, _listener) {
var _f = function(_arg) {
_this.eventHandler(_listener, _arg);
}
if (_ms) {
_f = IriSP._.throttle(_f, _ms);
}
- _this.player.popcorn.listen(_listener, _f);
+ _this.onMdpEvent(_listener, _f);
+ });
+ IriSP._(_medialisteners).each(function(_ms, _listener) {
+ var _f = function(_arg) {
+ _this.eventHandler(_listener, _arg);
+ }
+ if (_ms) {
+ _f = IriSP._.throttle(_f, _ms);
+ }
+ _this.media.on(_listener, _f);
});
if (!this.tracer) {
@@ -91,7 +102,7 @@
switch(_e.type) {
case "mouseover":
if (_this.lastTarget != _lastTarget) {
- _this.player.popcorn.trigger('IriSP.TraceWidget.MouseEvents', _data);
+ _this.player.trigger('TraceWidget.MouseEvents', _data);
} else {
if (typeof _this.moTimeout != "undefined") {
clearTimeout(_this.moTimeout);
@@ -105,12 +116,12 @@
}
_this.moTimeout = setTimeout(function() {
if (_lastTarget != _this.lastTarget) {
- _this.player.popcorn.trigger('IriSP.TraceWidget.MouseEvents', _data);
+ _this.player.trigger('TraceWidget.MouseEvents', _data);
}
},100);
break;
default:
- _this.player.popcorn.trigger('IriSP.TraceWidget.MouseEvents', _data);
+ _this.player.trigger('TraceWidget.MouseEvents', _data);
}
_this.lastTarget = _lastTarget;
});
@@ -133,13 +144,13 @@
case 'timeupdate':
case 'play':
case 'pause':
- _arg.time = this.player.popcorn.currentTime() * 1000;
+ _arg.time = this.player.getCurrentTime().milliseconds;
case 'seeked':
case 'volumechange':
- _traceName += 'Popcorn_' + _listener;
+ _traceName += 'media_' + _listener;
break;
default:
- _traceName += _listener.replace('IriSP.','').replace('.','_');
+ _traceName += _listener.replace('.','_');
}
this.lastEvent = _traceName;
if (typeof this.extend === "object" && this.extend) {
diff -r 7c1d08cf6956 -r 4da0a5740b6c src/widgets/Tweet.js
--- a/src/widgets/Tweet.js Fri Sep 14 10:38:04 2012 +0900
+++ b/src/widgets/Tweet.js Mon Sep 17 00:17:06 2012 +0900
@@ -66,7 +66,7 @@
IriSP.Widgets.Tweet.prototype.draw = function() {
this.renderTemplate();
- this.bindPopcorn("IriSP.Tweet.show","show");
+ this.onMdpEvent("Tweet.show","show");
this.pinned = this.pin_at_start;
var _this = this;
this.$.find(".Ldt-Tweet-Pin").click(function() {
@@ -170,7 +170,7 @@
this.$.find(".Ldt-Tweet-Retweet").attr("href", "https://twitter.com/intent/retweet?tweet_id=" + _tweet.source.id_str);
this.$.find(".Ldt-Tweet-Reply").attr("href", "https://twitter.com/intent/tweet?in_reply_to=" + _tweet.source.id_str);
this.$.find(".Ldt-Tweet-Original").attr("href", "https://twitter.com/" + _tweet.source.user.screen_name + "/status/" + _tweet.source.id_str);
- this.player.popcorn.trigger("IriSP.Annotation.minimize");
+ this.player.trigger("Annotation.minimize");
this.$.slideDown();
this.cancelTimeout();
if (!this.pinned) {
@@ -182,7 +182,7 @@
}
IriSP.Widgets.Tweet.prototype.hide = function() {
- this.player.popcorn.trigger("IriSP.Annotation.maximize");
+ this.player.trigger("Annotation.maximize");
this.$.slideUp();
this.cancelTimeout();
}
diff -r 7c1d08cf6956 -r 4da0a5740b6c test/oggvideo.htm
--- a/test/oggvideo.htm Fri Sep 14 10:38:04 2012 +0900
+++ b/test/oggvideo.htm Mon Sep 17 00:17:06 2012 +0900
@@ -15,7 +15,51 @@