473,803 Members | 3,410 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Serving local windows media files via PHP

Hi everyone,

I am working on a project where I have .wmv files stored outside of
the server's www root, and want to serve them via a custom web
interface. It's all on windows, and is only intended to work locally
on the physical machine it runs on (don't ask, the customer is
king...).

Right now I have a working prototype in which I use a PHP script
(called movie.php) to serve the target file. In the HTML page, I have
an OBJECT tag that refers to the script, like so:

<OBJECT ID="MediaPlayer " WIDTH="512" HEIGHT="384"
CLASSID="CLSID: 22D6F312-B0F6-11D0-94AB-0080C74C7E95"
STANDBY="Loadin g Windows Media Player components..."
TYPE="applicati on/x-oleobject">
<PARAM NAME="FileName" VALUE="movie.ph p?fileID=12345" >
<PARAM name="ShowContr ols" VALUE="true">
<param name="ShowStatu sBar" value="true">
<PARAM name="ShowDispl ay" VALUE="true">
<PARAM name="autostart " VALUE="true">
<EMBED TYPE="applicati on/x-mplayer2"
SRC="movie.php? fileID=12345"
NAME="MediaPlay er"
WIDTH="512"
HEIGHT="384"
ShowControls="1 "
ShowStatusBar=" 1"
ShowDisplay="1"
autostart="1"
pluginspage="ht tp://www.microsoft.c om/windows/windowsmedia/download/
default.asp">
</EMBED>
</OBJECT>

The movie.php script itself is pretty simple too (stripped down to the
essentials):

<?php

