[Solved] Toogle icon (play/pause), and stop when another button is clicked


Well, after a lot of research i could get something that for now it’s ok for me.
I just want to share if anybody else gets my same problem

This are my scripts (i needed to use 2)

    <script language="javascript">
    var currentsound;
    function play_pause(player) {
    var myAudio = document.getElementById(player);
        if(myAudio.paused) {
        myAudio.play();
        } else{
        myAudio.pause();
        }   
                                }
    function changeImage(img) {
    var imgfile = img.src.split(/\s+/).pop();   
    if (imgfile =="http://www.../.../pause.png" ) 
    {
        img.src = "http://www.../.../play.png";
    }
    else 
    {
        img.src = "http://www.../.../pause.png";
    }
                    }
</script>

And what basically do is that the first function do a play/pause for each button, and 2nd function toggle the image (see the onclick event)

This is my HTML:

    <audio preload="none" id="myAudio1" src="http://www.../.../Music1.mp3" type="audio/mpeg"> </audio> 
    <img src="http://www.../.../play.png" width=30 height=30 border="0"
    onclick="play_pause('myAudio1');changeImage(this)"> <!--id needs to be changed manually (id and onclick event) -->

<audio preload="none" id="myAudio2" src="http://www.../.../Music2.mp3" type="audio/mpeg"> </audio>
    <img src="http://www.../.../play.png" width=30 height=30 border="0"
    onclick="play_pause('myAudio2');changeImage(this)">

Indeed is not the best solution, because every time you click on another button (different from the one is running) them both will sound at same time, but at least you can play/pause each button individually and toggle the icons too.
For more button just copy-paste the html part and change the id part

Hope is usefull for anyone else than me, and if you got a better answer like having a counter variable for put into the ID so don’t need to be changed manually or playing/pause and stopping when any other button gets click, post it, will be very appreciate it!

Regards

solved Toogle icon (play/pause), and stop when another button is clicked