2010-04-12 138 views
1

我从来没有删除声音剪辑,我想通过一个事件播放。在浏览器中播放动态声音剪辑

我有有像这样一个片段文件:

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; 
} 

,并在页面上我最喜欢这个按钮;

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

和这个隐藏在后台

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

和JS是;

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

这似乎不工作,我相信它与PHP头有关。有人能请我指出正确的方向,因为它将非常感激。

回答