user avatar
user avatar
user avatar
X9DESIGN
  • Member for 6 years, 7 months
  • Last seen more than a month ago
About

Here You have version for multiple instances of audio player.

HTML

<a href="javascript:void(0)" onclick="aud_play_pause(this)">
    <i class="control icon-play"></i>
    <audio class="xnine-player" src="/path/to/file#1.mp3" preload="auto"></audio>
</a>

<a href="javascript:void(0)" onclick="aud_play_pause(this)">
    <i class="control icon-play"></i>
    <audio class="xnine-player" src="/path/to/file#2.mp3" preload="auto"></audio>
</a>

JAVASCRIPT

<script>
    function aud_play_pause(object) {
        var myAudio = object.querySelector(".xnine-player");
        var myIcon = object.querySelector(".control");
        if (myAudio.paused) {
            myIcon.className = "control icon-pause";
            myAudio.play();
        } else {
            myIcon.className = "control icon-play";
            myAudio.pause();
        }
    }
</script>

...

Badges
This user doesn’t have any gold badges yet.
This user doesn’t have any silver badges yet.
9
bronze badges
1
Score
5
Posts
42
Posts %
1
Score
2
Posts
17
Posts %
1
Score
2
Posts
17
Posts %
0
Score
3
Posts
25
Posts %
0
Score
2
Posts
17
Posts %
0
Score
2
Posts
17
Posts %
Top posts
View all questions and answers