Commit d4b90e479232c45a7afe545391903585d179d1f4

Authored by ykxie
1 parent dbba4520

fix 屏幕缩放进度条问题

src/js/audioPlayer/jQuery.AudioPlayer.js
1 /** 1 /**
2 - * jQuery音频播放  
3 - * @Author syantao  
4 - * v1.0.1 2 + * jQuery.AudioPlayer.js
  3 + * @Author Keystion
  4 + * @Version 1.0.1
5 * Created by Keystion on 2016-12-19 5 * Created by Keystion on 2016-12-19
6 - * @param {[type]} jQuery [description] 6 + * Update on 2017-01-06
7 */ 7 */
8 ;(function(jQuery){ 8 ;(function(jQuery){
9 "use strict"; 9 "use strict";
10 var AudioPlayer = { 10 var AudioPlayer = {
11 options: { 11 options: {
12 - debuggers: false, // 是否开启播放记录  
13 - container: 'body', // 把组件塞到什么地方  
14 - source: '', // 音频源文件  
15 - imagePath: './image', // 音频源文件  
16 - seekNum: 0, // 拖拽是判断之前是否播放  
17 - allowSeek: true, // 是否可以拖拽  
18 - canplayCallback: null, // 可以播放之后,做某些事情  
19 - playCallback: null, // 播放之后,做某些事情  
20 - pauseCallback: null, // 暂停之后,做某些事情  
21 - timeupdateCallback: null, // 拖动之后,做某些事情  
22 - endedCallback: null, // 播放结束之后,做某些事情  
23 - mutedCallback: null, // 静音之后,做某些事情  
24 - template: $('<div id="componentWrapper">' + 12 + // open console log / 打开控制台日志
  13 + debuggers: false
  14 + // container, default 'body' / 组件要放到什么地方,默认'body'
  15 + ,container: 'body'
  16 + // audio source / 音频源
  17 + ,source: ''
  18 + // 音频源文件 / image resources
  19 + ,imagePath: './image'
  20 + // Determines whether or not the player is playing before dragging/判断拖拽之前是否正在播放
  21 + ,seekNum: 0
  22 + // Whether can drag and drop / 是否可以拖拽
  23 + ,allowSeek: true
  24 + // After can play TODO / 可以播放之后,做某些事情
  25 + ,canplayCallback: null
  26 + // After playback TODO / 播放之后,做某些事情
  27 + ,playCallback: null
  28 + // After the suspension TODO / 暂停之后,做某些事情
  29 + ,pauseCallback: null
  30 + // After the drag TODO / 拖动之后,做某些事情
  31 + ,timeupdateCallback: null
  32 + // End of the play TODO / 播放结束之后,做某些事情
  33 + ,endedCallback: null
  34 + // After the mute TODO / 静音之后,做某些事情
  35 + ,mutedCallback: null
  36 + // template dom / 模板节点
  37 + ,template: $('<div id="componentWrapper">' +
25 '<audio id="audio-element" style="display: none;">您的浏览器不支持 audio 标签。</audio>' + 38 '<audio id="audio-element" style="display: none;">您的浏览器不支持 audio 标签。</audio>' +
26 '<div class="controls_toggle"><img src="" alt="controls_toggle" /></div>' + 39 '<div class="controls_toggle"><img src="" alt="controls_toggle" /></div>' +
27 '<div class="player_mediaTime_current">00:00</div>' + 40 '<div class="player_mediaTime_current">00:00</div>' +
@@ -45,9 +58,11 @@ @@ -45,9 +58,11 @@
45 '</div>' + 58 '</div>' +
46 '</div>' + 59 '</div>' +
47 '</div>') 60 '</div>')
48 - },  
49 - elements: {},  
50 - init: function(options) { 61 + }
  62 + // elements
  63 + ,elements: {}
  64 + // initialize
  65 + ,init: function(options) {
51 var _this = this; 66 var _this = this;
52 if (!options || !options.container) { 67 if (!options || !options.container) {
53 return false; 68 return false;
@@ -56,29 +71,30 @@ @@ -56,29 +71,30 @@
56 71
57 // audio DOM 72 // audio DOM
58 _this.elements.audioDom = _this.options.template.find('audio')[0]; 73 _this.elements.audioDom = _this.options.template.find('audio')[0];
59 - // 播放按钮 74 + _this.elements.componentWrapper = _this.options.template.find('#componentWrapper');
  75 + // Play button / 播放按钮
60 _this.elements.playButton = _this.options.template.find('.controls_toggle'); 76 _this.elements.playButton = _this.options.template.find('.controls_toggle');
61 - // 当前时间 77 + // The current time / 当前时间
62 _this.elements.currentTime = _this.options.template.find('.player_mediaTime_current'); 78 _this.elements.currentTime = _this.options.template.find('.player_mediaTime_current');
63 - // 总时长 79 + // The total length / 总时长
64 _this.elements.totalTime = _this.options.template.find('.player_mediaTime_total'); 80 _this.elements.totalTime = _this.options.template.find('.player_mediaTime_total');
65 - // 加载进度条 81 + // Loading progress bar / 加载进度条
66 _this.elements.loadProgress = _this.options.template.find('.load_progress'); 82 _this.elements.loadProgress = _this.options.template.find('.load_progress');
67 - // 播放进度条 83 + // Playback progress bar / 播放进度条
68 _this.elements.playProgress = _this.options.template.find('.play_progress'); 84 _this.elements.playProgress = _this.options.template.find('.play_progress');
69 - // 播放进度条wrap 85 + // Playback progress bar wrap / 播放进度条wrap
70 _this.elements.playProgressWrap = _this.options.template.find('.player_progress'); 86 _this.elements.playProgressWrap = _this.options.template.find('.player_progress');
71 - // 播放进度条总长 87 + // The total length of playback progress bar / 播放进度条总长
72 _this.elements.totalPlayProgress = _this.options.template.find('.progress_bg'); 88 _this.elements.totalPlayProgress = _this.options.template.find('.progress_bg');
73 - // 静音按钮 89 + // Mute button / 静音按钮
74 _this.elements.mutedButton = _this.options.template.find('.player_volume'); 90 _this.elements.mutedButton = _this.options.template.find('.player_volume');
75 - // 音量大小wrap 91 + // The volume size wrap / 音量大小wrap
76 _this.elements.volumeWrap = _this.options.template.find('.volume_seekbar'); 92 _this.elements.volumeWrap = _this.options.template.find('.volume_seekbar');
77 - // 音量总长 93 + // The volume chief / 音量总长
78 _this.elements.totalVolume = _this.options.template.find('.volume_bg'); 94 _this.elements.totalVolume = _this.options.template.find('.volume_bg');
79 - // 当前音量 95 + // The current volume / 当前音量
80 _this.elements.currentVolume = _this.options.template.find('.volume_level'); 96 _this.elements.currentVolume = _this.options.template.find('.volume_level');
81 - // 音量提示条 97 + // The tooltips of the volume / 音量提示条
82 _this.elements.tipsVolume = _this.options.template.find('.player_volume_tooltip'); 98 _this.elements.tipsVolume = _this.options.template.find('.player_volume_tooltip');
83 $(_this.options.container).append(_this.options.template); 99 $(_this.options.container).append(_this.options.template);
84 100
@@ -86,32 +102,42 @@ @@ -86,32 +102,42 @@
86 _this.elements.mutedButton.find('img').attr('src', _this.options.imagePath + '/volume.png'); 102 _this.elements.mutedButton.find('img').attr('src', _this.options.imagePath + '/volume.png');
87 103
88 if(options.source){ 104 if(options.source){
89 - _this.updateSource({source: options.source, callback: function(){ _this.log('update source') }}); 105 + _this.updateSource({source: options.source, callback: function(){ _this.log('The audio source has been updated') }});
90 } 106 }
91 107
92 _this.elements.currentVolume.width((60 / 100 * _this.elements.audioDom.volume * 100) + 'px'); 108 _this.elements.currentVolume.width((60 / 100 * _this.elements.audioDom.volume * 100) + 'px');
93 109
94 - // 初始化话事件 110 + // Initialize the event / 初始化事件
95 _this.events(); 111 _this.events();
96 - },  
97 - // 更新音频源  
98 - updateSource: function(o){ 112 + }
  113 + // Update the audio source foo. / 更新音频源
  114 + ,updateSource: function(o){
99 var _this = this; 115 var _this = this;
100 - // 重置 116 + // reset
101 _this.reset(); 117 _this.reset();
102 118
103 - // 更新音频来 119 + // Update the audio source / 更新音频
104 _this.elements.audioDom.setAttribute('src', o.source); 120 _this.elements.audioDom.setAttribute('src', o.source);
105 121
  122 + // callback
106 if(typeof o.callback == 'function'){ 123 if(typeof o.callback == 'function'){
107 o.callback(); 124 o.callback();
108 } 125 }
109 - },  
110 - // dom 绑定事件  
111 - events: function() { 126 + }
  127 + // dom events
  128 + ,events: function() {
112 var _this = this; 129 var _this = this;
113 130
114 - // 调节声音大小 131 + // Monitor window changes to do some of the UI update / 监听窗口的变化做一些UI的更新
  132 + $(window).resize(function(event) {
  133 +
  134 + // Update the width of the download progress bar / 更新下载进度条的宽度
  135 + _this.setLoadProgressWidth();
  136 + // Update the playback progress bar width / 更新播放进度条的宽度
  137 + _this.elements.playProgress.width((_this.elements.audioDom.currentTime / _this.elements.audioDom.duration) * $('.progress_bg').width());
  138 + });
  139 +
  140 + // Adjust the size of sound / 调节声音大小
115 _this.elements.volumeWrap.on("mouseenter", function(event) { 141 _this.elements.volumeWrap.on("mouseenter", function(event) {
116 event.preventDefault(); 142 event.preventDefault();
117 }).on("mouseleave", function(event) { 143 }).on("mouseleave", function(event) {
@@ -143,7 +169,8 @@ @@ -143,7 +169,8 @@
143 _this.muted(); 169 _this.muted();
144 }); 170 });
145 171
146 - // 播放进度条 172 + // Playback progress bar drag and drop events / 播放进度条拖拽事件
  173 + // To determine whether to allow drag and drop / 判断是否允许拖拽
147 if(_this.options.allowSeek){ 174 if(_this.options.allowSeek){
148 _this.elements.playProgressWrap.on('mousedown', function(event) { 175 _this.elements.playProgressWrap.on('mousedown', function(event) {
149 event.preventDefault(); 176 event.preventDefault();
@@ -153,15 +180,17 @@ @@ -153,15 +180,17 @@
153 _this.options.seekNum = 2; 180 _this.options.seekNum = 2;
154 _this.pause(); 181 _this.pause();
155 } 182 }
156 - // 鼠标按下就更新进度条 183 + // The mouse click will update the progress bar / 鼠标按下就更新进度条
157 _this.setPlayProgressWidth(event); 184 _this.setPlayProgressWidth(event);
158 }).on('mousemove', function(event) { 185 }).on('mousemove', function(event) {
159 event.preventDefault(); 186 event.preventDefault();
160 - // 判断是否已经开始移动 才会设置进度条 187 + // Determine whether have begun to move will set the progress bar / 判断是否已经开始移动 才会设置进度条
161 _this.options.seekNum != 0 && _this.setPlayProgressWidth(event); 188 _this.options.seekNum != 0 && _this.setPlayProgressWidth(event);
162 }).on('mouseup', function(event) { 189 }).on('mouseup', function(event) {
163 event.preventDefault(); 190 event.preventDefault();
164 - // TODO 是否有必要在鼠标按键抬起的时候再次去更新播放进度条宽度 191 + // TODO
  192 + // Is it necessary to when the mouse button to lift again to update the playback progress bar width
  193 + // 是否有必要在鼠标按键抬起的时候再次去更新播放进度条宽度
165 // _this.setPlayProgressWidth(event); 194 // _this.setPlayProgressWidth(event);
166 if (_this.options.seekNum == 1) { 195 if (_this.options.seekNum == 1) {
167 _this.pause(); 196 _this.pause();
@@ -185,7 +214,7 @@ @@ -185,7 +214,7 @@
185 }) 214 })
186 } 215 }
187 216
188 - // 播放暂停 217 + // Click event broadcast suspended / 播放暂停点击事件
189 _this.elements.playButton.on('click', function(event) { 218 _this.elements.playButton.on('click', function(event) {
190 event.preventDefault(); 219 event.preventDefault();
191 _this.toggleplay({ 220 _this.toggleplay({
@@ -194,17 +223,17 @@ @@ -194,17 +223,17 @@
194 }); 223 });
195 }) 224 })
196 225
197 - // 当音频的加载已放弃时 226 + // When audio load has abandoned / 当音频的加载已放弃时
198 _this.elements.audioDom.onabort = function() { 227 _this.elements.audioDom.onabort = function() {
199 _this.log('onabort'); 228 _this.log('onabort');
200 229
201 _this.reset(); 230 _this.reset();
202 } 231 }
203 232
204 - // 当浏览器可以播放音频时 233 + // When the browser can play audio / 当浏览器可以播放音频时
205 _this.elements.audioDom.oncanplay = function() { 234 _this.elements.audioDom.oncanplay = function() {
206 _this.log('oncanplay'); 235 _this.log('oncanplay');
207 - // 判断音频加载完毕 236 + // Determine the audio to load / 判断音频加载完毕
208 if (_this.elements.audioDom.readyState == 4) { 237 if (_this.elements.audioDom.readyState == 4) {
209 var duration = Math.round(_this.elements.audioDom.duration); 238 var duration = Math.round(_this.elements.audioDom.duration);
210 var minutes = Math.floor(duration / 60); 239 var minutes = Math.floor(duration / 60);
@@ -219,31 +248,31 @@ @@ -219,31 +248,31 @@
219 } 248 }
220 } 249 }
221 250
222 - // 当浏览器正在下载音频时 251 + // When the browser is downloading audio / 当浏览器正在下载音频时
223 _this.elements.audioDom.onprogress = function() { 252 _this.elements.audioDom.onprogress = function() {
224 if (_this.elements.audioDom.readyState == 4) { 253 if (_this.elements.audioDom.readyState == 4) {
225 _this.elements.loadProgress.width((_this.elements.audioDom.buffered.end(0) / _this.elements.audioDom.seekable.end(0)) * _this.elements.totalPlayProgress.width()); 254 _this.elements.loadProgress.width((_this.elements.audioDom.buffered.end(0) / _this.elements.audioDom.seekable.end(0)) * _this.elements.totalPlayProgress.width());
226 } 255 }
227 }; 256 };
228 257
229 - // 当浏览器开始查找音频时 258 + // When the browser begins searching for the audio / 当浏览器开始查找音频时
230 _this.elements.audioDom.onloadstart = function() { 259 _this.elements.audioDom.onloadstart = function() {
231 _this.log('onloadstart'); 260 _this.log('onloadstart');
232 } 261 }
233 262
234 - // 当音频已开始或不再暂停时 263 + // When the audio has begun or is no longer suspended / 当音频已开始或不再暂停时
235 _this.elements.audioDom.onplay = function() { 264 _this.elements.audioDom.onplay = function() {
236 _this.log('onplay'); 265 _this.log('onplay');
237 _this.elements.playButton.find('img').attr('src', _this.options.imagePath + '/pause.png'); 266 _this.elements.playButton.find('img').attr('src', _this.options.imagePath + '/pause.png');
238 } 267 }
239 268
240 - // 当音频已暂停时 269 + // When the audio has been suspended / 当音频已暂停时
241 _this.elements.audioDom.onpause = function() { 270 _this.elements.audioDom.onpause = function() {
242 _this.log('onpause'); 271 _this.log('onpause');
243 _this.elements.playButton.find('img').attr('src', _this.options.imagePath + '/play.png'); 272 _this.elements.playButton.find('img').attr('src', _this.options.imagePath + '/play.png');
244 } 273 }
245 274
246 - // 当目前的播放列表已结束时 275 + // When the current playlist has ended / 当目前的播放列表已结束时
247 _this.elements.audioDom.onended = function() { 276 _this.elements.audioDom.onended = function() {
248 _this.log('onended'); 277 _this.log('onended');
249 278
@@ -252,39 +281,43 @@ @@ -252,39 +281,43 @@
252 } 281 }
253 } 282 }
254 283
  284 + // When the user starts moving/jump to the new location in the audio
255 // 当用户开始移动/跳跃到音频中的新位置时 285 // 当用户开始移动/跳跃到音频中的新位置时
256 _this.elements.audioDom.onseeking = function() { 286 _this.elements.audioDom.onseeking = function() {
257 _this.log('onseeking'); 287 _this.log('onseeking');
258 } 288 }
259 289
  290 + // When the user has mobile/jump to the new location in the audio
260 // 当用户已移动/跳跃到音频中的新位置时 291 // 当用户已移动/跳跃到音频中的新位置时
261 _this.elements.audioDom.onseeked = function() { 292 _this.elements.audioDom.onseeked = function() {
262 _this.log('onseeked'); 293 _this.log('onseeked');
263 } 294 }
264 295
  296 + // When the current playback position has changed
265 // 当目前的播放位置已更改时 297 // 当目前的播放位置已更改时
266 _this.elements.audioDom.ontimeupdate = function() { 298 _this.elements.audioDom.ontimeupdate = function() {
267 _this.log('ontimeupdate'); 299 _this.log('ontimeupdate');
268 _this.timeupdate(); 300 _this.timeupdate();
269 } 301 }
270 302
  303 + // When the volume is changed
271 // 当音量已更改时 304 // 当音量已更改时
272 _this.elements.audioDom.onvolumechange = function() { 305 _this.elements.audioDom.onvolumechange = function() {
273 _this.log('onvolumechange'); 306 _this.log('onvolumechange');
274 _this.setvolume(); 307 _this.setvolume();
275 } 308 }
276 - },  
277 - // 切换播放/暂停  
278 - toggleplay: function(o) { 309 + }
  310 + // Toggle play/pause 切换播放/暂停
  311 + ,toggleplay: function(o) {
279 var _this = this; 312 var _this = this;
280 if (_this.elements.audioDom.paused) { 313 if (_this.elements.audioDom.paused) {
281 _this.play(o.playCallback); 314 _this.play(o.playCallback);
282 } else { 315 } else {
283 _this.pause(o.pauseCallback); 316 _this.pause(o.pauseCallback);
284 } 317 }
285 - },  
286 - // 设置播放  
287 - play: function(o) { 318 + }
  319 + // Set the playback / 设置播放
  320 + ,play: function(o) {
288 var _this = this; 321 var _this = this;
289 _this.elements.audioDom.play(); 322 _this.elements.audioDom.play();
290 if (typeof o == 'function') { 323 if (typeof o == 'function') {
@@ -294,9 +327,9 @@ @@ -294,9 +327,9 @@
294 if(typeof _this.options.playCallback == 'function'){ 327 if(typeof _this.options.playCallback == 'function'){
295 _this.options.playCallback({'status': _this.elements.audioDom.play}); 328 _this.options.playCallback({'status': _this.elements.audioDom.play});
296 } 329 }
297 - },  
298 - // 设置暂停  
299 - pause: function(o) { 330 + }
  331 + // Set the suspend / 设置暂停
  332 + ,pause: function(o) {
300 var _this = this; 333 var _this = this;
301 _this.elements.audioDom.pause(); 334 _this.elements.audioDom.pause();
302 if (typeof o == 'function') { 335 if (typeof o == 'function') {
@@ -306,9 +339,9 @@ @@ -306,9 +339,9 @@
306 if(typeof _this.options.pauseCallback == 'function'){ 339 if(typeof _this.options.pauseCallback == 'function'){
307 _this.options.pauseCallback({'status': _this.elements.audioDom.play}); 340 _this.options.pauseCallback({'status': _this.elements.audioDom.play});
308 } 341 }
309 - },  
310 - // 设置静音否  
311 - muted: function(o) { 342 + }
  343 + // muted / 设置静音否
  344 + ,muted: function(o) {
312 var _this = this; 345 var _this = this;
313 if (_this.elements.audioDom.muted) { 346 if (_this.elements.audioDom.muted) {
314 _this.elements.audioDom.muted = false; 347 _this.elements.audioDom.muted = false;
@@ -321,9 +354,9 @@ @@ -321,9 +354,9 @@
321 if(typeof _this.options.mutedCallback == 'function'){ 354 if(typeof _this.options.mutedCallback == 'function'){
322 _this.options.mutedCallback({'status': _this.elements.audioDom.muted}); 355 _this.options.mutedCallback({'status': _this.elements.audioDom.muted});
323 } 356 }
324 - },  
325 - // 设置声音大小  
326 - setvolume: function(options) { 357 + }
  358 + // Set the sound size / 设置声音大小
  359 + ,setvolume: function(options) {
327 var _this = this; 360 var _this = this;
328 if (!options) { 361 if (!options) {
329 _this.elements.currentVolume.width((_this.elements.totalVolume.width() / 100 * _this.elements.audioDom.volume * 100) + 'px'); 362 _this.elements.currentVolume.width((_this.elements.totalVolume.width() / 100 * _this.elements.audioDom.volume * 100) + 'px');
@@ -331,14 +364,15 @@ @@ -331,14 +364,15 @@
331 if (options.event) { 364 if (options.event) {
332 return _this.elements.audioDom.volume = _this.sumVolume(options.event) / 100; 365 return _this.elements.audioDom.volume = _this.sumVolume(options.event) / 100;
333 } else { 366 } else {
334 - // _this.log 需要优化 367 + // TODO _this.log
  368 + // Need to optimize / 需要优化
335 _this.options.debuggers && console.error('缺少参数:options.event'); 369 _this.options.debuggers && console.error('缺少参数:options.event');
336 return false; 370 return false;
337 } 371 }
338 } 372 }
339 - },  
340 - // 设置播放进度条  
341 - setPlayProgressWidth: function(argument) { 373 + }
  374 + // Set the playback progress bar / 设置播放进度条
  375 + ,setPlayProgressWidth: function(argument) {
342 var _this = this; 376 var _this = this;
343 if (!argument) { 377 if (!argument) {
344 return false; 378 return false;
@@ -350,9 +384,20 @@ @@ -350,9 +384,20 @@
350 _this.elements.playProgress.width(argument.clientX - _this.elements.playProgressWrap.offset().left); 384 _this.elements.playProgress.width(argument.clientX - _this.elements.playProgressWrap.offset().left);
351 _this.elements.audioDom.currentTime = (argument.clientX - _this.elements.playProgressWrap.offset().left) / _this.elements.totalPlayProgress.width() * _this.elements.audioDom.duration; 385 _this.elements.audioDom.currentTime = (argument.clientX - _this.elements.playProgressWrap.offset().left) / _this.elements.totalPlayProgress.width() * _this.elements.audioDom.duration;
352 // } 386 // }
353 - },  
354 - // 播放时间更改  
355 - timeupdate: function() { 387 + }
  388 + // Set the width of the download progress bar / 设置下载进度条的宽度
  389 + ,setLoadProgressWidth: function(){
  390 + var _this = this;
  391 +
  392 + // The audio of the ready state / 音频的就绪状态
  393 + // More docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/readyState
  394 + // TODO Add other state
  395 + if (_this.elements.audioDom.readyState == 4) {
  396 + _this.elements.loadProgress.width((_this.elements.audioDom.buffered.end(0) / _this.elements.audioDom.seekable.end(0)) * _this.elements.totalPlayProgress.width());
  397 + }
  398 + }
  399 + // Playing time change foo. / 播放时间更改
  400 + ,timeupdate: function() {
356 var _this = this; 401 var _this = this;
357 402
358 var currTime = Math.floor(_this.elements.audioDom.currentTime).toString(); 403 var currTime = Math.floor(_this.elements.audioDom.currentTime).toString();
@@ -366,9 +411,9 @@ @@ -366,9 +411,9 @@
366 _this.elements.totalTime.html(_this.formatTime(duration)); 411 _this.elements.totalTime.html(_this.formatTime(duration));
367 } 412 }
368 _this.elements.playProgress.width((_this.elements.audioDom.currentTime / _this.elements.audioDom.duration) * $('.progress_bg').width()); 413 _this.elements.playProgress.width((_this.elements.audioDom.currentTime / _this.elements.audioDom.duration) * $('.progress_bg').width());
369 - },  
370 - // 格式化时间戳相关  
371 - formatTime: function(secs, format) { 414 + }
  415 + // Formatting a timestamp / 格式化时间戳相关
  416 + ,formatTime: function(secs, format) {
372 var hr = Math.floor(secs / 3600); 417 var hr = Math.floor(secs / 3600);
373 var min = Math.floor((secs - (hr * 3600)) / 60); 418 var min = Math.floor((secs - (hr * 3600)) / 60);
374 var sec = Math.floor(secs - (hr * 3600) - (min * 60)); 419 var sec = Math.floor(secs - (hr * 3600) - (min * 60));
@@ -381,9 +426,9 @@ @@ -381,9 +426,9 @@
381 } 426 }
382 427
383 return min + ':' + sec; 428 return min + ':' + sec;
384 - },  
385 - // 计算音量  
386 - sumVolume: function(event) { 429 + }
  430 + // To calculate the volume / 计算音量
  431 + ,sumVolume: function(event) {
387 var _this = this; 432 var _this = this;
388 if (!event) { 433 if (!event) {
389 return false; 434 return false;
@@ -392,20 +437,26 @@ @@ -392,20 +437,26 @@
392 num = Math.max(0, Math.min(1, num / _this.elements.totalVolume.width())); 437 num = Math.max(0, Math.min(1, num / _this.elements.totalVolume.width()));
393 num = parseInt(100 * num, 10); 438 num = parseInt(100 * num, 10);
394 return num; 439 return num;
395 - },  
396 - // 重置函数  
397 - reset: function(){ 440 + }
  441 + // reset / 重置函数
  442 + ,reset: function(){
398 var _this = this; 443 var _this = this;
399 444
400 - // 播放按钮 当前播放时间 总时间 音量 播放进度条 下载进度条 445 + // The play button to return to the initial state / 播放按钮回到初始状态
401 _this.elements.playButton.find('img').attr('src', _this.options.imagePath + '/play.png'); 446 _this.elements.playButton.find('img').attr('src', _this.options.imagePath + '/play.png');
  447 + // The current playback time back to the initial state / 当前播放时间回到初始状态
402 _this.elements.currentTime.html('00:00'); 448 _this.elements.currentTime.html('00:00');
  449 + // Total time to return to the initialization state / 总时间回到初始化状态
403 _this.elements.totalTime.html('00:00'); 450 _this.elements.totalTime.html('00:00');
  451 + // The volume back to initialize the state / 音量回到初始化状态
404 _this.elements.currentVolume.width(_this.elements.totalVolume); 452 _this.elements.currentVolume.width(_this.elements.totalVolume);
  453 + // Playback progress bar to initialize state / 播放进度条回到初始化状态
405 _this.elements.playProgress.width(0); 454 _this.elements.playProgress.width(0);
  455 + // Audio download progress bar back to the initial state / 音频下载进度条回到初始状态
406 _this.elements.loadProgress.width(0); 456 _this.elements.loadProgress.width(0);
407 - },  
408 - log: function(log){ 457 + }
  458 + // Custom log / 定制log
  459 + ,log: function(log){
409 var _this = this; 460 var _this = this;
410 461
411 if(_this.options.debuggers){ 462 if(_this.options.debuggers){