--- a/web/res/metadataplayer/AnnotationsList.js Thu Sep 26 14:46:53 2013 +0200
+++ b/web/res/metadataplayer/AnnotationsList.js Tue Oct 01 16:33:47 2013 +0200
@@ -53,7 +53,7 @@
voice_annotation: "Annotation Vocale",
now_playing: "Lecture en cours..."
}
-}
+};
IriSP.Widgets.AnnotationsList.prototype.template =
'<div class="Ldt-AnnotationsListWidget">'
@@ -85,7 +85,7 @@
+ '{{/tags}}'
+ '</ul>'
+ '{{/tags.length}}'
- + '{{#audio}}<div class="Ldt-AnnotationsList-Play" data-audio={{audio}}>{{l10n.voice_annotation}}</div>{{/audio}}'
+ + '{{#audio}}<div class="Ldt-AnnotationsList-Play" data-annotation-id="{{id}}">{{l10n.voice_annotation}}</div>{{/audio}}'
+ '</li>';
//obj.url = this.project_url + "/" + media + "/" + annotations[i].meta.project + "/" + annotations[i].meta["id-ref"] + '#id=' + annotations[i].id;
@@ -102,7 +102,7 @@
this.currentSource = this.player.loadMetadata(IriSP._.defaults({
"url" : _url
}, this.metadata));
-}
+};
IriSP.Widgets.AnnotationsList.prototype.ajaxMashup = function() {
var _currentTime = this.media.getCurrentTime();
@@ -119,7 +119,7 @@
"url" : _url
}, this.metadata));
}
-}
+};
IriSP.Widgets.AnnotationsList.prototype.refresh = function(_forceRedraw) {
_forceRedraw = (typeof _forceRedraw !== "undefined" && _forceRedraw);
@@ -146,7 +146,7 @@
/* Get the n annotations closest to current timecode */
_list = _list.sortBy(function(_annotation) {
return Math.abs((_annotation.begin + _annotation.end) / 2 - _currentTime);
- }).slice(0, this.limit_count)
+ }).slice(0, this.limit_count);
}
if (this.newest_first) {
_list = _list.sortBy(function(_annotation) {
@@ -211,17 +211,45 @@
url : _url,
tags : _annotation.getTagTexts(),
specific_style : (typeof _bgcolor !== "undefined" ? "background-color: " + _bgcolor : ""),
- audio : (_this.show_audio && _annotation.audio && _annotation.audio.href && _annotation.audio.href != "null" ? _annotation.audio.href : undefined),
l10n: _this.l10n
};
+ if (_this.show_audio && _annotation.audio && _annotation.audio.href && _annotation.audio.href != "null") {
+ _data.audio = true;
+ if (!_this.jwplayers[_annotation.id]) {
+ var _audiofile = _annotation.audio.href;
+ if (_this.audio_url_transform) {
+ _audiofile = _this.audio_url_transform(_annotation.audio.href);
+ }
+ var _tmpId = "jwplayer-" + IriSP.Model.getUID();
+ _this.jwplayers[_annotation.id] = _tmpId;
+ _this.$.find(".Ldt-AnnotationsList-Audio").append(IriSP.jQuery("<div>").attr("id", _tmpId));
+ jwplayer(_tmpId).setup({
+ flashplayer: IriSP.getLib("jwPlayerSWF"),
+ file: _audiofile,
+ fallback: false,
+ primary: "flash",
+ controls: false,
+ width: 1,
+ height: 1,
+ events: {
+ onPause: function() {
+ _this.$.find(".Ldt-AnnotationsList-Play[data-annotation-id=" + _annotation.id + "]").text(_this.l10n.voice_annotation);
+ },
+ onPlay: function() {
+ _this.$.find(".Ldt-AnnotationsList-Play[data-annotation-id=" + _annotation.id + "]").text(_this.l10n.now_playing);
+ }
+ }
+ });
+ }
+ }
var _html = Mustache.to_html(_this.annotationTemplate, _data),
_el = IriSP.jQuery(_html),
_onselect = function() {
- _this.annotations_$.removeClass("selected");
+ _this.$.find('.Ldt-AnnotationsList-li').removeClass("selected");
_el.addClass("selected");
},
_onunselect = function() {
- _this.annotations_$.removeClass("selected");
+ _this.$.find('.Ldt-AnnotationsList-li').removeClass("selected");
};
_el.mouseover(function() {
_annotation.trigger("select");
@@ -244,8 +272,6 @@
_annotation.on("unselect", _onunselect);
});
- this.annotations_$ = this.$.find('.Ldt-AnnotationsList-li');
-
/* Correct the empty tag bug */
this.$.find('.Ldt-AnnotationsList-Tag-Li').each(function() {
var _el = IriSP.jQuery(this);
@@ -260,14 +286,11 @@
this.$.find(".Ldt-AnnotationsList-Play").click(function() {
var _el = IriSP.jQuery(this),
- _audiofile = _el.attr("data-audio").replace(_this.rtmp_streamer,"");
- _el.text(_this.l10n.now_playing);
- _this.jwplayer.load({
- file: _audiofile
- });
- _this.jwplayer.play(true);
+ _annid = _el.attr("data-annotation-id");
+ if (_this.jwplayers[_annid]) {
+ jwplayer(_this.jwplayers[_annid]).play();
+ }
_this.media.pause();
- _this.jw_paused_media = true;
});
if (this.source.getAnnotations().searching) {
@@ -289,38 +312,17 @@
}
}
return _list.length;
-}
+};
IriSP.Widgets.AnnotationsList.prototype.draw = function() {
+ this.jwplayers = {};
this.mashupMode = (this.media.elementType === "mashup");
this.renderTemplate();
var _this = this;
-
- if (this.show_audio) {
- var _tmpId = "jwplayer-" + IriSP.Model.getUID();
- this.$.find(".Ldt-AnnotationsList-Audio").attr("id", _tmpId);
- this.jwplayer = jwplayer(_tmpId);
- this.jwplayer.setup({
- flashplayer: IriSP.getLib("jwPlayerSWF"),
- fallback: false,
- width: 1,
- height: 1,
- events: {
- onIdle: function() {
- if (_this.jw_paused_media) {
- _this.jw_paused_media = false;
- _this.media.play();
- }
- _this.$.find(".Ldt-AnnotationsList-Play").text(_this.l10n.voice_annotation)
- }
- }
- });
- this.jw_paused_media = false;
- }
-
+
this.list_$ = this.$.find(".Ldt-AnnotationsList-ul");
@@ -370,7 +372,7 @@
if (this.refresh_interval) {
window.setInterval(function() {
- _this.currentSource.get()
+ _this.currentSource.get();
}, this.refresh_interval);
}