--- a/src/js/model.js Fri Oct 26 15:49:29 2012 +0200
+++ b/src/js/model.js Mon Nov 05 19:03:10 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/js/serializers/ldt_annotate.js Fri Oct 26 15:49:29 2012 +0200
+++ b/src/js/serializers/ldt_annotate.js Mon Nov 05 19:03:10 2012 +0100
@@ -5,67 +5,59 @@
}
IriSP.serializers.ldt_annotate = {
- types : {
- annotation : {
- serialized_name : "annotations",
- serializer : function(_data, _source) {
- var _annType = _data.getAnnotationType();
- return {
- begin: _data.begin.milliseconds,
- end: _data.end.milliseconds,
- content: {
- data: _data.description,
- audio: _data.audio
- },
- tags: _data.getTagTexts(),
- media: _data.getMedia().id,
- type_title: _annType.title,
- type: ( typeof _annType.dont_send_id !== "undefined" && _annType.dont_send_id ? "" : _annType.id )
- }
+ serializeAnnotation : function(_data, _source) {
+ var _annType = _data.getAnnotationType();
+ return {
+ begin: _data.begin.milliseconds,
+ end: _data.end.milliseconds,
+ content: {
+ description: _data.description,
+ title: _data.title,
+ audio: _data.audio
+ },
+ tags: _data.getTagTexts(),
+ media: _data.getMedia().id,
+ type_title: _annType.title,
+ type: ( typeof _annType.dont_send_id !== "undefined" && _annType.dont_send_id ? "" : _annType.id ),
+ meta: {
+ created: _data.created,
+ creator: _data.creator
}
}
},
serialize : function(_source) {
- var _res = {},
- _this = this;
- _source.forEach(function(_list, _typename) {
- if (typeof _this.types[_typename] !== "undefined") {
- _res[_this.types[_typename].serialized_name] = _list.map(function(_el) {
- return _this.types[_typename].serializer(_el, _source);
- });
- }
- });
- _res.meta = {
- creator: _source.creator,
- created: _source.created
- }
+ var _this = this
+ _res = {
+ "objects": _source.getAnnotations().map(function(_annotation) {
+ return _this.serializeAnnotation(_annotation, _source);
+ })
+ };
return JSON.stringify(_res);
},
deSerialize : function(_data, _source) {
if (typeof _data == "string") {
_data = JSON.parse(_data);
}
+
_source.addList('tag', new IriSP.Model.List(_source.directory));
_source.addList('annotationType', new IriSP.Model.List(_source.directory));
_source.addList('annotation', new IriSP.Model.List(_source.directory));
- if (typeof _data.annotations == "object" && _data.annotations && _data.annotations.length) {
- var _anndata = _data.annotations[0],
- _ann = new IriSP.Model.Annotation(_anndata.id, _source);
- _ann.description = _anndata.content.data || "";
- _ann.title = _data.creator || "";
- _ann.created = new Date(_data.meta.created);
+ IriSP._(_data.objects).each(function(_anndata) {
+ var _ann = new IriSP.Model.Annotation(_anndata.id, _source);
+ _ann.description = _anndata.content.description || "";
+ _ann.title = _anndata.content.title || "";
+ _ann.creator = _anndata.meta.creator || "";
+ _ann.created = new Date(_anndata.meta.created);
_ann.setMedia(_anndata.media, _source);
- var _anntypes = _source.getAnnotationTypes(true).searchByTitle(_anndata.type_title);
- if (_anntypes.length) {
- var _anntype = _anntypes[0];
- } else {
- var _anntype = new IriSP.Model.AnnotationType(_anndata.type, _source);
+ var _anntype = _source.getElement(_anndata.type);
+ if (!_anntype) {
+ _anntype = new IriSP.Model.AnnotationType(_anndata.type, _source);
_anntype.title = _anndata.type_title;
_source.getAnnotationTypes().push(_anntype);
}
_ann.setAnnotationType(_anntype.id);
var _tagIds = IriSP._(_anndata.tags).map(function(_title) {
- var _tags = _source.getTags(true).searchByTitle(_title);
+ var _tags = _source.getTags(true).searchByTitle(_title, true);
if (_tags.length) {
var _tag = _tags[0];
}
@@ -79,11 +71,10 @@
_ann.setTags(_tagIds);
_ann.setBegin(_anndata.begin);
_ann.setEnd(_anndata.end);
- _ann.creator = _data.meta.creator;
if (typeof _anndata.content.audio !== "undefined" && _anndata.content.audio.href) {
_ann.audio = _anndata.content.audio;
}
_source.getAnnotations().push(_ann);
- }
+ });
}
}
\ No newline at end of file
--- a/src/widgets/AutoPlayer.js Fri Oct 26 15:49:29 2012 +0200
+++ b/src/widgets/AutoPlayer.js Mon Nov 05 19:03:10 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/CreateAnnotation.css Fri Oct 26 15:49:29 2012 +0200
+++ b/src/widgets/CreateAnnotation.css Mon Nov 05 19:03:10 2012 +0100
@@ -34,6 +34,11 @@
border-radius: 2px;
}
+.Ldt-CreateAnnotation-Title.empty, .Ldt-CreateAnnotation-Creator.empty {
+ font-style: italic;
+ color: #90b0d0;
+}
+
.Ldt-CreateAnnotation-Times {
color: #ff3b77
}
@@ -67,6 +72,10 @@
border-radius: 2px;
}
+.Ldt-CreateAnnotation-Description.empty {
+ font-style: italic; color: #999999;
+}
+
.Ldt-CreateAnnotation-Avatar {
float: right;
width: 48px;
--- a/src/widgets/CreateAnnotation.js Fri Oct 26 15:49:29 2012 +0200
+++ b/src/widgets/CreateAnnotation.js Mon Nov 05 19:03:10 2012 +0100
@@ -7,7 +7,7 @@
IriSP.Widgets.CreateAnnotation.prototype = new IriSP.Widgets.Widget();
IriSP.Widgets.CreateAnnotation.prototype.defaults = {
- show_title_field : false, /* For the moment, titles can't be sent to ldtplatform */
+ show_title_field : true,
show_creator_field : true,
start_visible : true,
always_visible : false,
@@ -106,12 +106,12 @@
+ '{{^show_slice}}{{#show_arrow}}<div class="Ldt-CreateAnnotation-Arrow"></div>{{/show_arrow}}{{/show_slice}}'
+ '<div class="Ldt-CreateAnnotation"><div class="Ldt-CreateAnnotation-Inner">'
+ '<form class="Ldt-CreateAnnotation-Screen Ldt-CreateAnnotation-Main">'
- + '<h3><span class="Ldt-CreateAnnotation-h3Left">{{#show_title_field}}<input class="Ldt-CreateAnnotation-Title" placeholder="{{l10n.type_title}}" />{{/show_title_field}}'
+ + '<h3><span class="Ldt-CreateAnnotation-h3Left">{{#show_title_field}}<input class="Ldt-CreateAnnotation-Title empty" placeholder="{{l10n.type_title}}" />{{/show_title_field}}'
+ '{{^show_title_field}}<span class="Ldt-CreateAnnotation-NoTitle">{{l10n.no_title}} </span>{{/show_title_field}}'
- + ' <span class="Ldt-CreateAnnotation-Times">{{#show_slice}}{{l10n.from_time}} {{/show_slice}}{{^show_slice}}{{l10n.at_time}} {{/show_slice}} <span class="Ldt-CreateAnnotation-Begin">00:00</span>'
+ + '<span class="Ldt-CreateAnnotation-Times"> {{#show_slice}}{{l10n.from_time}} {{/show_slice}}{{^show_slice}}{{l10n.at_time}} {{/show_slice}} <span class="Ldt-CreateAnnotation-Begin">00:00</span>'
+ '{{#show_slice}} {{l10n.to_time}} <span class="Ldt-CreateAnnotation-End">{{end}}</span>{{/show_slice}}</span></span>'
- + '{{#show_creator_field}}{{l10n.your_name_}} <input class="Ldt-CreateAnnotation-Creator" value="{{creator_name}}" /></h3>{{/show_creator_field}}'
- + '<textarea class="Ldt-CreateAnnotation-Description" placeholder="{{l10n.type_description}}"></textarea>'
+ + '{{#show_creator_field}}{{l10n.your_name_}} <input class="Ldt-CreateAnnotation-Creator empty" value="{{creator_name}}" /></h3>{{/show_creator_field}}'
+ + '<textarea class="Ldt-CreateAnnotation-Description empty" placeholder="{{l10n.type_description}}"></textarea>'
+ '<div class="Ldt-CreateAnnotation-Avatar"><img src="{{creator_avatar}}" title="{{creator_name}}"></img></div>'
+ '<input type="submit" class="Ldt-CreateAnnotation-Submit" value="{{l10n.submit}}" />'
+ '{{#show_mic_record}}<div class="Ldt-CreateAnnotation-RecBlock"><div class="Ldt-CreateAnnotation-RecLabel">Add voice annotation</div>'
@@ -261,12 +261,15 @@
IriSP.Widgets.CreateAnnotation.prototype.show = function() {
this.visible = true;
this.showScreen('Main');
- this.$.find(".Ldt-CreateAnnotation-Description").val("").css("border-color", "#666666");
+ this.$.find(".Ldt-CreateAnnotation-Description").val("").css("border-color", "#666666").addClass("empty");
if (this.show_title_field) {
- this.$.find(".Ldt-CreateAnnotation-Title").val("").css("border-color", "#666666");
+ this.$.find(".Ldt-CreateAnnotation-Title").val("").css("border-color", "#666666").addClass("empty");
}
if (this.show_creator_field) {
this.$.find(".Ldt-CreateAnnotation-Creator").val(this.creator_name).css("border-color", "#666666");
+ if (!this.creator_name) {
+ this.$.find(".Ldt-CreateAnnotation-Creator").addClass("empty");
+ }
}
this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").removeClass("selected");
this.$.slideDown();
@@ -320,6 +323,11 @@
var _field = this.$.find(".Ldt-CreateAnnotation-Description"),
_contents = _field.val();
_field.css("border-color", !!_contents ? "#666666" : "#ff0000");
+ if (!!_contents) {
+ _field.removeClass("empty");
+ } else {
+ _field.addClass("empty");
+ }
this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").each(function() {
var _rx = IriSP.Model.regexpFromTextOrArray(IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,''));
if (_contents.match(_rx)) {
@@ -336,6 +344,11 @@
var _field = this.$.find(".Ldt-CreateAnnotation-Title"),
_contents = _field.val();
_field.css("border-color", !!_contents ? "#666666" : "#ff0000");
+ if (!!_contents) {
+ _field.removeClass("empty");
+ } else {
+ _field.addClass("empty");
+ }
this.pauseOnWrite();
return !!_contents;
}
@@ -345,6 +358,11 @@
var _field = this.$.find(".Ldt-CreateAnnotation-Creator"),
_contents = _field.val();
_field.css("border-color", !!_contents ? "#666666" : "#ff0000");
+ if (!!_contents) {
+ _field.removeClass("empty");
+ } else {
+ _field.addClass("empty");
+ }
this.pauseOnWrite();
return !!_contents;
}
@@ -392,7 +410,6 @@
_annotation.description = this.$.find(".Ldt-CreateAnnotation-Description").val(); /* Champ description */
_annotation.setTags(this.$.find(".Ldt-CreateAnnotation-TagLi.selected")
.map(function() { return IriSP.jQuery(this).attr("tag-id")})); /*Liste des ids de tags */
-
if (this.audio_url) {
_annotation.audio = {
src: "mic",
@@ -400,14 +417,11 @@
href: this.audio_url
};
}
-
- /* Les données créateur/date de création sont envoyées non pas dans l'annotation, mais dans le projet */
if (this.show_creator_field) {
- _export.creator = this.$.find(".Ldt-CreateAnnotation-Creator").val();
+ _annotation.creator = this.$.find(".Ldt-CreateAnnotation-Creator").val();
} else {
- _export.creator = this.creator_name;
+ _annotation.creator = this.creator_name;
}
- _export.created = new Date();
_exportedAnnotations.push(_annotation); /* Ajout de l'annotation à la liste à exporter */
_export.addList("annotation",_exportedAnnotations); /* Ajout de la liste à exporter à l'objet Source */
@@ -425,7 +439,7 @@
function() {
_this.close_after_send
? _this.hide()
- : _this.showScreen("Main");
+ : _this.show();
},
_this.after_send_timeout
);
--- a/src/widgets/PopcornPlayer.js Fri Oct 26 15:49:29 2012 +0200
+++ b/src/widgets/PopcornPlayer.js Mon Nov 05 19:03:10 2012 +0100
@@ -11,7 +11,6 @@
}
IriSP.Widgets.PopcornPlayer.prototype.draw = function() {
-
if (typeof this.video === "undefined") {
this.video = this.media.video;
--- a/src/widgets/Slice.js Fri Oct 26 15:49:29 2012 +0200
+++ b/src/widgets/Slice.js Mon Nov 05 19:03:10 2012 +0100
@@ -48,7 +48,7 @@
},
start: function() {
_this.sliding = true;
- if (!_this.media.getPaused) {
+ if (!_this.media.getPaused()) {
_this.media.pause();
}
_currentTime = _this.media.getCurrentTime();
--- a/test/jwplayer.htm Fri Oct 26 15:49:29 2012 +0200
+++ b/test/jwplayer.htm Mon Nov 05 19:03:10 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 15:49:29 2012 +0200
+++ b/test/mp4video.htm Mon Nov 05 19:03:10 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 15:49:29 2012 +0200
+++ b/test/oggvideo.htm Mon Nov 05 19:03:10 2012 +0100
@@ -29,7 +29,7 @@
},
css : 'metadataplayer/LdtPlayer-core.css',
widgets: [
- { type: "PopcornPlayer" },
+ { type: "AutoPlayer" },
{ type: "Slider" },
{ type: "Controller" },
{ type: "Polemic" },