Jun. 24, 2009Bk
Hi,
Upon refreshing the page in IE the video doesn't play anymore but just plays the audio. It works fine in Firefox and if you embed it directly. Below is the code I am using:
<script type="text/javascript" src="/lib/swf_player/swfobject.js"></script>
<script type="text/javascript">
function createPlayer(thePlayer, theFile) {
var flashvars = {
file:theFile,
autostart:"true",
controlbar:"none"
}
var params = {
allowfullscreen:"true",
allowscriptaccess:"always"
}
var attributes = {
id:thePlayer,
name:thePlayer
}
swfobject.embedSWF("player.swf", "placeholder1", "250", "150", "9.0.115", false, flashvars, params, attributes);
}
</script>
<body bgcolor="#DDDDDD" onload="createPlayer('player1', 'get_healthy.flv')">
<div style="margin-top: -180px; margin-right: 165px; float: right;"><h3><a href="http://www.gethealthynsw.com.au/">Get Healthy</a></h3></div>
<div class="clear-hidden"></div>
<div style="margin-top: -160px; float: right; border: 2px solid #336699;">
<div id="placeholder1">
<a href="http://www.adobe.com/go/getflashplayer">Get flash</a> to see this player
</div>
</div>
</body>
I am clueless!!
Jun. 24, 2009lost
<script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js"></script>
<script type="text/javascript">
var flashvars =
{
file: 'get_healthy.flv',
autostart: 'true'
id: 'player1',
controlbar: 'none',
autostart: 'true'
};
var params =
{
allowfullscreen: 'true',
allowscriptaccess: 'always'
};
var attributes =
{
id: 'player1',
name: 'player1'
};
swfobject.embedSWF('player.swf', 'placeholder1', '250', '150', '9.0.124', false, flashvars, params, attributes);
</script>
</head>
<body bgcolor="#DDDDDD">
Let swfobject monitor the DOM loading and determine when to write the object element for embedding the player.
Jun. 29, 2009Bk
How do I use JS controls then? Plus this doesn't work anyway
Jun. 29, 2009lost
Fixed:
<script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js"></script>
<script type="text/javascript">
var flashvars =
{
file: 'get_healthy.flv',
id: 'player1',
controlbar: 'none',
id: 'player1',
autostart: 'true'
};
var params =
{
allowfullscreen: 'true',
allowscriptaccess: 'always'
};
var attributes =
{
id: 'player1',
name: 'player1'
};
swfobject.embedSWF('player.swf', 'placeholder1', '250', '150', '9.0.124', false, flashvars, params, attributes);
</script>
</head>
<body bgcolor="#DDDDDD">
"How do I use JS controls then?"
What do you mean by this? You didn't have any JavaScript API code in the code that you posted above.
Jun. 30, 2009Bk
This is what I want to do.
<head>
<script src="/lib/swf_player/swfobject.js"></script>
<script type="text/javascript">
var player = null;
function playerReady(thePlayer)
{
player = window.document[thePlayer.id];
};
function createPlayer()
{
var flashvars =
{
file: "/lib/swf_player/get_healthy.flv",
autostart:"true",
controlbar:"none"
};
var params =
{
allowfullscreen:"true",
allowscriptaccess:"always"
};
var attributes =
{
id:"player1",
name:"player1"
};
swfobject.embedSWF("/lib/swf_player/player.swf", "placeholder1", "250", "150", "9.0.124", false, flashvars, params, attributes);
}
</script>
</head>
<body onload="createPlayer();">
<table>
<tr>
<td>
<div id="placeholder1">
<a href="http://www.adobe.com/go/getflashplayer">Get flash</a> to see this player
</div>
</td>
<td>
<li><a href="#" onclick="player.sendEvent('VOLUME', 50)">UnMute</a></li>
<li><a href="#" onclick="player.sendEvent('MUTE')">Mute</a></li>
</td>
</tr>
</table>
</body>
So if I put ID tags in Flashvars would it be alrite?
Jun. 30, 2009Bk
Sorry let me be a bit clear. If I don't have the createplayer() on onload(), how do I set the mute etc from the outside? Right now, I have a onClick event that mutes the player. Thanks.
Jun. 30, 2009lost
To use the JavaScript API, you only need to set the name & id attributes and the id flashvar, which is in the code that I posted.
To simplify things a bit, you can get the player reference object once, then re-use it. I added the code in bold to do this.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>BK - JWMP v4.5.x - swfobject v2.1</title>
<script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js"></script>
<script type="text/javascript">
var player;
function playerReady(obj)
{
player = document.getElementById(obj.id);
};
var flashvars =
{
file: 'get_healthy.flv',
id: 'player1',
controlbar: 'none',
id: 'player1',
autostart: 'true'
};
var params =
{
allowfullscreen: 'true',
allowscriptaccess: 'always'
};
var attributes =
{
id: 'player1',
name: 'player1'
};
swfobject.embedSWF('player.swf', 'placeholder1', '250', '150', '9.0.124', false, flashvars, params, attributes);
</script>
</head>
<body>
<table>
<tr>
<td>
<!-- keep the next line all on one line so you don't end up with a 5px margin below the player -->
<div id="placeholdercontainer1"><a id="placeholder1" href="http://www.adobe.com/go/getflashplayer">Get flash to see this player.</a></div>
</td>
<td>
<li><a href="#" onclick="player.sendEvent('VOLUME', 50); return false;">UnMute</a></li>
<li><a href="#" onclick="player.sendEvent('MUTE'); return false">Mute</a></li>
</td>
</tr>
</table>
</body>
</html>
It's highly recommended that you load swfobject v2.1 from Google's CDN for the following reasons:
Loading from Google AJAX Libraries API
http://pipwerks.com/journal/2008/11/11/swfobjectjs-finds-a-home-on-google-servers/
How & Why You Should Use Google CDN
http://webmuch.com/how-why-you-should-use-google-cdn/
Jul. 01, 2009Bk
<head>
<script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js"></script>
<script type="text/javascript">
var player = null;
function playerReady(thePlayer)
{
player = document.getElementById(thePlayer.id);
};
var flashvars =
{
file: "/lib/swf_player/get_healthy.flv",
id:"player1",
controlbar:"none",
id:"player1",
autostart:"true"
};
var params =
{
allowfullscreen:"true",
allowscriptaccess:"always"
};
var attributes =
{
id:"player1",
name:"player1"
};
swfobject.embedSWF("/lib/swf_player/player.swf", "placeholder1", "250", "150", "9.0.124", false, flashvars, params, attributes);
</script>
</head>
<body>
<table>
<tr>
<td>
<div id="placeholdercontainer1"><a id="placeholder1" href="http://www.adobe.com/go/getflashplayer">Get flash to see this player</a></div>
</td>
<td>
<a href="#" onclick="player.sendEvent('VOLUME', 50); return false;">Unmute</a>
<a href="#" onclick="player.sendEvent('MUTE'); return false;">Mute</a>
</td>
</tr>
</table>
</body>
This is what I did and still the refreshing in IE draws a blank when you do it the 2nd time !!!!!!
I use this script as an include in my page, dunno if that changes anything. Any ideas?? This is really frustrating
Jul. 01, 2009lost
Unfortunately, I can't reproduce this issue. It's probably dependent on a particular version of IE7, a particular version of the Adobe Flash Player, and the phase of the moon.
Here are some other things that you can try:
1) use swfobject v2.2<script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
2) try a different release of the JW FLV Player from here: http://developer.longtailvideo.com/trac/log/trunk/as3/player.swf
Click on the release that you want in the Rev column,
3) specify a valid DOCTYPE (the first line in the code that I posted above),
4) KICK IT! (often works when all else fails).
Jul. 01, 2009Bk
hehe...but I figured out a way to fix it though...I am using the latest swf (as3, I think) and tried the date time hack when embedding and it works!!
swfobject.embedSWF('player.swf'+ cacheHack(), 'placeholder1', '250', '150', '9.0.124', false, flashvars, params, attributes);
function cacheHack()
{
return "?t=" +new Date().getTime();
}
Thanks for your help anyway
Jul. 01, 2009lost
Looks like you've kicked a goal!
Here are some helpful links to learn more about the JW Player™:
Earn money with ads from LongTail's AdSolution. Watch our demos and sign up now!
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.