Jump to content

Secure HTML5 Playback Area


emamuc

Recommended Posts

Hi Everyone,

 

I'm developing a session secured area for video playback. The videofiles shall be served by php to control the sessions.

This is my markup:

 

{foreach from=$res item=r}
<div class="title">{$r.name|stripslashes}</div>

	<video id="player" class="projekktor" title="{$r.name|stripslashes}" width="480" height="270" controls>
	<source src="get_video?id={$r.id}&type=mp4" type="video/mp4" />
	</video>

<div class="description">{$r.desc|stripslashes}</div>
{/foreach}

 

The source

<source src="get_video?id={$r.id}&type=mp4" type="video/mp4" />

is played well, when loaded directly in a browser, but the movie isn't loaded when I specify the script as source to the video-tag.

 

This is the relevant part in my get_video.php:

 

$con =  mysql_connect($dbhost,$dbuser,$dbpass);
  @mysql_select_db($db) or die( "Unable to select database");

  	$vid = mysql_real_escape_string($_GET['id']);
	$type = mysql_real_escape_string($_GET['type']);


 $result = mysql_query('SELECT path, filename FROM `videos` where `id`="'.$vid.'"');
  if ($result)
  {

 	while ($res = mysql_fetch_array($result)){
	$path = $res['path'];
	$file = $res['filename'];



}

$extensions = array('mp4','ogv','webm');
	  
if(in_array($type,$extensions)){
$file = $path.$file.".".$type;

if (is_file($file)) {


if (isset($_SERVER['HTTP_RANGE']))  { 

	header("Content-type: video/".$type);
	rangeDownload($file);

}
else { 
		$file_size = (string)(filesize($file));
		header('Content-Type: video/'.$type);
		header('Content-Length: '.$file_size);

		readfile($file);
		exit();
}

 

I tried several HTML5 Players and the generic video tag. None of it want to work.

 

Does anyone have a suggestion?

 

Thank you very much!

Link to comment
https://forums.phpfreaks.com/topic/242236-secure-html5-playback-area/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.