Forum Moderators: open
import flash.external.*;
ExternalInterface.addCallback('Sound', null, playsound);
ExternalInterface.addCallback("Stop", null, stopsound);
function playsound(url)
{
sound = new Sound(soundLoader);
sound.loadSound(url,true);
}
function stopsound() {sound.stop();}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Sound Player</title>
<script type="text/javascript">
//<![CDATA[
function play(url)
{
var splayer = document.getElementById('splayer');
if (splayer)
{
if (url=='stop' && splayer.Stop!=undefined) {splayer.Stop();}
else if (splayer.Sound!=undefined) {splayer.Sound(url);}
else {alert('Undefined, is height and width both at least 1px?');}
}
}
//]]>
</script>
</head>
<body>
<div><a href="javascript:play('stones.mp3');">play mp3 sound</a></div>
<div><a href="javascript:play('stop');">stop mp3 sound</a></div>
<object data="sound.swf" id="splayer" style="height: 1px; width: 1px;" type="application/x-shockwave-flash">
<param name="loop" value="false" />
<param name="play" value="true" />
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
</object>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Sound Player</title>
<script type="text/javascript">
//<![CDATA[
function play(url)
{
var splayer = document.getElementById('splayer');
if (splayer)
{
if (url=='stop' && splayer.Stop!=undefined) {splayer.Stop();}
else if (splayer.Sound!=undefined) {splayer.Sound(url);}
else {alert('Undefined, is height and width both at least 1px?');}
}
}
//]]>
</script>
</head>
<body>
<div><a href="javascript:play('sound1.mp3&1');">play mp3 sound 1</a></div>
<div><a href="javascript:play('sound2.mp3&2');">play mp3 sound 2</a></div>
<div><a href="javascript:play('stop');">stop mp3 sound</a></div>
<object data="sound2-final.swf" id="splayer" style="height: 1px; width: 1px;" type="application/x-shockwave-flash">
<param name="loop" value="false" />
<param name="play" value="true" />
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
</object>
</body>
</html>
import flash.external.*;
ExternalInterface.addCallback('Sound',null,playsound);
ExternalInterface.addCallback("Stop", null, stopsound);
function playsound(param)
{
var p = param.split('&');
if (p[1]=='0') {sound0 = new Sound(sound0); sound0.loadSound(p[0],true);}
else if (p[1]=='1') {sound1 = new Sound(sound1); sound1.loadSound(p[0],true);}
else if (p[1]=='2') {sound2 = new Sound(sound2); sound2.loadSound(p[0],true);}
else if (p[1]=='3') {sound3 = new Sound(sound3); sound3.loadSound(p[0],true);}
else if (p[1]=='4') {sound4 = new Sound(sound4); sound4.loadSound(p[0],true);}
else if (p[1]=='5') {sound5 = new Sound(sound5); sound5.loadSound(p[0],true);}
else if (p[1]=='6') {sound6 = new Sound(sound6); sound6.loadSound(p[0],true);}
else if (p[1]=='7') {sound7 = new Sound(sound7); sound7.loadSound(p[0],true);}
}
function stopsound()
{
sound0.stop();
sound1.stop();
sound2.stop();
sound3.stop();
sound4.stop();
sound5.stop();
sound6.stop();
sound7.stop();
}