1

I am dealing with music player, i try to access this players method like play, pause, top using java script. but the code can't control those methods. can anyone tell a method for access stop,play and pause method of this using java script or jQuery Thank you

Here is my code

<div class="audiojs" classname="audiojs" id="audiojs_wrapper0">
    <object width="1" height="1" style="position: absolute; left: -1px;" name="audiojs0" id="audiojs0"
            classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
        <param value="./audiojs/audiojs.swf?playerInstance=audiojs.instances['audiojs0']&amp;datetime=1336309077444.049"
               name="movie">
        <param value="always" name="allowscriptaccess">
        <embed width="1" height="1" allowscriptaccess="always"
               src="./audiojs/audiojs.swf?playerInstance=audiojs.instances[%27audiojs0%27]&amp;datetime=1336309077444.049"
               name="audiojs0">
    </object>

</div>

1 Answer 1

1

To access JavaScript functions from your ActionScript class you can make use of the ExternalInterface method.

On the HTML page where your SWF is embedded, you will have to include the custom JavaScript functions you want to access from your SWF. With the help of the ExternalInterface method you can access any declared JavaScript function.

In your case, just wrap the stop , play and pause function of the music player in a custom JavaScript function (which you can then address from the SWF) or call the native stop, play and pause function directly. I prefer to create a wrapper class so that your code is understandable for any third party.

The principle is very easy to implement, just read through this link and you will be on your way!

Sign up to request clarification or add additional context in comments.

2 Comments

thanks i prefer js of this swf and found those methods now its working.. when i stop the music and then play, the whole file loads again. can you know the reason for this..
Maybe you could try to use the pause function instead of the stop function? So when the user presses play, the song just resumes from it's paused position?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.