- Timestamp:
- 2022-10-24T08:34:28+13:00 (19 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-installations/mars/trunk/sites/mars/collect/amc-essentia/js/av_document.js
r36862 r36865 1 var AMC_SONG_DURATION = 30; 2 3 var currentPosIsZero = true; 4 var currentPosRunup = 0; 5 6 7 function AVEnsurePaused() 8 { 9 if (!wavesurfer.backend.isPaused()) { 10 $('#ws-pause-icon').hide(); 11 $('#ws-play-icon' ).show(); 12 $('#ws-playpause-label').html("Play"); 13 } 14 15 wavesurfer.pause(); 16 } 17 18 function AVPlay() 19 { 20 $('#ws-play-icon' ).hide(); 21 $('#ws-pause-icon').show(); 22 $('#ws-playpause-label').html("Pause"); 23 24 if (currentPosRunup>0) { 25 var skip_amount = -1 * currentPosRunup; 26 wavesurfer.skip(skip_amount); 27 currentPosRunup = 0; 28 } 29 30 wavesurfer.play(); 31 32 } 33 1 34 function AVPlayPause() 2 35 { 3 return wavesurfer.backend.isPaused() ? wavesurfer.play() : wavesurfer.pause(); 36 if (wavesurfer.backend.isPaused()) { 37 AVPlay(); 38 } 39 else { 40 AVEnsurePaused(); 41 } 42 43 //return wavesurfer.backend.isPaused() ? wavesurfer.play() : wavesurfer.pause(); 4 44 } 5 45 … … 36 76 // clamp to ensure >= 6.0 secs 37 77 var current_time = Math.max(6.0,wavesurfer.getCurrentTime()); 38 39 wavesurfer.pause();78 var current_time_1dp = current_time.toFixed(1); 79 AVEnsurePaused(); 40 80 41 81 weka_segment = Math.round(current_time/3) * 3; … … 47 87 form.elements["s1.arousal"].value = arousal_val; 48 88 form.elements["s1.valence"].value = valence_val; 89 90 $('#makeRecommendationFrom-AV').html(`(@${current_time_1dp} secs: arousal=${arousal_val}, valence=${valence_val})`); 49 91 50 92 … … 83 125 }; 84 126 85 127 /* 86 128 var argsFixed = { 87 129 "a": "q", … … 101 143 "excerptid" : "resultsArea" 102 144 }; 145 */ 103 146 104 147 var url = "https://mars.so-we-must-think.space/greenstone3/library"; 148 149 $('#recommendationArea').css("cursor","wait"); 150 $('#resultsAreaDiv').html("Retrieving recommendation ..."); 105 151 106 152 $.ajax({ … … 109 155 data: args 110 156 }) 111 .done(function( msg ) { 112 $('#resultsAreaDiv').html(msg); 113 //alert( "Data Saved: " + msg ); 114 }); 115 157 .always(function() { 158 $('#recommendationArea').css("cursor","revert"); 159 }) 160 .fail(function(jqXHR,textStatus) { 161 console.error( "Request failed: " + textStatus); 162 }) 163 .done(function(html_result) { 164 $('#resultsAreaDiv').html(html_result); 165 166 const updated_url = new URL(window.location); 167 updated_url.searchParams.set('p.frameOffset', current_time); 168 //window.history.pushState({}, '', url + "?p.frameOffset=" + current_time); 169 //window.history.pushState({}, '', updated_url); 170 window.history.replaceState({}, '', updated_url); 171 172 173 }); 174 116 175 // stop submit 117 176 return false; 118 177 178 // force GET method request to go ahead 119 179 //return true; 120 180 } 121 181 122 182 123 var currentPosIsZero = true;124 183 125 184 function recommendFromStart() … … 140 199 function postInitWavesurfer(wavesurfer) 141 200 { 201 console.log("postInitWavesurfer called with wavesufer = " + wavesurfer); 202 142 203 wavesurfer.load(gs.variables.mp3url); 143 204 … … 157 218 158 219 wavesurfer.on('ready', function () { 220 221 console.log("**** wavesurfer ready()"); 159 222 160 223 if ('p_frameOffset' in gs.cgiParams) { … … 162 225 //console.log("**** starting play @ " + frameOffset); 163 226 //wavesurfer.play(frameOffset); 164 wavesurfer.seekTo(frameOffset/30.0); 227 //console.log("**** setting play seek @ " + frameOffset); 228 wavesurfer.seekTo(frameOffset/AMC_SONG_DURATION); 229 230 if (frameOffset>1.0) { 231 currentPosRunup = 1.0; // 1 second 232 } 165 233 } 166 234 }); 167 235 168 236 } 237 238 $(document).ready(function() { 239 240 const doc_url = new URL(window.location); 241 var renderWave = doc_url.searchParams.get('renderWave'); 242 243 if (renderWave && (renderWave == 1)) { 244 // showing the waveform => offer link to spectrogram 245 const sts_url = new URL(window.location); 246 sts_url.searchParams.set('renderWave', 0); 247 $('#switch-to-spectrogram').attr("href",sts_url); 248 $('#switch-to-waveform').hide(); 249 } 250 else { 251 // show the spectrogram => offer link to waveform 252 253 const stw_url = new URL(window.location); 254 stw_url.searchParams.set('renderWave', 1); 255 $('#switch-to-waveform').attr("href",stw_url); 256 $('#switch-to-spectrogram').hide(); 257 } 258 259 }); 260
Note:
See TracChangeset
for help on using the changeset viewer.