Can you tell me if this works, if it does I can put these values into the other one.
It might not be good to set it up like that though, using all those values.
<button onclick='play()'>Play</button>
<button onclick='pause()'>Pause</button>
<script>
var url = 'http://46.105.118.14:15500/;';
var stream = new Audio(url);
stream.preload = 'none';
function play() {
stream.play();
}
function pause() {
stream.pause();
stream.src = ''
stream.load();
stream = null;
stream = new Audio();
stream.src = url;
stream.preload = 'none';
}
</script>
I added in those property values in the other player:
I think it’s crazy to put all that stuff in there though.
Maybe I wouldn’t need every single one of them,
maybe 1 or a couple is all that’s needed. Unless none
of them do the trick.
function pauseAudio(player) {
player.src = ''
player.load();
player = null;
player = new Audio();
player.src = url;
player.preload = 'none';
player.pause();
}
I just found this, not sure if it would work though:
https://stackoverflow.com/a/42125087
var sourceElement = document.querySelector("source");
var originalSourceUrl = sourceElement.getAttribute("src");
var audioElement = document.querySelector("audio");
function pause() {
sourceElement.setAttribute("src", "");
audioElement.pause();
// settimeout, otherwise pause event is not raised normally
setTimeout(function () {
audioElement.load(); // This stops the stream from downloading
});
}
function play() {
if (!sourceElement.getAttribute("src")) {
sourceElement.setAttribute("src", originalSourceUrl);
audioElement.load(); // This restarts the stream download
}
audioElement.play();
}
I tried to set that one up here:
but not sure what would go in the source element spots.
https://jsfiddle.net/bwa3os2v/343/
function playAudio(player, src) {
player.volume = 1.0;
if (!sourceElement.getAttribute("src")) {
sourceElement.setAttribute("src", "http://46.105.118.14:15500/;");
player.load(); // This restarts the stream download
}
player.play();
}
function pauseAudio(player) {
sourceElement.setAttribute("src", "");
player.pause();
// settimeout, otherwise pause event is not raised normally
setTimeout(function() {
player.load(); // This stops the stream from downloading
});
}
Got it working here:
https://jsfiddle.net/bwa3os2v/345/
I may have did it wrong because I didn’t add this in cause I couldn’t get it working with it in.
https://jsfiddle.net/bwa3os2v/347/
var sourceElement = document.querySelector("source");
var originalSourceUrl = sourceElement.getAttribute("src");
var audioElement = document.querySelector("audio");
I put this:
var player = document.querySelector("source");
var "http://46.105.118.14:15500/;" = sourceElement.getAttribute("src");
var player = document.querySelector("audio");