--- a/.hgignore Wed Dec 07 11:09:24 2011 +0100
+++ b/.hgignore Wed Dec 07 12:07:12 2011 +0100
@@ -5,3 +5,4 @@
build/LdtPlayer-release.js
build/LdtPlayer.min.js
*.swp
+*.orig
--- a/sbin/build/client.xml Wed Dec 07 11:09:24 2011 +0100
+++ b/sbin/build/client.xml Wed Dec 07 12:07:12 2011 +0100
@@ -70,10 +70,10 @@
<target name="concatenate" description="Build the developer release file" depends="make_templates">
<concat encoding="UTF-8" outputencoding="UTF-8" destfile="../../build/LdtPlayer-release.js">
<filelist dir="../../src/js/" files="header.js" />
- <filelist dir="../../src/js/libs" files="popcorn.js popcorn.youtube.js popcorn.code.js popcorn.jwplayer.js popcorn.mediafragment.js jwplayer.js mustache.js raphael.js" />
+ <filelist dir="../../src/js/libs" files="jwplayer.js mustache.js raphael.js" />
<filelist dir="../../src/js" files="main.js" />
<filelist dir="../../build" files="compiled_templates.js" />
- <filelist dir="../../src/js" files="utils.js data.js site.js ui.js widgets.js layout.js init.js" />
+ <filelist dir="../../src/js" files="pop.js utils.js data.js site.js ui.js widgets.js layout.js init.js" />
<fileset dir="../../src/js/widgets" casesensitive="yes">
<include name="**/*.js"/>
</fileset>
--- a/src/js/init.js Wed Dec 07 11:09:24 2011 +0100
+++ b/src/js/init.js Wed Dec 07 12:07:12 2011 +0100
@@ -29,7 +29,7 @@
case "jwplayer":
var opts = IriSP.jQuery.extend({}, options);
delete opts.container;
- pop = Popcorn.jwplayer("#" + containerDiv, "", opts).mediafragment({start : 0});
+ pop = Popcorn.jwplayer("#" + containerDiv, opts);
break;
case "youtube":
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/js/pop.js Wed Dec 07 12:07:12 2011 +0100
@@ -0,0 +1,158 @@
+/* wrapper that simulates popcorn.js because
+ popcorn is a bit unstable at the time */
+
+Popcorn = {};
+Popcorn.media = { "paused": true};
+
+Popcorn.listen = function(msg, callback) {
+ IriSP.jQuery(Popcorn).bind(msg, function(event, rest) { callback(rest); });
+};
+
+Popcorn.trigger = function(msg, params) {
+ IriSP.jQuery(Popcorn).trigger(msg, params);
+};
+
+Popcorn.guid = function(prefix) {
+ var str = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
+ var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
+ return v.toString(16);
+ });
+
+ return prefix + str;
+};
+
+Popcorn.__initApi = function() {
+ Popcorn.trigger("timeupdate");
+};
+
+Popcorn.jwplayer = function(container, options) {
+ Popcorn._container = container.slice(1); //eschew the '#'
+ options.events = {
+ onReady: Popcorn.__initApi,
+ onTime: Popcorn.__timeHandler,
+ onSeek: Popcorn.__seekHandler }
+
+ jwplayer(Popcorn._container).setup(options);
+ Popcorn.media.duration = options.duration;
+ return Popcorn;
+};
+
+Popcorn.currentTime = function(time) {
+ if (typeof(time) === "undefined") {
+ return jwplayer(Popcorn._container).getPosition();
+ } else {
+ var currentTime = +time;
+ jwplayer( Popcorn._container ).seek( currentTime );
+ return jwplayer(Popcorn._container).getPosition();
+ }
+};
+
+Popcorn.play = function() {
+ Popcorn.media.paused = false;
+// Popcorn.trigger("play");
+// Popcorn.trigger("playing");
+ jwplayer( Popcorn._container ).play();
+};
+
+Popcorn.pause = function() {
+ if ( !Popcorn.media.paused ) {
+ Popcorn.media.paused = true;
+ Popcorn.trigger( "pause" );
+ jwplayer( Popcorn._container ).pause();
+ }
+};
+
+Popcorn.muted = function(val) {
+ if (typeof(val) !== "undefined") {
+
+ if (jwplayer(Popcorn._container).getMute() !== val) {
+ if (val) {
+ jwplayer(Popcorn._container).setMute(true);
+ } else {
+ jwplayer( Popcorn._container ).setMute(false);
+ }
+
+ Popcorn.trigger( "volumechange" );
+ }
+
+ return jwplayer( Popcorn._container ).getMute();
+ } else {
+ return jwplayer( Popcorn._container ).getMute();
+ }
+};
+
+Popcorn.mute = Popcorn.muted;
+
+Popcorn.__codes = [];
+Popcorn.code = function(options) {
+ Popcorn.__codes.push(options);
+ return Popcorn;
+};
+
+Popcorn.__runCode = function() {
+ var currentTime = jwplayer(Popcorn._container).getPosition();
+ var i = 0;
+ for(i = 0; i < Popcorn.__codes.length; i++) {
+ var c = Popcorn.__codes[i];
+ if (currentTime == c.start) {
+ c.onStart();
+ }
+
+ if (currentTime == c.end) {
+ c.onEnd();
+ }
+
+ }
+};
+
+/* called everytime the player updates itself
+ (onTime event)
+ */
+
+Popcorn.__timeHandler = function(event) {
+ var pos = event.position;
+
+ var i = 0;
+ for(i = 0; i < Popcorn.__codes.length; i++) {
+ var c = Popcorn.__codes[i];
+
+ if (pos >= c.start && pos < c.end &&
+ pos - 0.1 <= c.start) {
+ c.onStart();
+ }
+
+ if (pos >= c.start && pos >= c.end &&
+ pos - 0.1 <= c.end) {
+ c.onEnd();
+ }
+
+ }
+
+ Popcorn.trigger("timeupdate");
+};
+
+Popcorn.__seekHandler = function(event) {
+ var i = 0;
+ for(i = 0; i < Popcorn.__codes.length; i++) {
+ var c = Popcorn.__codes[i];
+
+ if (event.position >= c.start && event.position < c.end) {
+ c.onEnd();
+ }
+
+ if (typeof(event.offset) === "undefined")
+ event.offset = 0;
+ if (event.offset >= c.start && event.offset < c.end) {
+ c.onStart();
+ }
+
+ }
+
+ Popcorn.trigger("timeupdate");
+}
+
+
+Popcorn.roundTime = function() {
+ var currentTime = Popcorn.currentTime();
+ return Math.round(currentTime);
+};
--- a/src/js/widgets/annotationsWidget.js Wed Dec 07 11:09:24 2011 +0100
+++ b/src/js/widgets/annotationsWidget.js Wed Dec 07 12:07:12 2011 +0100
@@ -43,7 +43,17 @@
var annotationMarkup = IriSP.templToHTML(IriSP.annotationWidget_template);
this.selector.append(annotationMarkup);
+ var view;
+ if (typeof(this._serializer._data.views) !== "undefined" && this._serializer._data.views !== null)
+ view = this._serializer._data.views[0];
+
+ var view_type = "";
+
+ if(typeof(view) !== "undefined" && typeof(view.annotation_types) !== "undefined" && view.annotation_types.length > 1) {
+ view_type = view.annotation_types[0];
+ }
+
var annotations = this._serializer._data.annotations;
var i;
@@ -52,16 +62,17 @@
var begin = Math.round((+ annotation.begin) / 1000);
var end = Math.round((+ annotation.end) / 1000);
+ if (view_type != "" && typeof(annotation.meta) !== "undefined" && typeof(annotation.meta["id-ref"]) !== "undefined"
+ && annotation.meta["id-ref"] != view_type) {
+ continue;
+ }
+
+
var conf = {start: begin, end: end,
onStart:
function(annotation) {
return function() {
- /* we need it because we have to restore
- the display after displaying the contents
- of a tweet.
- */
- _this._currentAnnotation = annotation;
- _this.displayAnnotation(annotation);
+ _this.displayAnnotation(annotation);
} }(annotation),
onEnd:
--- a/src/js/widgets/segmentsWidget.js Wed Dec 07 11:09:24 2011 +0100
+++ b/src/js/widgets/segmentsWidget.js Wed Dec 07 12:07:12 2011 +0100
@@ -123,7 +123,7 @@
IriSP.SegmentsWidget.prototype.clickHandler = function(annotation) {
var begin = (+ annotation.begin) / 1000;
- this._Popcorn.currentTime(Math.floor(begin));
+ this._Popcorn.currentTime(Math.round(begin));
};
IriSP.SegmentsWidget.prototype.searchHandler = function(searchString) {