0

this problem is going to make me bald. Save my hair plz.

i have been trying every possible way to stop and pause and play the JWplayer latest version using its JavaScript API and nothing works.

here is the code:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>JW Player 5 playlist</title>
    <script src="jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript" src="jwplayer.js"></script>
    <script type="text/javascript" src="swfobject.js"></script>



</head>
<body>

<!-- START OF THE PLAYER EMBEDDING TO COPY-PASTE -->
<div id="mediaplayer">JW Player goes here</div>


<script type="text/javascript">
    jwplayer("mediaplayer").setup({
        flashplayer: "player.swf",
        file: "lounge warmup.3gp",
        skin: "simple/simple.zip",
        image: "http://content.bitsontherun.com/thumbs/nPripu9l-480.jpg",
        controlbar: "bottom",
        width: "400",
        height: "8"
    });
</script>
<!-- END OF THE PLAYER EMBEDDING -->
<br>

<a href="#" onclick="jwplayer().stop(); return false;">Stop playback</a>

</body>
</html>

why this is not working??

alhoseany
  • 761
  • 9
  • 28

1 Answers1

2

Your code works for me (after I adjusted the "file" to something I had locally). Some possibilities:

  1. Are you loading this with a "file://" URL, or are you loading it from an actual web server? (If from a file:// URL, there might be Flash security restrictions.)

  2. Do you intend to have a height of 8px as you've currently specified? I don't know what your custom skin looks like. In order to see things using default skin I had to specify a larger height.

  3. I'm not very familiar with JWPlayer, but is it possible the file parameter needs to be URL encoded? (If not sure, maybe trying removing the space from the file name and renaming it on the server as well.)

In any case, your code works for me using default skin and different media file. I can play and then click your "stop" link to stop playback. If ideas above don't help, then you'll need to specify exactly what is not working for you.

kaliatech
  • 17,579
  • 5
  • 72
  • 84
  • all the script works for me except the stop playback link.when i click it, the player don't stop. which version are you using? – alhoseany Jun 27 '11 at 17:05
  • 1
    i found the answer to the problem. i use windows xp and Firefox 5. right click on the flash player->global settings->advanced(tab)-> developer tools ------------------------ specify trusted locations for developer. click on trusted location settings click add... button and navigate to the player.swf you are using with the script. and click ok. now i can manipulate the player with JavaScript on my local machine. i hope this will not be needed for every user visits my website. – alhoseany Jun 27 '11 at 17:20
  • That is due the Flash security restrictions that I mentioned. Flash has different restrictions around javascript interaction depending on how and where it is loaded. The restrictions are most severe when you load the host HTML page directly off your filesystem (by double-clicking on the HTML file in Windows Explorer for example). It's often helpful to run a local webserver and use that to develop and test your page so that the Flash security model is closer to that resulting from production deployment on your website. – kaliatech Jun 27 '11 at 17:40