views:

31

answers:

1

Hi, I've never delt with sound clips and im wanting to play one via an event.

I have a file which has a snippet like so:

if( $get['0002'] == 'mu' ) {
    switch( $get['0000'] ) {
        case 'mp3': header('Content-Type: audio/mp3'); break;
        case 'wav': header('Content-Type: audio/x-wav'); break;
        default: break;
    }
    echo file_get_contents('./folder-name/' . $get['0001'] . '.' . $get['0000'] );
    exit;
}

and on the page I fave this button;

<input type="button" value="Play Sound" onClick="EvalSound('sound1')" >

and this hidden away in the background

<embed src="./?0000=wav&0001=0001&0002=mu" autostart=false width=0 height=0 id="sound1" enablejavascript="true">

and the js being;

<script>
function EvalSound(soundobj) {
  var thissound=document.getElementById(soundobj);
  thissound.Play();
}
</script>

This does not seem to work and I believe it has something to do with the PHP headers. Could someone please point me in the right direction, as it would be much appreciated.

A: 

Please do some testing here with: http://www.phon.ucl.ac.uk/home/mark/audio/play.htm

On firefox I get an error for the Play() function.

Use something like firebug to give you more information.

If everything works then start debugging your php script.

zaf