1/**============================================================================================================================== 2 * 3 * SoundManager player object 4 * $.qtSMPO.sm = soundManager 5 * 6 ==============================================================================================================================*/ 7 8(function ($) { 9 $.qtSMPO = { 10 sm: soundManager, 11 playerCont: $('#qtmplayer'), 12 soundId: 'qtSoundId', 13 init: function(){ 14 var ob = $.qtSMPO, 15 flashpath = ob.playerCont.data("qtmplayer-smflash"); 16 $.qtSMPO.sm.setup({ 17 // url: flashpath, 18 useHighPerformance: true, 19 usePeakData:true, 20 forceUseGlobalHTML5Audio: true, 21 bufferTime: 90000, 22 useHTML5Audio: true, 23 }); 24 return true; 25 }, 26 smPause: function(){ 27 $.qtSMPO.sm.pause($.qtSMPO.soundId); 28 }, 29 secondsTimeSpanToHMS: function(s){ 30 var h = Math.floor(s/3600); //Get whole hours 31 s -= h*3600; 32 var m = Math.floor(s/60); //Get remaining minutes 33 s -= m*60; 34 var stringtime; 35 if(h >= 1){ 36 stringtime = h+":"+(m < 10 ? '0'+m : m)+":"+(s < 10 ? '0'+s : s); 37 } else { 38 stringtime = (m < 10 ? '0'+m : m)+":"+(s < 10 ? '0'+s : s); 39 } 40 return stringtime; 41 }, 42 smStop: function(){ 43 var smp = $.qtSMPO, 44 sm = $.qtSMPO.sm, 45 id = $.qtSMPO.soundId, 46 ob = $.qtPlayerObj, 47 interface = ob.interface; 48 sm.stop(id); 49 sm.destroySound(id); 50 sm.nowplaying = false; 51 interface.timeupdate("00:00", '00:00'); 52 }, 53 smPlay: function(){ 54 var smp = $.qtSMPO, 55 sm = $.qtSMPO.sm, 56 id = $.qtSMPO.soundId, 57 ob = $.qtPlayerObj, 58 interface = ob.interface, 59 percLoaded, 60 duration, 61 position, 62 perc, 63 time, 64 s, 65 h; 66 if(sm.nowplaying === ob.songdata.file){ 67 sm.play(id); 68 } else { 69 sm.destroySound(id); 70 sm.nowplaying = ob.songdata.file; 71 sm.sound = sm.createSound({ 72 id: id, 73 url: ob.songdata.file, 74 autoLoad: true, 75 autoPlay: true, 76 volume: 90, 77 onload: function() { 78 }, 79 whileplaying : function(){ 80 duration = sm.sound.duration; 81 position = sm.sound.position; 82 perc = position /duration; 83 time; 84 time = smp.secondsTimeSpanToHMS( Math.round(sm.sound.position / 1000) ); 85 duration = smp.secondsTimeSpanToHMS( Math.round(sm.sound.duration / 1000) ); 86 interface.timeupdate(perc, time); 87 $.qtRaphaelCircle.update(perc); 88 $.qtMplayerPlaylistCue.update(perc * 100); 89 }, 90 onbufferchange: function(){ 91 if(sm.sound.isBuffering){ 92 interface.bufferStart(); 93 } else { 94 var durationHMS = smp.secondsTimeSpanToHMS(Math.round(sm.sound.duration / 1000)); 95 interface.setDuration(durationHMS); 96 interface.bufferEnd(); 97 percLoaded = sm.sound.bytesLoaded / sm.sound.bytesTotal; 98 if (isNaN(percLoaded)) { 99 $.qtPlayerObj.interface.progressUpdate(0); 100 } else { 101 $.qtPlayerObj.interface.progressUpdate(percLoaded); 102 } 103 } 104 }, 105 whileloading: function(){ 106 var percLoaded; 107 percLoaded = sm.sound.bytesLoaded / sm.sound.bytesTotal; 108 if(percLoaded === 0 ){ 109 percLoaded = 0.1; 110 } 111 $.qtPlayerObj.interface.progressUpdate(percLoaded); 112 }, 113 onPosition : function(){ 114 115 }, 116 onfinish: function(){ 117 interface.next(); 118 } 119 }); 120 } 121 }, 122 smSeek: function(perc){ 123 if( undefined === $.qtSMPO.sm.sound){ 124 return; 125 } 126 var cue = $.qtSMPO.sm.sound.duration * perc / 100, 127 time, 128 s = Math.round($.qtSMPO.sm.sound.duration) / 1000 / 100 * perc, 129 h = Math.floor(s/3600); //Get whole hours 130 s -= h*3600; 131 var m = Math.floor(s/60); //Get remaining minutes 132 s -= m*60; 133 s = Math.round(s); 134 if(s > 3600){ 135 time = h+":"+(m < 10 ? '0'+m : m)+":"+(s < 10 ? '0'+s : s); 136 } else { 137 time = (m < 10 ? '0'+m : m)+":"+(s < 10 ? '0'+s : s); 138 } 139 $.qtPlayerObj.interface.timeupdate(perc/100, time); 140 $.qtSMPO.sm.setPosition($.qtSMPO.soundId,cue); 141 }, 142 smSeekTime: function(t){ 143 var a = t.split(':'); 144 var sec = parseInt(a[0]*3600) + parseInt(a[1]*60) + parseInt(a[2]); 145 var ms = sec * 1000; 146 var perc = ms / $.qtSMPO.sm.sound.duration * 100; 147 $.qtPlayerObj.interface.timeupdate(perc, t); 148 $.qtSMPO.sm.setPosition($.qtSMPO.soundId, ms); 149 } 150 }; 151})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.