View Full Version : stop sound from a different frame
Cris79
02-27-2003, 09:17 AM
I have a htm page who use frame like this:
<HTML>
<HEAD>
<TITLE></TITLE>
<frameset Cols="150,*" border=0>
<frame name="left" src="menu_sound.htm" marginwidth="10" marginheight="10" scrolling="Auto" frameborder="no" noresize>
<frame name="right" src="home.htm" marginwidth="10" marginheight="10" scrolling="Auto" frameborder="no" noresize>
<noframes>
<body>
<p>This page uses frames, but your browser doesn't support them.</p>
</body>
</noframes>
</frameset>
</HEAD>
<BODY>
</BODY>
In menu.htm a have put a background sound (an mp3 file).
MY PROBLEM:
How can I stop runing the mp3 file when i load in frame named "right" newpage.htm ?
Do you have any idea?
It might help if you post the code for the left frame so we can see how the mp3 is played
for media player it would be something like
onload="parent.left.document.MediaPlayer.Stop()"
which would be placed in newpage.htm's opening body tag
Cris79
03-03-2003, 08:58 AM
Thanks man !!!
Cris79
03-03-2003, 09:15 AM
Here is the index page:
<HTML>
<HEAD>
<TITLE>index</TITLE>
<frameset Cols="150,*" border=0>
<frame name="left" src="a2.htm" marginwidth="10" marginheight="10" scrolling="Auto" frameborder="no" noresize>
<frame name="right" src="a3_1.htm" marginwidth="10" marginheight="10" scrolling="Auto" frameborder="no" noresize>
<noframes>
<body>
<p>This page uses frames, but your browser doesn't support them.</p>
</body>
</noframes>
</frameset>
</HEAD>
<BODY>
------------------------------------------------------------------------------------
in the right page I have only text.
this is left page code (a2.htm)
<HTML>
<HEAD>
<TITLE>a2 page</TITLE>
<script LANGUAGE="JavaScript" SRC="aud.js"></script>
<script LANGUAGE="JavaScript"><!--
var aySound = new Array();
// Below: source for sound files to be preloaded
aySound[0] = "a1.mp3";
document.write('<BGSOUND ID="auIEContainer">')
IE = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all)? 1:0;
NS = (navigator.appName=="Netscape" && navigator.plugins["LiveAudio"])? 1:0;
ver4 = IE||NS? 1:0;
onload=auPreload;
//-->
</script>
</HEAD>
<BODY>
<INPUT TYPE="BUTTON" VALUE="play" onClick="playSound(0)">
<INPUT TYPE="BUTTON" VALUE="Stop!" onClick="stopSound(0)">
<br><a href="a3.htm" target="right">stop sound</a>
</BODY>
</HTML>
</BODY>
</HTML>
------------------------------------------------------------------------------------
this is aud.js code
function auPreload() {
if (!ver4) return;
if (NS) auEmb = new Layer(0,window);
else {
Str = "<DIV ID='auEmb' STYLE='position:absolute;'></DIV>";
document.body.insertAdjacentHTML("BeforeEnd",Str);
}
var Str = '';
for (i=0;i<aySound.length;i++)
Str += "<EMBED SRC='"+aySound[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>"
if (IE) auEmb.innerHTML = Str;
else {
auEmb.document.open();
auEmb.document.write(Str);
auEmb.document.close();
}
auCon = IE? document.all.auIEContainer:auEmb;
auCon.control = auCtrl;
}
function auCtrl(whSound,play) {
if (IE) this.src = play? aySound[whSound]:'';
else eval("this.document.embeds[whSound]." + (play? "play()":"stop()"))
}
function playSound(whSound) { if (window.auCon) auCon.control(whSound,true); }
function stopSound(whSound) { if (window.auCon) auCon.control(whSound,false); }
------------------------------------------------------------------------------------
At last this is a3.htm code
<HTML>
<HEAD>
<TITLE></TITLE><script LANGUAGE="JavaScript" SRC="aud.js"></script>
</HEAD>
<BODY onload="stopSound(0)">
<center>No sound</center>
</BODY>
</HTML>
--------------------------------------
Can you see where is the problem?
Thanks !!!
:thumbsup:
In a3.htm try the following
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY onload="parent.left.stopSound(0)">
<center>No sound</center>
</BODY>
</HTML>
Cris79
03-05-2003, 08:52 AM
OK!!!:D Now is good. Thanks:thumbsup: !!!
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.