From 7bf981b2967be64a9d621bc629066212b94256c3 Mon Sep 17 00:00:00 2001 From: Felix Hartmann Date: Wed, 29 May 2019 20:17:59 +0200 Subject: [PATCH] added note about browsers, added touch support for slider --- src/frontend/app.js | 33 ++++++++++++++++++++++++++++++--- src/frontend/sheets.ejs | 4 ++-- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/frontend/app.js b/src/frontend/app.js index 84088e1..16c20b1 100644 --- a/src/frontend/app.js +++ b/src/frontend/app.js @@ -12,6 +12,7 @@ let songDir = []; let player = null; let aLoopTime = null; let bLoopTime = null; +let sliderPause = false; // init socket io $(function () { @@ -100,6 +101,34 @@ $(function () { updateDisplay(); }); + $( '#position-slider' ).on('touchend', function () { + if(sliderPause){ + player.play(); + sliderPause = false; + } + }); + + $( '#position-slider' ).on('touchstart', function () { + if(player.isPlaying()){ + player.pause(); + sliderPause = true; + } + }); + + $( '#position-slider' ).mouseup(function () { + if(sliderPause){ + player.play(); + sliderPause = false; + } + }); + + $( '#position-slider' ).mousedown(function () { + if(player.isPlaying()){ + player.pause(); + sliderPause = true; + } + }); + $( '#speed-slider' ).change(function () { updateDisplay(); }); @@ -109,7 +138,7 @@ $(function () { }); $('input[type=range]').on('input', function () { - $(this).trigger('change'); + $(this).trigger('change'); }); $('#extFile').change(function () { @@ -238,10 +267,8 @@ Player.prototype = { html5: true, // Force to HTML5 so that the audio can stream in (best for large files). onplay: function() { updateDisplay(); - console.log('pressed play button'); $( '#playBtn' ).removeClass('btn-succes').addClass('btn-warning'); $( '#playBtn svg' ).removeClass('fa-play').addClass('fa-pause'); - // Start upating the progress of the track. requestAnimationFrame(self.step.bind(self)); }, onload: function() { diff --git a/src/frontend/sheets.ejs b/src/frontend/sheets.ejs index 4c7bac5..92a34df 100644 --- a/src/frontend/sheets.ejs +++ b/src/frontend/sheets.ejs @@ -11,7 +11,7 @@
@@ -33,4 +33,4 @@ ${require ('./views/footer.html')}
- \ No newline at end of file +