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

Problem embedding video from URL


Hi,

I have a problem embedding JW Player.
I'd want to play a video from a URL, not a direct file url.
The video returned by the server is correctly encoded (it plays fine if I save it on the webserver and point directly to the file) and the mime type is right ("video/mp4").

JW Player gives me the error "Error loading player: No playable sources found".
I tried to add a fake parameter to the url (it seems that JW Player needs the file extension in the url) but than JW Player gives me the error "Error loading media File not found".

The url is like:
http://testserver/site/GetFile.aspx?guid=e9cca5d5-7224-4650-9458-e8f8621db9d5&chset=caddfc97-87d2-47fc-b146-62c7ff935ba4

Any idea?

Here's the javascript code:
bc.. function PlayIt( vid, byline, caption )
{
var ic = document.getElementById( 'image-container' );
var vd = document.getElementById( 'video-container' );
ic.style.display = 'none';
document.getElementById( 'byline' ).innerHTML = byline;
document.getElementById( 'caption' ).innerHTML = caption;

/* setel pideo na */
vd.style.display = 'inherit';
jwplayer.key="MY_PLAYER_KEY";
jwplayer("video-container").setup({
file: encodeURIComponent(vid+"&etx=.mp4"),
width: "100%",
aspectratio: "16:9",
responsive: "yes",
autostart: true
});
}



Many thanks

13 Community Answers

JW Player

User  
0 rated :

Just wanted to add that I'm using JW Player version 6.4.3359

Ethan Feldman

JW Player Support Agent  
0 rated :

Set the player’s type variable to mp4.

JW Player

User  
0 rated :

Many thanks for your reply.
I tried to change the function like this (I removed the fake extension and added the "type" variable)
bc.. function PlayIt( vid, byline, caption )
{
var ic = document.getElementById( 'image-container' );
var vd = document.getElementById( 'video-container' );
ic.style.display = 'none';
document.getElementById( 'byline' ).innerHTML = byline;
document.getElementById( 'caption' ).innerHTML = caption;

/* setel pideo na */
vd.style.display = 'inherit';
jwplayer.key="MY_PLAYER_KEY";
jwplayer("video-container").setup({
file: encodeURIComponent(vid),
width: "100%",
aspectratio: "16:9",
responsive: "yes",
autostart: true,
type: "mp4"
});
}


But the player still gives the error "Error loading media: file not found".
The url passed is correct (if I put it in the browser the downloaded file is an mp4 and the mime type is "video/mp4").
What could be the problem?

Thanks again.
P.S: I cannot find in the online documentation the "type" variable.

JW Player

User  
0 rated :

Is it supported by JW Player to play file returned by a php script (or ASP.NET) and not with a direct link to the file?

I made a small test in php and I cannot make it work.
The php function is this:
bc.. <?php
$file = "test.mp4";
if (file_exists($file)){
$name="video.mp4";
$type = "video/mp4";

header('Content-Description: File Transfer');
header("Content-type: $type");
header("Content-Disposition: attachment; filename="$name"");
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));

readfile($file);
}
?>


The player also with an url pointing to this php script gives error "file not found".

Ethan Feldman

JW Player Support Agent  
0 rated :

That should work. Do you have a link?

JW Player

User  
0 rated :

Here's a test page:
http://www.sakya.it/testvideo/testvideo.html

The testvideo.php is the one posted before.
The html is just:
bc.. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> Test video </title>
<script src="http://jwpsrv.com/library/yzsXmuSrEeKG7CIACqoQEQ.js"></script>
</head>

<body>
<div id='video1'></div>
<script type='text/javascript'>
jwplayer('video1').setup({
file: "http://demo.teradp.com/GNWeb/CMSPages/GetFile.aspx?guid=e9cca5d5-7224-4650-9458-e8f8621db9d5&chset=caddfc97-87d2-47fc-b146-62c7ff935ba4",
width: "640",
height: "360",
type: "mp4"
});
</script>
<br/><br/>
<div id='video2'></div>
<script type='text/javascript'>
jwplayer('video2').setup({
file: "http://www.sakya.it/testvideo/testvideo.php?guid=e9cca5d5-7224-4650-9458-e8f8621db9d5&chset=caddfc97-87d2-47fc-b146-62c7ff935ba4",
width: "640",
height: "360",
type: "mp4"
});
</script>

</body>
</html>


I "discovered" something new: the file from the php script is correctly played (I had to remove the endoceUri call), while the one from the ASP.NET (the call to demo.teradp.com) both the response have the correct mime type.
Could it be something wrong with the header?

JW Player

User  
0 rated :

It's surely something in the header because a php script that just reads the file from the url
http://demo.teradp.com/GNWeb/CMSPages/GetFile.aspx?guid=e9cca5d5-7224-4650-9458-e8f8621db9d5&chset=caddfc97-87d2-47fc-b146-62c7ff935ba4

and rewrites it to the output works:
bc.. <?php
$name="video.mp4";
$type = "video/mp4";

header('Content-Description: File Transfer');
header("Content-type: $type");
header("Content-Disposition: attachment; filename="$name"");
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');

$url = "http://demo.teradp.com/GNWeb/CMSPages/GetFile.aspx?guid=e9cca5d5-7224-4650-9458-e8f8621db9d5&chset=caddfc97-87d2-47fc-b146-62c7ff935ba4";
$file = fopen ($url, "rb");
if ($file) {
while(!feof($file)) {
echo fread($file, 1024 * 8);
flush();
}
}
fclose($file);
?>


But I don't know what to look to fix in the header. The only thing I know is that the mime type is correct. :)

Ethan Feldman

JW Player Support Agent  
0 rated :

These videos play fine for me?

JW Player

User  
0 rated :

I made some test and I discovered that the video are played or not depending on the system/browser that it is used.
Probably is something related to HTML5.
If I force the flash version using
bc.. primary: "flash"

it seem to work on every browser.

Without the "flash" variable on Windows 8 x64:
-Opera x64: display only the second video
-Firefox x86: does not display both the videos
-Internet Explorer (both x86 and x64): does not display both the video
-Chrome: does not display both the videos

On Ubuntu x64:
-Opera x64: display both the videos

What os/browser did you use to test the page?

Now I fixed the html with the "flash" variable and the video are playing correctly.

JW Player

User  
0 rated :

....I also noticed only now that the "mp4" file is just a flash video renamed ".mp4"...
Too bad I didn't check the file when I received it.... :(

Ethan Feldman

JW Player Support Agent  
0 rated :

I used FF22, Win7. You should make sure that your server has MIME TYPEs set up as well as setting the player’s type variable.

JW Player

User  
0 rated :

The mime type is correct, it's the file that is wrong.
I recevied the video for testing and didn't check its encoding, my bad!
The file was named mp4 but it was actually a flv renamed mp4.
Without the "primary: flash" variable the player was trying to use html5 (I think) due to the mp4 extension (and variable) and was failing to play it.
Setting the primary flash the video plays fine. I'll test the player with a real mp4 (but I'm sure it will work),

Many thanks for your help. ;)

Ethan Feldman

JW Player Support Agent  
0 rated :

Np :)

This question has received the maximum number of answers.