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

Streaming Issue with AWS CloudFront Signed URL using JW Player


We are trying to "Streaming Videos with AWS CloudFront Signed URL using JW Player".

We want to send all 3 components using Signed URL from S3.

1. Web Distribution signed URL for JWplayer.js & JWPlayer.flash.swf
2. RTMP Distribution signed URL for Vedio

The issue is we are not able to use HTTPs for "JWplayer.swf".

My Code

<?php
require 'aws\aws-autoloader.php';

use Aws\CloudFront\CloudFrontClient;

$cloudFront = CloudFrontClient::factory(array(
'region' => 'ap-southeast-1',
'version' => 'latest',
'signature' => 'v4'
));
?>

<HTML>
<HEAD>
<TITLE>Amazon CloudFront Streaming with JW Player 7</TITLE>

<!-- Call the JW Player JavaScript file, jwplayer.js.
Replace WEB-DISTRIBUTION-DOMAIN-NAME with the domain name of your
CloudFront web distribution, for example, d1234.cloudfront.net
(begins with "d"). This causes a browser to download the JW Player file
before streaming begins.

Replace LICENSE-KEY with your personal license key from JW Player.
-->
<?php
// Setup parameter values for the resource
$streamHostUrl = 'https://d1sivyajtbys6c.cloudfront.net';
//$streamHostUrl = 'http://s2zk7q605bvsrp.cloudfront.net';
$resourceKey = 'jwplayer/jwplayer.js';
$expires = time() + 4900;

// Create a signed URL for the resource using the canned policy
$signedUrlCannedPolicy = $cloudFront->getSignedUrl([
'url' => $streamHostUrl . '/' . $resourceKey,
'expires' => $expires ,
'private_key' => 'pk-APKAJJ33A2UBDR5POKSQ.pem',
'key_pair_id' => 'APKAJJ33A2UBDR5POKSQ',
]);
// echo "JW player:", $signedUrlCannedPolicy;
?>

<script type='text/javascript' src='<?php echo $signedUrlCannedPolicy ?>'></script>

<script>jwplayer.key="7bKLKjNkvAcDxuxPNdzcqO5p4L0EE33I+xpTmQ==";</script>

</HEAD>

<BODY>
<H1>This video is streamed by CloudFront and played by JW Player 7.</H1>

<!-- Replace RTMP-DISTRIBUTION-DOMAIN-NAME with the domain name of your
RTMP distribution, for example, s5678.cloudfront.net (begins with "s").

Replace VIDEO-FILE-NAME with the name of your .mp4 or .flv video file,
including the .mp4 or .flv filename extension. For example, if you uploaded
my-vacation.mp4, enter my-vacation.mp4. You might need to prepend "mp4:" to the
name of your video file, for example, mp4:my-vacation.mp4.

If the file is in a subdirectory, include the subdirectory name just before
the file name, for example:

"rtmp://RTMP-DISTRIBUTION-DOMAIN-NAME/cfx/st/sample-directory/VIDEO-FILE-NAME"
-->


<div id="my-video"></div>
<script type="text/javascript">
jwplayer("my-video").setup({
<?php
// Setup parameter values for the resource
$streamHostUrl = 'http://d1sivyajtbys6c.cloudfront.net';
//$streamHostUrl = 'http://s2zk7q605bvsrp.cloudfront.net';
$resourceKey = 'jwplayer/jwplayer.flash.swf';
$expires = time() + 4900;

// Create a signed URL for the resource using the canned policy
$signedUrlCannedPolicy = $cloudFront->getSignedUrl([
'url' => $streamHostUrl . '/' . $resourceKey,
'expires' => $expires ,
'private_key' => 'pk-APKAJJ33A2UBDR5POKSQ.pem',
'key_pair_id' => 'APKAJJ33A2UBDR5POKSQ',
]);
// echo "JW player SWF:", $signedUrlCannedPolicy;
?>
flashplayer: '<?php echo $signedUrlCannedPolicy ?>',
<?php
$streamHostUrl = 'rtmp://s2vxaccai8mlic.cloudfront.net';

$resourceKey = 'your_movie.mp4';
$expires = time() + 4900;

// Create a signed URL for the resource using the canned policy
$signedUrlCannedPolicy = $cloudFront->getSignedUrl([
'url' => $streamHostUrl . '/' . $resourceKey,
'expires' => $expires,
'private_key' => 'pk-APKAJJ33A2UBDR5POKSQ.pem',
'key_pair_id' => 'APKAJJ33A2UBDR5POKSQ',
]);
// echo "Cavs file:", $signedUrlCannedPolicy;
?>
file: "<?= $streamHostUrl ?>/cfx/st/<?= $signedUrlCannedPolicy ?>",

width: "720",
primary: "flash",
height: "480"
});
</script>

</BODY>
</HTML>

3 Community Answers

Alex

JW Player Support Agent  
0 rated :

Hi there,

Are you saying that you need to be able to call jwplayer.flash.swf via HTTPS or you cannot and need to call it via HTTP?

Please let me know.

h...

User  
0 rated :

HI Alex,

I need to call "jwplayer.flash.swf" vai HTTPS Cloudfront Signed URL.

Alex

JW Player Support Agent  
0 rated :

This is not something that I am sure you would be able to do as it is not built-in functionality of the player or something that we provide support for. If you have not tried it already, I would suggest trying to use the flashplayer configuration option to set an alternate path for jwplayer.flash.swf to see if that works.

Thank you.

This question has received the maximum number of answers.