"mp3player" Controlled by JavaScript Code

This section provides a tutorial example on how to control 'mp3player' using JavaScript code like document.getElementById('xxx').SetVariable().

mp3player can also be controlled by JavaScript code, because it supports these properties through the SetVariable() function:

SetVariable("player:jsPlay","") - Starts to play the music
SetVariable("player:jsPause","") - Pauses the play
SetVariable("player:jsStop","") - Stops the play
SetVariable("player:jsVolume",n) - Sets the volume to n

To call the SetVariable() function, you need:

Here is my tutorial example on how to control mp3player with JavaScript codes:

<html>
<!-- mp3player_JavaSript_test.html
 - Copyright (c) 2014, HerongYang.com, All Rights Reserved.
-->
<head>
<script type="text/javascript">
   function play() {
      document.getElementById("myFlash").SetVariable(
         "player:jsPlay","");
   }
   function pause() {
      document.getElementById("myFlash").SetVariable(
         "player:jsPause","");
   }
   function stop() {
      document.getElementById("myFlash").SetVariable(
         "player:jsStop","");
   }
   function volume(n) {
      document.getElementById("myFlash").SetVariable(
         "player:jsVolume",n);
   }
</script>
</head>
<body>

<p>Controlling mp3player with JavaScript Code:
</p>

<p>[ <a href="javascript:play()">Play</a> 
   | <a href="javascript:pause()">Pause</a>
   | <a href="javascript:stop()">Stop</a> 
   | <a href="javascript:volume(0)">Volume=0</a>
   | <a href="javascript:volume(100)">Volume=100</a>
   | <a href="javascript:volume(200)">Volume=200</a>
   ]
</p>

<object id="myFlash" type="application/x-shockwave-flash" 
   data="player_mp3_maxi.swf"
   width="200" height="20">
   <param name="wmode" value="transparent"/>
   <param name="movie" value="player_mp3_maxi.swf"/>
   <param name="FlashVars"
   value="mp3=Music_Sample.mp3&amp;config=mp3player_config.txt"/>
</object>

</body></html>

If you open mp3player_JavaSript_test.html in Firefox or IE, you should see several links that allows you to control mp3player via JavaScript codes.

I have included the above code here on this page. If you are reading the Web version of this book, you should be able to see mp3player displayed and you can play it. Otherwise, you will see a static image.

Flash application my3player is integrated here. You can use these JavaScript links to control it:
[ Play | Pause | Stop | Volume=0 | Volume=100 | Volume=200 ]

Table of Contents

 About This Book

 Introduction of Adobe Flash

 Adobe Flash Player Plugin for Firefox

 Adobe Flash Player Plugin for Chrome

 Adobe Flash Player Plugin for Safari

 Adobe Flash Player ActiveX for IE

 Using "object" Elements for Flash Files

 Using "embed" Elements for Flash Files

"mp3player" - MP3 Music Player

 Downloading and Testing "mp3player"

 Integrating "mp3player" in Web Pages

 "mp3player" Configuration Parameters

"mp3player" Controlled by JavaScript Code

 "object" Element with Flash Parameters

 "object" Element with Flash Parameters - Firefox 3

 "object" Element with Flash Parameters - IE 8

 "embed" Element with Flash Parameters

 SWFObject - Hidding "object" behind JavaScript

 Flash Player Projector

 SWFTools - SWF File Manipulation Tools

 SWFC Script to Generate Flash SWF Files

 ActionScript Embedded in SWFC Script

 AS3Compile - ActionScript 3 Compiler

 Adobe Flex SDK 4

 SWF File Structure and Tags

 SWF File Processing Rules

 SWF Files for Video and Audio Streams

 Outdated Tutorials

 References

 Full Version in PDF/EPUB