|
2
|
1 |
IriSP.Widgets.MusitagAnnotator = function(player, config) { |
|
|
2 |
IriSP.Widgets.Widget.call(this, player, config); |
|
|
3 |
}; |
|
|
4 |
|
|
|
5 |
IriSP.Widgets.MusitagAnnotator.prototype = new IriSP.Widgets.Widget(); |
|
|
6 |
|
|
|
7 |
IriSP.Widgets.MusitagAnnotator.prototype.defaults = { |
|
|
8 |
min_left: -90, |
|
|
9 |
max_right: 900, |
|
|
10 |
width: 870 |
|
|
11 |
}; |
|
|
12 |
|
|
|
13 |
IriSP.Widgets.MusitagAnnotator.prototype.template = |
|
|
14 |
'<div class="Musitag-Annotator-PositionBar"></div><div class="Musitag-Annotator-Main">' |
|
|
15 |
+ '<div class="Musitag-Annotator-section"><h2>1</h2>' |
|
|
16 |
+ ' <h3>Choisis<br />une couleur</h3>' |
|
|
17 |
+ ' <div class="Musitag-Annotator-selector">' |
|
|
18 |
+ ' <div class="Musitag-container-80 Musitag-Annotator-tagInSelector">' |
|
|
19 |
+ ' <div class="Musitag-shadow"></div>' |
|
|
20 |
+ ' <div class="Musitag-color"></div>' |
|
|
21 |
+ ' <div class="Musitag-color Musitag-red"></div>' |
|
|
22 |
+ ' </div>' |
|
|
23 |
+ ' <div class="Musitag-container-80 Musitag-Annotator-tagInSelector">' |
|
|
24 |
+ ' <div class="Musitag-shadow"></div>' |
|
|
25 |
+ ' <div class="Musitag-color"></div>' |
|
|
26 |
+ ' <div class="Musitag-color Musitag-yellow"></div>' |
|
|
27 |
+ ' </div>' |
|
|
28 |
+ ' <div class="Musitag-container-80 Musitag-Annotator-tagInSelector">' |
|
|
29 |
+ ' <div class="Musitag-shadow"></div>' |
|
|
30 |
+ ' <div class="Musitag-color"></div>' |
|
|
31 |
+ ' <div class="Musitag-color Musitag-green"></div>' |
|
|
32 |
+ ' </div>' |
|
|
33 |
+ ' <div class="Musitag-container-80 Musitag-Annotator-tagInSelector">' |
|
|
34 |
+ ' <div class="Musitag-shadow"></div>' |
|
|
35 |
+ ' <div class="Musitag-color"></div>' |
|
|
36 |
+ ' <div class="Musitag-color Musitag-blue"></div>' |
|
|
37 |
+ ' </div>' |
|
|
38 |
+ ' </div>' |
|
|
39 |
+ '</div>' |
|
|
40 |
+ '<div class="Musitag-Annotator-separator"></div>' |
|
|
41 |
+ '<div class="Musitag-Annotator-section">' |
|
|
42 |
+ ' <h2>2</h2>' |
|
|
43 |
+ ' <h3>Choisis<br />une émotion</h3>' |
|
|
44 |
+ ' <div class="Musitag-Annotator-selector">' |
|
|
45 |
+ ' <div class="Musitag-container-80 Musitag-Annotator-tagInSelector">' |
|
|
46 |
+ ' <div class="Musitag-shadow"></div>' |
|
|
47 |
+ ' <div class="Musitag-color"></div>' |
|
|
48 |
+ ' <div class="Musitag-emoticon Musitag-happy"></div>' |
|
|
49 |
+ ' </div>' |
|
|
50 |
+ ' <div class="Musitag-container-80 Musitag-Annotator-tagInSelector">' |
|
|
51 |
+ ' <div class="Musitag-shadow"></div>' |
|
|
52 |
+ ' <div class="Musitag-color"></div>' |
|
|
53 |
+ ' <div class="Musitag-emoticon Musitag-unhappy"></div>' |
|
|
54 |
+ ' </div>' |
|
|
55 |
+ ' <div class="Musitag-container-80 Musitag-Annotator-tagInSelector">' |
|
|
56 |
+ ' <div class="Musitag-shadow"></div>' |
|
|
57 |
+ ' <div class="Musitag-color"></div>' |
|
|
58 |
+ ' <div class="Musitag-emoticon Musitag-laughing"></div>' |
|
|
59 |
+ ' </div>' |
|
|
60 |
+ ' <div class="Musitag-container-80 Musitag-Annotator-tagInSelector">' |
|
|
61 |
+ ' <div class="Musitag-shadow"></div>' |
|
|
62 |
+ ' <div class="Musitag-color"></div>' |
|
|
63 |
+ ' <div class="Musitag-emoticon Musitag-surprised"></div>' |
|
|
64 |
+ ' </div>' |
|
|
65 |
+ ' </div>' |
|
|
66 |
+ '</div>' |
|
|
67 |
+ '<div class="Musitag-Annotator-separator"></div>' |
|
|
68 |
+ '<div class="Musitag-Annotator-section">' |
|
|
69 |
+ ' <h2>3</h2>' |
|
|
70 |
+ ' <h3>Enregistre<br />ta voix</h3>' |
|
13
|
71 |
+ ' <div class="Musitag-Annotator-record">' |
|
|
72 |
|
|
15
|
73 |
+ ' <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="220" height="140" id="record_mic" align="middle">' |
|
13
|
74 |
+ ' <param name="movie" value="../../script/record_mic/record_mic.swf" />' |
|
|
75 |
+ ' <param name="quality" value="high" />' |
|
|
76 |
+ ' <param name="bgcolor" value="#ffffff" />' |
|
|
77 |
+ ' <param name="play" value="true" />' |
|
|
78 |
+ ' <param name="loop" value="true" />' |
|
|
79 |
+ ' <param name="wmode" value="transparent" />' |
|
|
80 |
+ ' <param name="scale" value="showall" />' |
|
|
81 |
+ ' <param name="menu" value="true" />' |
|
|
82 |
+ ' <param name="devicefont" value="false" />' |
|
|
83 |
+ ' <param name="salign" value="" />' |
|
|
84 |
+ ' <param name="allowScriptAccess" value="always" />' |
|
|
85 |
+ ' <param name="allowFullScreen" value="true" />' |
|
|
86 |
+ ' <param name="flashvars" value="playVisible=true">' |
|
|
87 |
+ ' <embed src="../../script/record_mic/record_mic.swf" quality="high" bgcolor="#ffffff"' |
|
|
88 |
+ ' width="220" height="140" name="ExternalInterfaceExample" align="middle"' |
|
|
89 |
+ ' play="true" loop="false" quality="high" allowScriptAccess="always" ' |
|
|
90 |
+ ' type="application/x-shockwave-flash" allowFullScreen="true" wmode="transparent" ' |
|
|
91 |
+ ' flashvars="playVisible=true"' |
|
|
92 |
+ ' pluginspage="http://www.macromedia.com/go/getflashplayer">' |
|
|
93 |
+ ' </embed>' |
|
|
94 |
+ ' </object>' |
|
|
95 |
|
|
|
96 |
|
|
|
97 |
+'</div>' |
|
2
|
98 |
+ '</div>' |
|
|
99 |
+ '<div class="Musitag-Annotator-separator"></div>' |
|
|
100 |
+ '<div class="Musitag-Annotator-section">' |
|
|
101 |
+ ' <h2>4</h2>' |
|
|
102 |
+ ' <h3>Envoie<br />ton Musitag</h3>' |
|
|
103 |
+ ' <div class="Musitag-Annotator-Note">' |
|
|
104 |
+ ' <div class="Musitag-container-80 Musitag-Annotator-tagInSend">' |
|
|
105 |
+ ' <div class="Musitag-shadow"></div>' |
|
|
106 |
+ ' <div class="Musitag-color"></div>' |
|
10
|
107 |
+ ' <div class="Musitag-emoticon"></div>' |
|
2
|
108 |
+ ' </div>' |
|
|
109 |
+ ' </div>' |
|
|
110 |
+ '</div>' |
|
|
111 |
+ '<div class="Musitag-Annotator-close"></div>' |
|
|
112 |
+ '</div></div>'; |
|
|
113 |
|
|
|
114 |
IriSP.Widgets.MusitagAnnotator.prototype.draw = function() { |
|
|
115 |
this.renderTemplate(); |
|
|
116 |
this.position_bar = this.$.find(".Musitag-Annotator-PositionBar"); |
|
|
117 |
this.position_bar.hide(); |
|
|
118 |
this.position_width = this.position_bar.outerWidth(); |
|
|
119 |
this.main_div = this.$.find(".Musitag-Annotator-Main"); |
|
|
120 |
this.$.hide(); |
|
|
121 |
this.main_width = this.main_div.outerWidth(); |
|
|
122 |
this.bindPopcorn("timeupdate","onTimeupdate"); |
|
|
123 |
this.bindPopcorn("IriSP.MusitagAnnotator.hide","hide"); |
|
|
124 |
this.bindPopcorn("IriSP.MusitagAnnotator.show","show"); |
|
15
|
125 |
this.recorder = this.$.find("embed")[0]; |
|
|
126 |
|
|
|
127 |
var _this = this; |
|
|
128 |
|
|
2
|
129 |
this.$.find('.Musitag-Annotator-tagInSelector').click(function() { |
|
|
130 |
var _class = IriSP.jQuery(this).children(':last-child').attr('class'), |
|
15
|
131 |
_classes = _class.split(' '), |
|
|
132 |
_type = _classes[0].replace(/^\w+-/,""), |
|
|
133 |
_value = _classes[1].replace(/^\w+-/,""); |
|
|
134 |
_this.annotation[_type] = _value; |
|
|
135 |
_this.checkAnnotation(); |
|
2
|
136 |
IriSP.jQuery('.Musitag-Annotator-tagInSend .' + _classes[0]).attr('class',_class); |
|
|
137 |
IriSP.jQuery(this).siblings().removeClass('down') |
|
|
138 |
.children(':last-child').css('opacity',.35); |
|
|
139 |
IriSP.jQuery(this).addClass('down') |
|
|
140 |
.children(':last-child').css('opacity',1); |
|
|
141 |
}); |
|
15
|
142 |
|
|
2
|
143 |
this.$.find('.Musitag-Annotator-close').click(function() { |
|
15
|
144 |
_this.recorder.stopRecord(); |
|
2
|
145 |
_this.hide(); |
|
|
146 |
_this.player.popcorn.trigger("IriSP.MusitagAndYou.show"); |
|
15
|
147 |
}); |
|
|
148 |
|
|
|
149 |
this.$.find('.Musitag-Annotator-Note').click(function() { |
|
|
150 |
_this.recorder.stopRecord(); |
|
|
151 |
}); |
|
|
152 |
|
|
|
153 |
window.setAudioUrl = function(_url) { |
|
|
154 |
_this.annotation.audio_url = _url; |
|
|
155 |
console.log(_url); |
|
|
156 |
} |
|
2
|
157 |
} |
|
|
158 |
|
|
|
159 |
IriSP.Widgets.MusitagAnnotator.prototype.onTimeupdate = function() { |
|
|
160 |
var _x = Math.floor(this.width * this.player.popcorn.currentTime() / this.source.getDuration().getSeconds()); |
|
|
161 |
this.position_bar.css("margin-left", (_x - this.position_width / 2)+"px"); |
|
|
162 |
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"); |
|
|
163 |
} |
|
|
164 |
|
|
15
|
165 |
IriSP.Widgets.MusitagAnnotator.prototype.checkAnnotation = function() { |
|
|
166 |
var _res = this.annotation.emoticon && this.annotation.color; |
|
|
167 |
this.$.find('.Musitag-Annotator-Note').css("opacity", _res ? 1 : .5); |
|
|
168 |
return _res; |
|
|
169 |
} |
|
|
170 |
|
|
2
|
171 |
IriSP.Widgets.MusitagAnnotator.prototype.show = function() { |
|
|
172 |
this.$.show(); |
|
10
|
173 |
this.$.find('.Musitag-Annotator-tagInSelector').removeClass("down"); |
|
|
174 |
this.$.find(".Musitag-Annotator-tagInSend .Musitag-color").attr("class","Musitag-color"); |
|
|
175 |
this.$.find(".Musitag-Annotator-tagInSend .Musitag-emoticon").attr("class","Musitag-emoticon hidden"); |
|
15
|
176 |
this.annotation = { |
|
|
177 |
audio_url: false, |
|
|
178 |
emoticon: false, |
|
|
179 |
color: false |
|
|
180 |
}; |
|
|
181 |
this.checkAnnotation(); |
|
2
|
182 |
this.position_bar.slideDown(200); |
|
|
183 |
} |
|
|
184 |
|
|
|
185 |
IriSP.Widgets.MusitagAnnotator.prototype.hide = function() { |
|
|
186 |
var _this = this; |
|
|
187 |
this.position_bar.slideUp(200, function() { |
|
|
188 |
_this.$.hide(); |
|
|
189 |
}); |
|
|
190 |
} |