开发者

How we can play audio in html page

In my page i have a button called Play

In included windows media player using this tag

<embed id="wmpid" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" name="mediaplayer1" ShowStatusBar="false" En开发者_JAVA技巧ableContextMenu="false"  autostart="0" width="200" height="45" loop="false" src="/1.wma"  />

The audio is starting when i click on the play contoller.

But when i click on the play button, that i created ,how i can play the audio

Thanks in advance


You have to use JavaScript to play the sound by clicking on a button.

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

  <embed src="success.wav" autostart=false width=0 height=0 name="sound1"
  enablejavascript="true">

Here are examples of a link, an image and a button calling the function.

  <a href="#" onMouseClick="EvalSound('sound1')">Click here</A>


You need to handle events via JavaScript. Refer is-there-a-documented-javascript-api-for-windows-media-player

Personally I recommend Yahoo Media Player. Windows Media Player might not work on all platforms. Prefer a flash based player. You might need to convert wma to mp3.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