Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Getting file parameter from a url link


Im trying to get jwplayer 6 to get its file parameter from a url link. This was possible with older version of the player but I cannot get it to work with jwplayer6.

The code that worked for the older player is as follows:

bc.. <html>
<head>
<title></title>
<style type="text/css">
#wrapper1 { position:absolute; left:64px; top:128px; width:320px; height:21px; background-color:#CCCC00; }
</style>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">

function deletePlayer(theWrapper, thePlaceholder, thePlayerId) {
swfobject.removeSWF(thePlayerId);
var tmp=document.getElementById(theWrapper);
if (tmp) { tmp.innerHTML = "<div id='" + thePlaceholder + "'></div>"; }
}

function createPlayer(thePlaceholder, thePlayerId, theWidth, theHeight, theFile, theImage, theLink, theLogo, theAutostart) {
var flashvars = {
config:"",
author:"",
captions:"",
description:"",
duration:"0",
file:theFile,
image:theImage,
link:theLink,
start:"0",
title:"",
type:"",

controlbar:"bottom",
logo:theLogo,
playlist:"none",
playlistsize:"180",
skin:"",

autostart:theAutostart,
bufferlength:"1",
displayclick:"play",
item:"0",
mute:"false",
quality:"true",
repeat:"none",
shuffle:"false",
stretching:"uniform",
volume:"90",

abouttext:"",
aboutlink:"",
linktarget:"_blank",
streamer:"",
tracecall:""
}
var params = {
allowfullscreen:"true",
allowscriptaccess:"always"
}
var attributes = {
id:thePlayerId,
name:thePlayerId
}
swfobject.embedSWF("player.swf", thePlaceholder, theWidth, theHeight, "9.0.115", false, flashvars, params, attributes);
}


function initPlayer(theFile, theImage, theLogo, theAutostart) {
deletePlayer('wrapper1', 'placeholder1', 'player1');
createPlayer('placeholder1', 'player1',
'320', '21',
theFile,
theImage,
'http://www.domain.com',
theLogo,
theAutostart)
}
</script>
<head>
<body onload="initPlayer('http://domain.com/files/test1.mp3', '','', false);">

<div id="wrapper1">
<div id="placeholder1"></div>
</div>

<a href="javascript:initPlayer('http://domain.com/files/test1.mp3', '', '', true);">Play audio 1</a><br>
<a href="javascript:initPlayer('http://domain.com/files/test2.mp3', '', '', true);">Play audio 2</a><br>
<a href="javascript:initPlayer('http://domain.com/files/test3.mp3', '', '', true);">Play audio 3</a><br>
</body>
</html>



Does anyone know how to get it to work in the same way with jwplayer6 using html5 instead of flash?

Thanks
BB

Thanks

8 Community Answers

Ethan Feldman

JW Player Support Agent  
0 rated :

Do you have a link to where this is running?

JW Player

User  
0 rated :

Yes, if you go to http://bbloqx.com/test/ you will see two examples.

In the first example, each link when clicked upon will play the sound file in the flash player.

In the second example, the link will take you to a new page where the audio file automatically play.

I'm trying to do both with version 6. Replacing the swf and js files with those of Version 6 doesnt seem to work :(

Ethan Feldman

JW Player Support Agent  
0 rated :

This is player 4.2.

If you are using JW6 you can only use the JW Embedder and a lot of variables changed – http://www.longtailvideo.com/support/jw-player/28834/migrating-from-jw5-to-jw6

JW Player

User  
0 rated :

Thanks Ethan for your reply.

Yes I am aware that the player is an older version.

My question is "CAN" the same functionality be done with v6.

And if so, how?

If it cannot be done with v6, I like to know that also. Thanks again.

Ethan Feldman

JW Player Support Agent  
0 rated :

You can, but it would have to use our new API, since the example here is older. New api reference / examples (on the left nav) – http://www.longtailvideo.com/support/jw-player/28851/javascript-api-reference

JW Player

User  
0 rated :

I checked out the examples and they all look like the files that are being played are hard coded. I didn't find a single example of the file parameter taken from a url link.

Thanks for all your replies, but with my limited knowledge of jwplayer, I'm not much farther than when I first began my search for a solution.

I'm curious as to how to implement this v6, at the moment, the new API is over my head.

JW Player

User  
0 rated :

SOLUTION FOUND:

For anyone else looking to get this to work with v6 here is what a friend of mine came up with:

bc.. <!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jwplayer.js"></script>
<script type="text/javascript">

function deletePlayer(theWrapper, thePlaceholder, thePlayerId) {
var tmp=document.getElementById(theWrapper);
if (tmp) { tmp.innerHTML = "<div id='" + thePlaceholder + "'></div>"; }
}

function createPlayer(thePlaceholder, thePlayerId, theWidth, theHeight, theFile, theImage, theLink, theLogo, theAutostart) {
jwplayer(thePlaceholder).setup({
file: theFile,
height: theHeight,
image: theImage,
width: theWidth,
bufferlength:"1",
displayclick:"play",
item:"0",
mute:"false",
quality:"true",
repeat:"false",
shuffle:"false",
stretching:"uniform",
volume:"90",
allowfullscreen:"false",
allowscriptaccess:"always",
autostart: theAutostart,
id:thePlayerId,
name:thePlayerId
});

}

function initPlayer(theFile, theImage, theLogo, theAutostart) {
deletePlayer('wrapper1', 'placeholder1', 'player1');
createPlayer('placeholder1', 'player1',
'320', '30',
theFile,
theImage,
'http://www.domain.com',
theLogo,
theAutostart)
}
</script>
</head>
<body>

<a href="javascript:initPlayer('http://domain.com/files/audiofile1.mp3', '', '', true);">Play audio 1</a><br>
<a href="javascript:initPlayer('http://domain.com/files/audiofile2.mp3', '', '', true);">Play audio 2</a><br>
<a href="javascript:initPlayer('http://domain.com/files/audiofile3.mp3', '', '', true);">Play audio 3</a><br>


<div id="wrapper1">
<div id="placeholder1"></div>
</div>

<h3>Example 2</h3>
<a href="/test2.html?http://domain.com/files/audio-file.mp3">Audio Link</a><br>

</body>



The code in Example 2 for the test2.html is as follows:
bc.. <!DOCTYPE html>
<html>
<head>
<title>JW API Example 3-2-2-0 - JW FLV Media Player</title>

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

function createPlayer(thePlaceholder, thePlayerId, theFile) {
var flashvars = {
file:theFile,
autostart:"true"
}
var params = {
allowfullscreen:"true",
allowscriptaccess:"always"
}
var attributes = {
id:thePlayerId,
name:thePlayerId
}
jwplayer(thePlaceholder).setup({
file: theFile,
height: 30,
bufferlength:"1",
displayclick:"play",
item:"0",
mute:"false",
quality:"true",
repeat:"false",
shuffle:"false",
stretching:"uniform",
volume:"90",
allowfullscreen:"false",
allowscriptaccess:"always",
autostart: "true",
id:thePlayerId,
name:thePlayerId
});

}


function initPlayer() {
createPlayer('placeholder1', 'player1', location.search.substring(1));
}
</script>
<head>
<body onload="initPlayer();">
<div id="wrapper">
<div id="placeholder1"></div>
</div>
</body>
</html>

Ethan Feldman

JW Player Support Agent  
0 rated :

Nice, thanks for sharing this.

This question has received the maximum number of answers.