1 2jQuery(function($) { 3 4 var elms = ['playBtn', 'pauseBtn']; 5 elms.forEach(function(elm) { 6 window[elm] = document.getElementById(elm); 7 }); 8 9 var Player = function(song) { 10 this.song = song; 11 12 if (playBtn !== null) { 13 playBtn.addEventListener('click', function() { 14 player.play(); 15 }); 16 17 pauseBtn.addEventListener('click', function() { 18 player.pause(); 19 }); 20 21 $("#volume").slider({ 22 min: 0, 23 max: 100, 24 value: 50, 25 range: "min", 26 slide: function(event, ui) { 27 player.volume(ui.value / 100); 28 } 29 }); 30 } 31 }; 32 33 Player.prototype = { 34 play: function() { 35 var self = this; 36 var sound; 37 38 var data = self.song; 39 40 // If we already loaded this track, use the current one. 41 // Otherwise, setup and load a new Howl. 42 if (data.howl) { 43 sound = data.howl; 44 } else { 45 sound = data.howl = new Howl({ 46 src: [data.file], 47 html5: true, // Force to HTML5 so that the audio can stream in (best for large files). 48 volume: 0.5, 49 onplay: function() { 50 pauseBtn.style.display = 'block'; 51 playBtn.style.display = 'none'; 52 }, 53 onload: function() { 54 55 }, 56 onend: function() { 57 58 }, 59 onpause: function() { 60 61 }, 62 onstop: function() { 63 64 } 65 }); 66 } 67 68 // Begin playing the sound. 69 sound.play(); 70 71 // Show the pause button. 72 if (sound.state() === 'loaded') { 73 playBtn.style.display = 'none'; 74 pauseBtn.style.display = 'block'; 75 } else { 76 playBtn.style.display = 'none'; 77 pauseBtn.style.display = 'none'; 78 } 79 }, 80 81 /** 82 * Pause the currently playing track. 83 */ 84 pause: function() { 85 var self = this; 86 87 var sound = self.song.howl; 88 89 // Puase the sound. 90 sound.pause(); 91 92 // Show the play button. 93 playBtn.style.display = 'block'; 94 pauseBtn.style.display = 'none'; 95 }, 96 97 /** 98 * Volume between 0 and 1. 99 */ 100 volume: function(val) { 101 var self = this; 102 103 // Update the global volume (affecting all Howls). 104 Howler.volume(val); 105 }, 106 }; 107 108 // Setup our new audio player 109 /*var player = new Player( 110 { 111 file: '/wordpress/wp-content/plugins/nzyc-extras/part1test.mp3', 112 howl: null 113 } 114 );*/ 115 if (typeof playerfile != 'undefined') { 116 var player = new Player( 117 { 118 file: playerfile, 119 howl: null 120 } 121 ); 122 } 123 124 125 /* var audioplaying=false; 126 document.addEventListener('scroll', function() { 127 if (!audioplaying) { 128 var audio = document.getElementById("myAudio"); 129 if (audio) { 130 var playPromise = audio.play(); 131 132 // In browsers that donât yet support this functionality, 133 // playPromise wonât be defined. 134 if (playPromise !== undefined) { 135 playPromise.then(function() { 136 // Automatic playback started! 137 }).catch(function(error) { 138 // Automatic playback failed. 139 // Show a UI element to let the user manually start playback. 140 console.log('first'); 141 console.log(error); 142 console.log('last'); 143 144 audioplaying = false; 145 }); 146 } 147 else { 148 audioplaying = true; 149 } 150 } 151 else { 152 audioplaying = true; 153 } 154 } 155 });*/ 156 157 158}); 159 160 161 162 163
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.