diff --git a/client/src/App.js b/client/src/App.js index f097b32..02cdd25 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -120,9 +120,12 @@ class App extends Component { acceptableContent[iRadio] = res.hasAcceptableContent; if (self.state.playingRadio === radioName && res.hasAcceptableContent && res.delayChanged) { // here, we know we are playing a channel with good content at the updated delay - self.play(radioName); + self.play(radioName, null, function(err) { + onCursorChecked(); + }); + } else { + onCursorChecked(); } - onCursorChecked(); }); }, function(err) { var iPlayingRadio = self.getRadioIndex(self.state.playingRadio); @@ -141,7 +144,7 @@ class App extends Component { for (i=0; i {/*= self.state.config.user.cacheLen*1000 })} src={iconPlay} alt="Backward 30s" onClick={self.seekBackward} />*/} - self.play(null, null)} /> + self.play(null, null, null)} /> {/**/} ); @@ -435,7 +443,7 @@ class App extends Component { id={"RadioItem" + i} key={"RadioItem" + i}> - + {liveMetadata && @@ -457,7 +465,7 @@ class App extends Component { playing={playing} cacheLen={self.state.config.user.cacheLen} width={self.state.canvasWidth || 100} - playCallback={function(delay) { self.play(radio, delay); }} /> + playCallback={function(delay) { self.play(radio, delay, null); }} /> } diff --git a/client/src/Playlist.js b/client/src/Playlist.js index 8b7be0d..33de0b4 100644 --- a/client/src/Playlist.js +++ b/client/src/Playlist.js @@ -97,7 +97,7 @@ class Playlist extends Component {
    {["music", "speech", "ads"].map(function(type, index) { return ( - + {self.translateContentName(type, lang)} diff --git a/client/src/audio.js b/client/src/audio.js index 20f53a6..ca5911d 100644 --- a/client/src/audio.js +++ b/client/src/audio.js @@ -11,7 +11,7 @@ audioElement.addEventListener("play", function() { console.log("playback started"); }); -var play = function(url) { +/*var play = function(url) { stop(); console.log("play " + url); audioElement.src = url; @@ -27,6 +27,25 @@ var stop = function() { } catch(e) { // no-op } +}*/ + +var play = function(url, callback) { // https://developers.google.com/web/updates/2017/06/play-request-was-interrupted + console.log("play " + url); + audioElement.src = url; + var playPromise = audioElement.play(); + if (playPromise !== undefined) { + playPromise.then(_ => { + if (callback) callback(null); + }) + .catch(error => { + if (callback) callback(error); + }); + } +} + +var stop = function() { + audioElement.src = ""; + audioElement.load(); } var setVolume = function(volume) {