Go
Not registered? Sign up!

Trigger song with a Button

Google Translate
4 posts | return to the JavaScript Interaction forum | get the rss feed for this thread

Nov. 07, 2009Francoisch

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

Nov. 07, 2009hobbs

 
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>

Nov. 08, 2009Francoisch

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

Nov. 08, 2009hobbs

 
@Francoisch,

You're welcome.

          Good Luck!

Add a reaction

You can also return to the category or try this search for related threads.


 

Search the Forums

Go

Support

Support Here are some helpful links to learn more about the JW Player™:

Monetize Your Video

Monetize Your Video Earn money with ads from LongTail's AdSolution. Watch our demos and sign up now!

Why Buy a License?

Why Buy a License? If you don’t buy a commercial license, you cannot use a JW Player™ on (i) a site that has ads; (ii) a corporate site; or a (iii) CMS. Our licenses are very inexpensive, so what are you waiting for? Buy a license today.