Hi,
I am trying to add support for ranges to my download scripts, so users downloading from my site with eg download managers they have the option for multiple connections/resume.
I have gone so far that this works perfect in normal situations, but not when streaming a file eg "wmv" ,
it seems mediaplayer or other players request ranges differently than download managers , so the effect is that you can not move forward along the movie being played before it is completely downloaded not even to the already downloaded segments.
this is as far as I have gone for normal downloads :
[PHP]$name = $filever['filename'];
$size = $filever['filesize'];
$type = $filever['filetype'];
$disposition = 'inline';
header("Cache-Control:");
header("Cache-Control: public");
Header("Content-Type: $type");
if (strstr($_SERVE R['HTTP_USER_AGEN T'], "MSIE")) {
$iefilename = preg_replace('/\./', '%2e', $name, substr_count($n ame, '.') - 1);
header("Content-Disposition: $disposition; filename=\"$ief ilename\"");
} else {
header("Content-Disposition: $disposition; filename=\"$nam e\"");
}
header("Accept-Ranges: bytes");
if(isset($_SERV ER['HTTP_RANGE'])) {
list($a, $range)=explode ("=",$_SERVE R['HTTP_RANGE']);
str_replace($ra nge, "-", $range);
$size2=$size-1;
$new_length=$si ze-$range;
header("HTTP/1.1 206 Partial Content");
header("Content-Length: $new_length");
header("Content-Range: bytes $range$size2/$size");
} else {
$size2=$size-1;
header("Content-Range: bytes 0-$size2/$size");
header("Content-Length: ".$size);
}
$fp=fopen($file _path,"rb");
while(!feof($fp )){
set_time_limit( 0);
print(fread($fp ,1024*8));
flush();
ob_flush();
}
fclose($fp);
exit;[/PHP]
8 2092 pbmods 5,821
Recognized Expert Expert
Changed thread title to better describe the problem, and hopefully get your thread some extra traffic :)
thanx, any help is really appreciated.
anybody has any ideas how to do MultiMedia streaming support in PHP,
this is something great and important in PHP which I haven't found anything on it.
any ideas?
pbmods 5,821
Recognized Expert Expert
Heya, Hunter.
I wonder if this represents a deficiency in the media player itself.
I don't know,
I remember when I was working on it,
I noticed as download managers request a range (where to start next) in this format:
"bytes=1111 111-"
Mediaplayer and other players send request like :
"bytes=1111 111-2222222"
I have been wondering how to evaluate that request and send an appropriate response, but so far, no success.
pbmods 5,821
Recognized Expert Expert
Heya, Hunter.
Figure something like this: -
preg_match_all('/bytes=(\\d+)(-(\\d+))?/', $_SERVER['HTTP_RANGE'], $matches);
-
$range_start = $matches[1];
-
$range_end = $matches[3]; // Might be null if no terminating range was specified.
-
thanx,
I am gonna try this one too,
but I think the problem is, as they send a different request, they also expect a different response,
I am working on it, but I don't know.
pbmods 5,821
Recognized Expert Expert
Oh boy.
Well, good luck, and keep us posted!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Markus Ernst |
last post by:
Hi
I know this question is rather HTTP related than PHP, but I did not find an
HTTP group on my news server.
I deliver some files with the following PHP syntax:
header('Content-Description: File Transfer');
header('Content-Type: '.$mimetype);
header('Content-Length: '.filesize($file));
|
by: Philipp Lenssen |
last post by:
I have a password-protected website with downloads. The
password-protection needed its own login-screen, so I use a
session-object. It works well but now I also want the downloads (PDFs
and Word-Documents) to check if the user is logged-in. When I stream
PDFs, all works well. When I stream DOCs, the Word-File seems broken
when I open it -- a lot of strange characters, some authors
information, and so on.
Can anybody help me?
|
by: Ron Gibson |
last post by:
Lets say I have a folder
members/3/
in this folder are images
I have a login page that connects to a database to retrieve user info.
After login the user is directed to a page that lists the files in the above
directory. Now lets say some other user goes to the directory and types in
members/3/image1.jpg he/she will now see the image. How can I stop this
|
by: the friendly display name |
last post by:
Following problem:
I want to stream a file to the client, but the logic takes too much CPU time
(100% in fact..) this is the code:
public class Download : System.Web.UI.Page
{
|
by: Volte |
last post by:
Hey all. Been looking into this for a while now, got some mock ups and
whatnot. All works well (as far as the server "streaming" the data, via
a sleep and flush method right now just for functionality. Only Ajax
doesnt seem to appreciate it. Still caches the buffer and dumps it out
at once. I was wondering if you guys had any insights on this.
Here is the code.
header("Content-type:
multipart/x-mixed-replace;boundary=endofsection");
| |
by: falloutphil |
last post by:
Hi,
First of all sorry for the double post - this is on the Python page too, but as far as I can see this is an Apache issue now. Mods - feel free to delete the similar titled posts from me on Python, if this is the case (can't seem to do it myself!).
Anyway,
I'm running a CGI script written in python that tars up the photos in user selected directories (via a form). It's running on Apache 1.3.31.1 on Solaris 5.8.
It works well for a...
|
by: =?Utf-8?B?QU9UWCBTYW4gQW50b25pbw==?= |
last post by:
Hi,
I have been using the code (some of it has been removed for simplicity)
below to allow authenticated (using ASP.NET membership database) users to get
a file from their archive area. It seems to work fine, however I noticed
that no web log entry is added when a successful download occurs (normally a
200 HTTP status code, however, if there is an authorization failure, it gets
logged). I have a logging routine that logs a successful...
|
by: Faisal Shafiq |
last post by:
I want to upload a file direct to the Silverlight Streaming Service from a
Web Client such as silverlight application.
As per our product requirement we want to upload a .WMV file directly from
silverlight client to Silverlight streaming service. I tried to user
WebClient and HttpWebRequest for that purpose but, unfortunately I can found
the way to do so. There are some problems with both classes.
1. There is no property of get...
|
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= |
last post by:
This is a follow-up to my post "Silverlight video doesn't work when file is
streamed from handler in ASP.net" at
http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.dotnet.framework.aspnet&mid=e9a38d03-83a8-41fc-8950-5ee60d2a18a5.
I have a web site under .NET 2.0 that renders videos using the Silverlight
media player. When I stream the video file (.wmv) to the browser via a
hard-coded link to the file,...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |