Jump to content

Playing/Streaming files


alco19357

Recommended Posts

I have a system that reads a file (.dat) and will render it as an wmv. Code below:

function download($VAR)
{
	$db     = &DB();
	$sql    = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'file WHERE
				site_id     = ' . DEFAULT_SITE . ' AND
				id          = ' . $db->qstr(@$VAR['id']) . ' AND
				status      = 1';
	$result = $db->Execute($sql);

	if($result->RecordCount() == 1)
	{
		$show = true;

		### Validate start date
		$s = $result->fields['date_start']; 
		if($s != '' && $s != 0)
			if($s > time())
				$show = false; 

		### Validate expire date	
		$e = $result->fields['date_expire'];
		if($e != '' && $e != 0)
			if($e < time())
				$show = false;           					

		### Validate user group: 
		if($show) {
			global $C_auth;
			@$arr = unserialize($result->fields['group_avail']);
			$show = false; 
			for($i=0; $i<count($arr); $i++) {
				if($C_auth->auth_group_by_id($arr[$i]))  {
					$show = true;		
					break;
				}
			}                
		} 

		### Get the filetype
		if($show) 
		{
			$ft = $result->fields['location_type'];
			if($ft == 0)
				$file = PATH_FILES . 'file_'.$VAR['id'].'.dat';
			elseif ($ft == 1)
				$file = $result->fields['location'];
			elseif ($ft == 2)
				$file = $result->fields['location'];

			### Open the file
			if (@$file=fopen($file, 'r'))
			{  
				### Display the correct headers:
				header ("Content-Type: " . $result->fields['type']);
				header ("Content-Size: " . $result->fields['size']);
				header ("Content-Disposition: inline; filename=mylbpr.wmv"); 
				header ("Content-Length: " . $result->fields['size']); 
					  
				fpassthru($file);
				exit;          
			}
		}
	}
	echo 'Sorry, the file does not exist or you are not authorized or your access has expired!';
}

 

When I play the page in Internet Explorer, it works with both attachment and inline as my disposition. However, in Firefox, it only works when the disposition is attachment. I can't get the file to play inline, nor can I get the file to play as an embed. Please help. Thank you!!

Alex

this is from the Agile Billing software

Link to comment
https://forums.phpfreaks.com/topic/163536-playingstreaming-files/
Share on other sites

also, i'm using firefox with the Microsoft Windows Media Player Firefox Plugin enabled. When i disable the plugin, and try, it does downloads the wmv to my local and it works from there. Does anyone know if there are settings i have to change in the plugin or is there another plugin for vista out there?

 

Thank you!

Alex

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.