$timeout = 60 * 60 * 24 * 2;
header( 'Cache-Control', 'private, max-age=' . $timeout . '' );
header( 'Pragma', 'private, max-age=' . $timeout . '' );
header( 'Expires', gmdate( 'D, d M Y H:i:s', time() + $timeout ) . '
GMT' );
header( 'Content-Type:video/x-ms-wmv' );
readfile( $file );

?>

This gives me a working player, but the big downside is the player
won't let me skip the clips :(

The seek bar does not respond to any requests to skip ahead, and
pausing the video resets it to the start. Any idea on how I can fix
this so I can skip ahead as much as I wish?

Thanks a lot!
Jul 30 '08 #1
2 1842
Hi,

Seeking usually involves a partial GET request (http://www.w3.org/
Protocols/rfc2616/rfc2616-sec14.html#sec1 4.35).

You could handle the range request in your script and send the byte
range specified in $_SERVER['HTTP_RANGE'] along with appropriate
headers. Example here: http://us2.php.net/manual/en/function.fread.php#84115

Alternatively, you can let Apache send the requested part directly by
using mod_rewrite and a map containing authorized sessions. Good
example here: http://bytes.com/forum/thread10523.html

The first is more flexible in terms of authorization and logging etc.
The second method would have slightly better performance, but I
wouldn't worry about it unless you're handling very high loads.

Regards,

John Peters

On Jul 30, 12:52 pm, AeonOfTime <s.mordz...@gma il.comwrote:
Hi everyone,

I am working on a project where I have .wmv files stored outside of
the server's www root, and want to serve them via a custom web
interface. It's all on windows, and is only intended to work locally
on the physical machine it runs on (don't ask, the customer is
king...).

Right now I have a working prototype in which I use a PHP script
(called movie.php) to serve the target file. In the HTML page, I have
an OBJECT tag that refers to the script, like so:

<OBJECT ID="MediaPlayer " WIDTH="512" HEIGHT="384"
CLASSID="CLSID: 22D6F312-B0F6-11D0-94AB-0080C74C7E95"
STANDBY="Loadin g Windows Media Player components..."
TYPE="applicati on/x-oleobject">
<PARAM NAME="FileName" VALUE="movie.ph p?fileID=12345" >
<PARAM name="ShowContr ols" VALUE="true">
<param name="ShowStatu sBar" value="true">
<PARAM name="ShowDispl ay" VALUE="true">
<PARAM name="autostart " VALUE="true">
<EMBED TYPE="applicati on/x-mplayer2"
SRC="movie.php? fileID=12345"
NAME="MediaPlay er"
WIDTH="512"
HEIGHT="384"
ShowControls="1 "
ShowStatusBar=" 1"
ShowDisplay="1"
autostart="1"
pluginspage="ht tp://www.microsoft.c om/windows/windowsmedia/download/
default.asp">
</EMBED>
</OBJECT>

The movie.php script itself is pretty simple too (stripped down to the
essentials):

<?php

$timeout = 60 * 60 * 24 * 2;
header( 'Cache-Control', 'private, max-age=' . $timeout . '' );
header( 'Pragma', 'private, max-age=' . $timeout . '' );
header( 'Expires', gmdate( 'D, d M Y H:i:s', time() + $timeout ) . '
GMT' );
header( 'Content-Type:video/x-ms-wmv' );
readfile( $file );

?>

This gives me a working player, but the big downside is the player
won't let me skip the clips :(

The seek bar does not respond to any requests to skip ahead, and
pausing the video resets it to the start. Any idea on how I can fix
this so I can skip ahead as much as I wish?

Thanks a lot!
Jul 30 '08 #2
On Jul 30, 5:52 pm, AeonOfTime <s.mordz...@gma il.comwrote:
Hi everyone,

I am working on a project where I have .wmv files stored outside of
the server's www root, and want to serve them via a custom web
interface. It's all on windows, and is only intended to work locally
on the physical machine it runs on (don't ask, the customer is
king...).

Right now I have a working prototype in which I use a PHP script
(called movie.php) to serve the target file. In the HTML page, I have
an OBJECT tag that refers to the script, like so:

<OBJECT ID="MediaPlayer " WIDTH="512" HEIGHT="384"
CLASSID="CLSID: 22D6F312-B0F6-11D0-94AB-0080C74C7E95"
STANDBY="Loadin g Windows Media Player components..."
TYPE="applicati on/x-oleobject">
<PARAM NAME="FileName" VALUE="movie.ph p?fileID=12345" >
<PARAM name="ShowContr ols" VALUE="true">
<param name="ShowStatu sBar" value="true">
<PARAM name="ShowDispl ay" VALUE="true">
<PARAM name="autostart " VALUE="true">
<EMBED TYPE="applicati on/x-mplayer2"
SRC="movie.php? fileID=12345"
NAME="MediaPlay er"
WIDTH="512"
HEIGHT="384"
ShowControls="1 "
ShowStatusBar=" 1"
ShowDisplay="1"
autostart="1"
pluginspage="ht tp://www.microsoft.c om/windows/windowsmedia/download/
default.asp">
</EMBED>
</OBJECT>

The movie.php script itself is pretty simple too (stripped down to the
essentials):

<?php

$timeout = 60 * 60 * 24 * 2;
header( 'Cache-Control', 'private, max-age=' . $timeout . '' );
header( 'Pragma', 'private, max-age=' . $timeout . '' );
header( 'Expires', gmdate( 'D, d M Y H:i:s', time() + $timeout ) . '
GMT' );
header( 'Content-Type:video/x-ms-wmv' );
readfile( $file );

?>

This gives me a working player, but the big downside is the player
won't let me skip the clips :(

The seek bar does not respond to any requests to skip ahead, and
pausing the video resets it to the start. Any idea on how I can fix
this so I can skip ahead as much as I wish?

Thanks a lot!
Don't use wmv.

In addition to solving the player problems, you'll reach a wider
audience and prevent leeching by using mpeg and Flash - see
http://www.webvideozone.com/public/171.cfm

C.
Jul 31 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
501
by: rockstar1971 | last post by:
Hello. I’m working with the Windows Media Encoder SDK to create an online jukebox for myself, but I’m having problems getting it to work. Here’s what I want to do: I’ve got a large collection of mp3 files that I listen to at work from my home server. I simply share them out from IIS and then open playlist files in WMP to play lists of songs. This works well fairly well. However, most of my mp3s are encoded at 192kbps or higher,...
1
1793
by: Philip Korolev | last post by:
Hi All. I am looking for articles on Windows Media development in ASP.NET pages. Dynamically adding playlists etc. Can I use server side code or is it all client side controlled? Spent the last few hours browsing the web and not feeling any wiser. If anybody has links that begin to answer any of the above , please forward them to me. In advance many thanks Phil
4
3371
by: Claudio Grondi | last post by:
I need to unpack on a Windows 2000 machine some Wikipedia media .tar archives which are compressed with TAR 1.14 (support for long file names and maybe some other features) . It seems, that Pythons tarfile module is able to list far more files inside the archives than WinRAR or 7zip or TotalCommander, but will it unpack all available files (largest archive size 17 GByte)? If tarfile is build on TAR 1.14 or TAR 1.15 it will be
1
7898
by: Stephen Adam | last post by:
Hi there, Have spent a while trying to find out how to connect to Windows Media Player through COM. Unfortunately there doesnt seem to be much stuff about it on the web. What I need to do is create a simple console application which will be able to find out what the values of a currently playing tack. I've downloaded the Windows Media player SDK which come with some IDL and
0
1043
by: Michal Przytulski | last post by:
Hi, i have a problem - i need to hide address of broadcasting computer in internet, problem looks like this - i hava a computer with windows media encoder, this computer is broadcasting online stream video, now i need to share with this video on internet without windows media server, i have idea that i can open this stream with php and send it forward - but how to do it ?? it is posible to that ?? maybe some other solutions for...
3
5193
by: UJ | last post by:
I have a .avi file that uses the Divx codec. If I load it with windows media player program it works fine. If I load it using my control in a program, it doesn't display. Over standard media files work fine so it's this particular file. Do I have to do anything when the file uses a non-included codec? How can I tell what Codec it's using? TIA - Jeff.
1
2146
by: xhunter | last post by:
I am streaming some files on my site (progressive http streaming), I use php to authenticate logged in users with sessions and cookies, and then send the stream to be opened. All my Quicktime and Real players files are working absolutely fine in all browsers, but the problem is, when it comes to Windows Media Player and Firefox, it doesn't seem to work, what I think it is the problem, that windows media player doesn't seem to use the...
2
1507
by: ezageza | last post by:
Hi, does anyone know whats going on or how to fix my problem with windows media player 10. When i'm finished using it and am shutting it down it brings up a message saying something like 'windows media is configuring the background files. Do you wish to continue shutting down'. I've noticed when watching movies lately on windows media that after about 10-15 mins the movie starts to jump really badly and the only way to stop it is to stop the...
1
11749
by: DeanB | last post by:
Please excuse my ignorance here as I have not used WPF for long, but what is the statement that tells what the "local:" identifier is that allows a window event to call a function in a .cs file? Here is the top of a window definition in xaml: I've marked the area in question with ?????. I have to call the TypeDirectoryValidationRule function from within the xaml code. I'm also confused on what the "SomePath" string is supposed to be for....
0
9564
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,...
0
10546
Oralloy
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...
1
10292
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,...
0
10068
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9121
agi2029
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...
0
6841
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4275
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
2
3796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.