crea/integration/metadataplayer/MusitagAnnotator.js
changeset 15 f1d070549d94
parent 13 692a26b5274b
child 38 f19428838d3b
--- a/crea/integration/metadataplayer/MusitagAnnotator.js	Wed Jun 06 18:35:36 2012 +0200
+++ b/crea/integration/metadataplayer/MusitagAnnotator.js	Wed Jun 06 19:36:25 2012 +0200
@@ -70,7 +70,7 @@
     + '    <h3>Enregistre<br />ta voix</h3>'
     + '    <div class="Musitag-Annotator-record">'
     
-    + '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="220" height="140" id="record_mic" align="middle">'
+    + '    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="220" height="140" id="record_mic" align="middle">'
     + '        <param name="movie" value="../../script/record_mic/record_mic.swf" />'
     + '        <param name="quality" value="high" />'
     + '        <param name="bgcolor" value="#ffffff" />'
@@ -122,20 +122,38 @@
     this.bindPopcorn("timeupdate","onTimeupdate");
     this.bindPopcorn("IriSP.MusitagAnnotator.hide","hide");
     this.bindPopcorn("IriSP.MusitagAnnotator.show","show");
+    this.recorder = this.$.find("embed")[0];
+    
+    var _this = this;
+    
     this.$.find('.Musitag-Annotator-tagInSelector').click(function() {
         var _class = IriSP.jQuery(this).children(':last-child').attr('class'),
-            _classes = _class.split(' ');
+            _classes = _class.split(' '),
+            _type = _classes[0].replace(/^\w+-/,""),
+            _value = _classes[1].replace(/^\w+-/,"");
+        _this.annotation[_type] = _value;
+        _this.checkAnnotation();
         IriSP.jQuery('.Musitag-Annotator-tagInSend .' + _classes[0]).attr('class',_class);
         IriSP.jQuery(this).siblings().removeClass('down')
             .children(':last-child').css('opacity',.35);
         IriSP.jQuery(this).addClass('down')
             .children(':last-child').css('opacity',1);
     });
-    var _this = this;
+    
     this.$.find('.Musitag-Annotator-close').click(function() {
+        _this.recorder.stopRecord();
         _this.hide();
         _this.player.popcorn.trigger("IriSP.MusitagAndYou.show");
-    })
+    });
+    
+    this.$.find('.Musitag-Annotator-Note').click(function() {
+       _this.recorder.stopRecord();
+    });
+    
+    window.setAudioUrl = function(_url) {
+        _this.annotation.audio_url = _url;
+        console.log(_url);
+    }
 }
 
 IriSP.Widgets.MusitagAnnotator.prototype.onTimeupdate = function() {
@@ -144,11 +162,23 @@
     this.main_div.css("margin-left",Math.max(this.min_left, Math.min(this.max_right - this.main_width, _x - this.main_width / 2))+"px");
 }
 
+IriSP.Widgets.MusitagAnnotator.prototype.checkAnnotation = function() {
+    var _res = this.annotation.emoticon && this.annotation.color;
+    this.$.find('.Musitag-Annotator-Note').css("opacity", _res ? 1 : .5);
+    return _res;
+}
+
 IriSP.Widgets.MusitagAnnotator.prototype.show = function() {
     this.$.show();
     this.$.find('.Musitag-Annotator-tagInSelector').removeClass("down");
     this.$.find(".Musitag-Annotator-tagInSend .Musitag-color").attr("class","Musitag-color");
     this.$.find(".Musitag-Annotator-tagInSend .Musitag-emoticon").attr("class","Musitag-emoticon hidden");
+    this.annotation = {
+        audio_url: false,
+        emoticon: false,
+        color: false
+    };
+    this.checkAnnotation();
     this.position_bar.slideDown(200);
 }