1
I have a problem with javascript, yes for lack of knowledge of the language.
The following, the code below makes a song from a search list play by clicking on "Play".
Javascript:
<script>
function PlayerRoduzir(id) {
var id;
change("https://api.xxxxxx.com/tracks/" + id +".mp3");
var button1 = document.getElementById("play_" + id).style.display = "none";
var button2 = document.getElementById("stop_" + id).style.display = "";
}
function PlayerParar(id){
var id;
var audio = document.getElementById("player");
var source = document.getElementById("mp3_src");
var button1 = document.getElementById("play_" + id).style.display = "";
var button2 = document.getElementById("stop_" + id).style.display = "none";
audio.pause();
}
</script>
PHP/HTML:
<?php
echo "<button type='button' id='play_".$id."' onClick='PlayerRoduzir(".$id.");' class='btn btn-info'><i class=\"fa fa-play-circle-o\" aria-hidden=\"true\"></i></button> ";
echo "<button type='button' style='display: none;' id='stop_".$id."' onClick='PlayerParar(".$id.");' class='btn btn-danger'><i class=\"fa fa-stop\" aria-hidden=\"true\"></i></button> ";
?>
When I click play the playback button turns red with the STOP signal to stop, if I click back the player.
The problem is when I click on the other "play", the other buttons should turn blue, but it doesn’t turn red, I would like it to turn blue and red only in the song that is playing. See the example of how it is currently in the image below:
And then, how to fix it?
When you click a button
play
it is necessary to stop all others by javascript, calling the function ofPlayerParar
for each of them– Isac
Can you post an example please? Unfortunately I have no experience with JS.
– user41630
Has the bootstrap class, being btn btn-info for play and btn btn-Danger stop.
– user41630