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

Forums

/

Pause button javascript function, Need Help....

22 replies [Last post]

Hello,

I am new to coding and have been playing around with the media player and saw that it was possible to use javascript to stop / play the selected video.

I copied the entire page from the javascript example and when I try it live, there is no luck.

You can see the page at:

http://www.sumoyo.com/-sfghtog.htm

Would like to also know if you can a mouse over the link to pause?

Appreciate any help.

you need to upload the mediaplayer.swf and swfobject.js as well as the playlist to your own site along with sfghtog.htm -
(and change the paths in the page accordingly)
you cannot control a player from another site with the javascript api for flash security reasons!

Hi Andersen,

Thanks for the help and that's why you guys are the experts.

Also wanted to know what would be the only Javascript I would need to keep on this page to have the pauseplay function still work?

heres code for a full page with only a play/pause button

<html>
<head>
<script type="text/javascript" src="swfobject.js"></script>

<script type="text/javascript">

function sendEvent(typ,prm) { thisMovie("mpl").sendEvent(typ,prm); };

function thisMovie(movieName) {
if(navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName];
} else {
return document[movieName];
}
};
</script>
</head>
<body>
<div id="player"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash</a> to see this  Player.</div>
<script type="text/javascript">
var s1 = new SWFObject('mediaplayer.swf','mpl','320','320','8');
s1.addParam("allowfullscreen","true");
s1.addVariable("file","<strong>playlist.xml</strong>");
s1.addVariable("enablejs","true");
s1.addVariable("javascriptid","mpl");
s1.addVariable("width","320");
s1.addVariable("height","320");
s1.addVariable("displayheight","240");
s1.write('player');
</script>
<a href="javascript:sendEvent('playpause')">Toggle the pause state</a>.
</body>
</html>

Hi Andersen,

This all works great, thank you for your help.

A few additional questions.

Is it possible to have this function only perform a pause function? If so how?

Also if we wanted to set this up as embedded code what would our string need to look like to include the javascript functions?

Greatly appreciate all of your guidance.

try use the stop command instead: <a href="javascript:sendEvent('stop')">Stop loading and playing</a> please also checkout the [url=http://www.jeroenwijering.com/extras/wizard.html]wizard[/url]

ıopıopıo

I just use:

my_ns.pause();

inside a function using my moviclip name for the interaction. I know that this isn't javascript, but it works if you have access to the actionscript code of the player.

...forgot to mention that this uses the netstream object, where "my_ns" is the name of the netstream.

What am i doing wrong here? http://lynnkerewchiropractic.com/test.html

You are using swfobject 1.5 on your site - http://www.lynnkerewchiropractic.com/player/swfobject.js, but your code is formatted for swfobject 2.0, if you change your version to 2.0, it will work.

Hi everyone,

I'm struggling to get the pause link working - I'm using the original skin, here is my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JW Custom Skin</title>
<script type='text/javascript' src='swfobject.js'></script>
</head>

<body>
<div id='player'></div>
<script type='text/javascript'>
var s1 = new SWFObject('player.swf','player','400','300','9');
s1.addParam('allowfullscreen','true');
s1.addParam('allowscriptaccess','always');
s1.addParam('flashvars','file=video.flv&autostart=true');
s1.addVariable("enablejs","true");
s1.addVariable("javascriptid","player");
s1.write('player');
</script>
<a href="javascript:sendEvent('playpause')">Toggle the pause state</a>.
</body>
</html>

I'm using swf object 1.5 as when I try to use 2.2 - the video failed to show. I'd really appreciate any advice, cheers.

 
@Garry,

What version of the JW Player are ou using?

The code that you posted is for the v3 player and is also incomplete.

Version 5 - the latest download - where can I find the latest swfobject code to accompany this?

 
swfobject only creates an object element to embed Flash content.

You can use swfobject v1.5 or v2.2 with the JW Players and Image Rotators.

The format of the code that you posted above is for swfobject v1.5.

Search the Forum for examples of swfobject v2.2 code.

swfobject v2.2 is hosted on Google Code.

Here is example swfobject 2 code:

<html>
<head>

<title>SWF 2</title>

<script type="text/javascript" src="swfobject20.js"></script>

<script type="text/javascript">
var flashvars = {
  width: "700",
  height: "450",
  file: "video.flv"
};
var params = {
  allowfullscreen: "true",
  wmode: "transparent",
  allowscriptaccess: "true"
};
var attributes = {
  id: "longtail",
  name: "longtail"
};
swfobject.embedSWF("player.swf", "playerspace", "700", "450", "9.0.0",
"expressInstall.swf", flashvars, params, attributes);
</script>
</head>

<body >

<div id='playerspace' name='playerspace'></div>

</body>
</html>

Thanks for the code, I have the video working - however, the code for the pause/stop button doesn't seem to work. I've tried both

<a href="javascript:sendEvent('playpause')">Toggle the pause state</a>

<a href="javascript:sendEvent('stop')">Stop loading and playing</a>

 
See the JSAPI documentation for the v4/v5 players here:

    http://developer.longtailvideo.com/trac/wiki/Player4Events#Viewevents

If you are using a v4/v5 player:

<a href="#" onclick="document.getElementById('longtail').sendEvent('STOP')">STOP loading and playing</a>
<a href="#" onclick="document.getElementById('longtail').sendEvent('PLAY', 'false')">PAUSE</a>
<a href="#" onclick="document.getElementById('longtail').sendEvent('PLAY', 'true')">PLAY</a>

Thanks very much everyone

 
You're welcome.

Glad we could help you.

Hi,
I am using JW Player in my application.When i click PLAY Button in JW Player i want to call user defined function in .JS page.....
Can any one pls provide some code or idea to do this task.....Ur thoughts....

Pranesh -

Do not post on multiple threads. Please post on a new thread and we will respond.