looping an audio file

Discussion in 'Javascript' started by Ivo, Dec 13, 2004.

  1. Ivo

    Ivo Guest

    Hi,
    I have an audio file (.mid or .wav or .mp3) in an object element:

    <object id="snd" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
    codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.
    cab#Version=5,1,52,701" type="application/x-oleobject" width="282"
    height="53">
    <param name="FileName" value="Tjaikovsky_-_The_sorcerers_apprentice.mid" />
    <param name="loop" value="true" />
    <... more presentational params ...>
    <embed name="embsnd" src="Tjaikovsky_-_The_sorcerers_apprentice.mid"
    width="280" height="53" controls="smallconsole" autostart="true"
    loop="true"></embed>
    </object>

    and a checkbox with which I would like to toggle the looping behaviour of
    said object:

    <label for="chloop">Loop:</label><input type="checkbox" id="chloop"
    onclick="toggleloop(this);" class="zm" checked>

    However, the sound keeps looping whatever I put in the toggle function:

    function toggleloop(el){
    document.getElementById('snd').PlayCount=el.checked?99:1;
    document.getElementById('snd').PlayCount=el.checked?0:1;
    document.getElementById('snd').loop=el.checked?99:1;
    document.getElementById('snd').loop=el.checked?0:1;
    document.embeds.embsnd.loop=el.checked?99:1;
    document.embeds.embsnd.loop=el.checked;
    ...??
    }

    Resources on the web speak of embedding sounds into webpages in many ways,
    but none I have found that discuss this particular issue. I hope someone
    easily
    spots my error.
     
    Ivo, Dec 13, 2004
    #1
    1. Advertisements

  2. Ivo

    Ivo Guest

    Thanks for your thoughts. The 'solution' I now have does that more or less:
    there are two of those objects, one set to loop and visible, the other
    non-looping and invisible. I toggle which sound is visible and hearable with
    the checkbox.

    But it 's not a solution at all: the whole idea behind this application is
    that users can toggle the looping behaviour *while the sound is playing*,
    and that it *keeps playing* at least till the end of the current round!
    Obviously, with your suggestion and my solution, the moment the checkbox is
    clicked, the current sound stops and the other one starts playing. And
    detecting with javascript when a sound file reaches the end also seems
    impossible...
    technology;

    I was hoping the same thing, I started with just an embed tag, then added
    the object hoping it would listen to my script, but alas!
     
    Ivo, Dec 15, 2004
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.