Order Now AdSolution Sign Up | Login » Bits on the Run Sign Up | Login »

Forums

/

Trigger song with a Button

3 replies [Last post]

Hello

I started from the code generated for "Flvplayer with a single song"; I did the following:
• Locate the Script code into a function
• Trigger the song with a Button

Here is my code, into the Head part:

<script type='text/javascript'>
function voix(fichier)
{
var so = new SWFObject('player.swf','ply','470','20','9','#ffffff');
so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','always');
so.addParam('wmode','opaque');
so.addVariable('file','+fichier+');
so.addVariable('duration','33');
so.write('mediaspace');
}
</script>

And into the Body part:

<script type='text/javascript' src='swfobject.js'></script>
<div id='mediaspace'>
<button type="button" onclick="javascript:voix('messagerie1.mp3')" class="bouton2">Toto</button>
</div>

Problem 1: this does not work.

Problem 2: I need that the song would start right away after clicking onto the Button, ie without clicking again on the small black arrow left to the player board.

Thank you in advance for your help.

Francois

 
In the head element:

    <script src="swfobject.js"></script>

    <script type="text/javascript">
      function voix(fichier)
      {
        var so = new SWFObject('player.swf', 'ply', '470', '20', '9.0.124', '#ffffff');
            so.addParam('allowfullscreen',     'true');
            so.addParam('allowscriptaccess',   'always');
            so.addVariable('file',              fichier);
            so.addVariable('duration',         '33');
            so.write('mediaspace');
      };
    </script>

In the body element:

    <div id="mediaspace"><a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Get the Adobe Flash Player to see this video.</a></div>
    <button type="button" onclick="voix('messagerie1.mp3')" class="bouton2">Toto</button>

hello Hobbs, thank you for your answer first.

I had messed up the code and you put it back right up, it works great.

Thank you again for your help.

Francois

 
@Francoisch,

You're welcome.

          [i]Good Luck![/i]