How to create a "sound / sound enable" button?

I saw a lot of web pages with a simple mute button that plays music or any mp3 file when you click a sound, and turns it off when pressed.

How to do it?

Hi, I did not plan to use Flash - if there is a standard plugin that I could use, and then make changes to the script, that would be cool.

I am open to all that there is a "standard" way to do this.

+3
source share
5 answers

I used google and then used a standalone pixel

0
source

Here is the right way to do it in AS3.

Initialization:

var sound:Sound;
var channel:SoundChannel;
var pos:Number;
var numLoops:Number = 0; // 0 to loop forever

sound = new Sound();
sound.load( new URLRequest("song.mp3") );
channel = sound.play( 0, numLoops );

:

pos = channel.position;
channel.stop();

:

channel = sound.play( pos, numLoops );

, , , , , "" .

+2

Javascript SoundPlayer , . , -.

<script language="javascript" type="text/javascript" src="http://lablogic.net/scripts/soundplayer/audio_o.js"></script>

<a href="#" onclick='play("your-sound-file.mp3")'>PLAY</a>
<a href="#" onclick='stop("your-sound-file.mp3")'>STOP</a>

"your-sound-file.mp3" URL . . , , . script , , : javascript-

+1

Flash? :

stopAllSounds();

theSound.stop(["id"]);
0

Assuming you are using Flash as above.

AS2

stopAllSounds();

AS3

var xf:SoundTransform = SoundMixer.soundTransform;
xf.volume = 0;
SoundMixer.soundTransform = xf;
0
source

Source: https://habr.com/ru/post/1709011/


All Articles