-2

I am working on music player and I ran into some issues I needed help on.

function play() {
    document.getElementById("embed").innerHTML="<embed src='sound/1.mp3' autostart=true loop=false volume=100 hidden=true>";
    return true;
}
<form action="" method="post">
    <button class="btn blue" type="button" onclick="sound()">PLAY</button>
    <div id="embed"></div>
</form>

When the sound is done playing, is there a way to replay it?

Also, is there a way for PHP to list all the .mp3 files in one folder in that format?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Prabh Singh
  • 49
  • 1
  • 11

1 Answers1

3

Issue 1-

Try to use the <audio> tag. (http://www.w3schools.com/tags/tag_audio.asp)

There you can set the "loop" attribute.

Issue 2-

$dir = '/path/to/dir/*.mp3';

foreach(glob($dir) as $mp3)
{
    $k = pathinfo($mp3);
    $m = $k['basename'];
    $v = explode(".",$k['basename']);
    echo "<li><a href='#' data-src='dir/".$m."'>".$v[0]."</a></li>";

}  

Hope this helps.

Patrick Mlr
  • 2,955
  • 2
  • 16
  • 25