Secure Token Plugin with PHP


Hits: 5139  

You might read our old article on how-to-prevent-downloading-and-leeching-media-files

You can review below code to secure your media files to be downloaded other then media players 😉

Creating a Secure Token SWF for JW Player

Secure Token have time limit after that token expire to get media files.

var timestamp = +new Date();

flowplayer("player", "http://www.svnlabs.com/token/player/flowplayer-3.2.7.swf", {
plugins: {
    secure: {
        url: 'player/flowplayer.securestreaming-3.2.3.swf',

        timestamp: timestamp,

        token: '69964920064c0a7626e6c97997070fcd'
    }
},

clip: {
    autoPlay: false,
    autoBuffering: true,
    duration: 30,
    urlResolvers: 'secure',
    baseUrl: 'http://www.svnlabs.com/token/'
}
});
<?php
// Get the file from the server
function get_file(){
global$streamname;
header('Content-Description: File Transfer');
header('Content-type: video/mp4');
header("Content-length: ".filesize($streamname));
header("Expires: 0");
header("Content-Transfer-Encoding: binary");
$file=fopen($streamname,'r');
echostream_get_contents($file);
fclose($file);
exit;
}
// Return secret to flowplayer for use
function get_secret(){
$token='69964920064c0a7626e6c97997070fcd';
return$token;
}
?>

Published by

Sandeep Verma

I’m an Entrepreneur. I’m proud to work as Blogger, LAMP Programmer, Linux Admin, Web Consultant, Cloud Manager, Apps Developer, Searcher. Concentrate > Observe > Imagine > Launch