Can't make player stop via Javascript
Please help! I've tried every example on this website to try to STOP a FLVplayer from playing a video. Here's what I'm doing: I've set up a player, but am not actually not actually started it ontil a user clicks on a button, which involkes the StartVid() function shown. There's a boolean so that the first time it's clicked, the actual player is written to the <DIV id>. That works fine. Next time that button is clicked, I want to stop the video and re-load the page. The STOP is needed because otherwise, it takes forever to re-load. The comments show all the things I've tried that don't work. In every case, my error console shows that the object doesn't support the method. What am I doing wrong?
<script type='text/javascript'>
var st = new SWFObject('bin/player.swf','ply','550','420','9','#33cc99');
st.addParam('allowfullscreen','true'); // global settings
st.addVariable('fullscreen', 'true');
st.addParam('allowscriptaccess','always');
st.addParam('wmode','opaque');
st.addVariable('autostart', 'true');
st.addVariable('file', 'housewalk.flv');
var bPlayVid = 0;
function startVid()
{
if(bPlayVid == 0)
{
bPlayVid = 1; // first time
st.write("vtLocation");
}
else // next time
{
var player = document.getElementById('vtLocation');
player.sendEvent("PLAY"); // doesn't work
st.sendEvent("PLAY"); // doesn't work either
player.sendEvent("STOP"); // doesn't workeither
player.sendEvent("PLAY", 'false'); // doesn't work either
location.reload(0); // don't ask... there's a good reason.
}
}