# How do I play and mute sound using javascript?

**URL:** <https://forum.kirupa.com/t/how-do-i-play-and-mute-sound-using-javascript/165830>\
**Category:** Uncategorized\
**Created:** [October 14, 2005, 7:27am UTC](https://forum.kirupa.com/t/how-do-i-play-and-mute-sound-using-javascript/165830 "2005-10-14T07:27:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sameerzs](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sameerzs/32/810_2.png) [@sameerzs](https://forum.kirupa.com/u/sameerzs)\
**Post date:** [October 14, 2005, 7:27am UTC](https://forum.kirupa.com/t/how-do-i-play-and-mute-sound-using-javascript/165830/1 "2005-10-14T07:27:34Z")

</div>

I have embeded sound using Javascript, I can play, pause, and stop it but I also want to foward and rewind it, and I also want to show the counter/timer.

Is there anyway I can do all these…I need this very immediately!!

Can anyone help?

Thank You!!

\*\*\*my code below…

* * *

[SIZE=2]

```auto

<table>
<tr>
<td valign="bottom" class="pod-holder">
<a href="#"><img src="hom_000_files/player_rew.gif" alt="Previous" width="29" height="29" border="0"></a>
<img src=play.jpg id=img1 onclick="callf()" style="cursor:hand">
<img src="hom_000_files/player_stop.gif" alt="Stop" width="29" height="29" border="0" onClick="document.mySound.stop()" style="cursor:hand">
<a href="#"><img src="hom_000_files/player_ff.gif" alt="Next" width="29" height="29" border="0"></a>
</td>
</tr>
</table>

<OBJECT id="mySound" CLASSID="CLSID:05589FA1-C356-11CE-BF01-00AA0055595A" WIDTH=0 HEIGHT=0>
  <PARAM NAME="Version" VALUE="1">
  <PARAM NAME="EnableContextMenu" VALUE="-1">
  <PARAM NAME="ShowDisplay" VALUE="0">
  <PARAM NAME="rate" VALUE="1">
  <PARAM NAME="ShowControls" VALUE="0">
  <PARAM NAME="ShowPositionControls" VALUE="0">
  <PARAM NAME="ShowSelectionControls" VALUE="0">
  <PARAM NAME="EnablePositionControls" VALUE="0">
  <PARAM NAME="EnableSelectionControls" VALUE="0">
  <PARAM NAME="ShowTracker" VALUE="0">
  <PARAM NAME="EnableTracker" VALUE="0">
  <PARAM NAME="AllowHideDisplay" VALUE="0">
  <PARAM NAME="AllowHideControls" VALUE="0">
  <PARAM NAME="AutoStart" VALUE="0">
  <PARAM NAME="PlayCount" VALUE="1">
  <PARAM NAME="Appearance" VALUE="0">
  <PARAM NAME="BorderStyle" VALUE="0">
  <PARAM NAME="FileName" VALUE="four51_pageflex.mp3">
  <PARAM NAME="DisplayMode" VALUE="0">
  <PARAM NAME="AllowChangeDisplayMode" VALUE="-1">
</OBJECT>
<br>
<script language="JavaScript">

    function changeStuff() {

        if (mySound.CurrentState == 0) {
            mySound.Rate = 1;
            mySound.Volume = 0.0;
            mySound.SelectionStart = 0.0;
            mySound.SelectionEnd = 1.0;
            mySound.Run();
            }

        else if (mySound.CurrentState == 1) {

            mySound.Rate = 1;
            mySound.Volume = 0.0;
            mySound.SelectionStart = 0.0;
            mySound.SelectionEnd = 1.0;
            mySound.Run();
            }

        else if (mySound.CurrentState == 0) {
            mySound.Stop();
            }
    }
    function pauseMe() {
        mySound.Pause();
    }
    var flag=false;
        function callf(){

            if(flag==false)
            {
                changeStuff();
                flag=true;
                img1.src="pause.jpg"
            }
            
                else if(flag==true)
            {
                pauseMe();
                flag=false;
                img1.src="play.jpg"
            }
            
    }
</script>

```

[/SIZE]

---

<div class="post-metadata">

**Author:** ![sameerzs](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sameerzs/32/810_2.png) [@sameerzs](https://forum.kirupa.com/u/sameerzs)\
**Post date:** [April 3, 2006, 5:46pm UTC](https://forum.kirupa.com/t/how-do-i-play-and-mute-sound-using-javascript/165830/2 "2006-04-03T17:46:11Z")

</div>

can anyone help???

---

<div class="post-metadata">

**Author:** ![simplistik](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/simplistik/32/7747_2.png) [@simplistik](https://forum.kirupa.com/u/simplistik)\
**Post date:** [April 3, 2006, 6:04pm UTC](https://forum.kirupa.com/t/how-do-i-play-and-mute-sound-using-javascript/165830/3 "2006-04-03T18:04:57Z")

</div>

u still haven’t found the solution after 6 months? try this as a solution:  
[http://www.wimpyplayer.com/products/mp3/javascript\_mp3\_player.html](http://www.wimpyplayer.com/products/mp3/javascript_mp3_player.html)

uses a little flash too i believe.

---

<div class="post-metadata">

**Author:** ![sameerzs](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sameerzs/32/810_2.png) [@sameerzs](https://forum.kirupa.com/u/sameerzs)\
**Post date:** [April 3, 2006, 6:52pm UTC](https://forum.kirupa.com/t/how-do-i-play-and-mute-sound-using-javascript/165830/4 "2006-04-03T18:52:50Z")

</div>

hehe… i somehow managed the other projects but this one is pretty critical.

Can’t i fwd and rew on the same track using only javascript??

---

<div class="post-metadata">

**Author:** ![simplistik](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/simplistik/32/7747_2.png) [@simplistik](https://forum.kirupa.com/u/simplistik)\
**Post date:** [April 3, 2006, 7:17pm UTC](https://forum.kirupa.com/t/how-do-i-play-and-mute-sound-using-javascript/165830/5 "2006-04-03T19:17:14Z")

</div>

> [@sameerzs](#):
>
> hehe… i somehow managed the other projects but this one is pretty critical.
> 
> Can’t i fwd and rew on the same track using only javascript??

Is there a particular reason that you couldn’t just embed it using quicktime or _shudder_ windows media player? and use their controls?

---

<div class="post-metadata">

**Author:** ![sameerzs](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sameerzs/32/810_2.png) [@sameerzs](https://forum.kirupa.com/u/sameerzs)\
**Post date:** [April 3, 2006, 8:06pm UTC](https://forum.kirupa.com/t/how-do-i-play-and-mute-sound-using-javascript/165830/6 "2006-04-03T20:06:21Z")

</div>

ya the client wants teh player to be customised…the looks shud go with the site… :stare:
