in a simple web application made with jQuery Mobile im using Howler.js Javascript for audio, the page has a flipswitch widget:
https://theredlips.digitalking.it/giochi/Sx1.html
When i switch to SI the music start to play in loop but when i switch to NO it doesn't pause.
I use the pause() method that is provided with Howler.js
Here is the part of the js code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/howler/2.0.3/howler.min.js"></script>
<script type="text/javascript">
$(document).on('pagecreate','[data-role=page]',function() {
// console.log('PAGECREATE');
$('#flip-select-audio').change(function() {
var sound = new Howl({
src: ['Sounds/Sx1.mp3', 'Sounds/Sx1.ogg','Sounds/Sx1.m4a'],
loop: true,
});
if ($(this).val() == "on") {
sound.play();
} else {
sound.pause();
}
});
});
</script>
and the part of the HTML code:
<form>
<label for="flip-select-audio"><strong>MUSICA:</strong></label>
<select id="flip-select-audio" name="flip-select-audio" data-role="flipswitch" data-mini="true">
<option value="off">NO</option>
<option value="on">SI</option>
</select>
</form>
Thanks in advice for any help.
不是一个错误,我移动var sound = new Howl外部改变flipswitch小部件的功能,现在正常工作!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.