LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-20-2005, 11:57 PM   #1
rook
LQ Newbie
 
Registered: Sep 2003
Posts: 12

Rep: Reputation: 0
Help with LAN movie page


I need some help with a web page project I'm trying to do. I have a linux box set up with my DIVX movies on it and I want to be able to play them over http. My client boxes are running WinXP and using mplayer. Mplayer streams the movies fine over http, but I want to write a PHP driven page so I can choose my movie from a browser and have it open in mplayer. The problem I have now is that as soon as I click on the link the browser starts downloading the file. I don't want to download it, I just want to stream it. Is there some way I can do this?
 
Old 02-21-2005, 11:01 AM   #2
DoubleOTeC
Member
 
Registered: Aug 2003
Location: Dominica
Distribution: RedHat, FC1, FC3, FC4
Posts: 266

Rep: Reputation: 30
I'm not sure, but I"m thinking you may need to implement a streaming server.
 
Old 02-21-2005, 11:13 PM   #3
rook
LQ Newbie
 
Registered: Sep 2003
Posts: 12

Original Poster
Rep: Reputation: 0
Okay, I have half a solution to my problem, but I still need a little help with the other half. Here's what I came up with:

1) Have the webpage create a playlist file that holds the url of the file to play.

2) Send the playlist to the browser via PHP.

The following code should work:

<?php
header('Content-type: video/x-mpegurl');
header('Content-Disposition: attachment; filename="playlist.m4u"');
readfile('playlist.m4u');
?>

My problem is this: My browser sees the playlist.m4u file as a text file and displays it on the screen. I added an encoding configuration to my server config file as follows:

AddEncoding video/x-mpegurl .m4u

But this doesn't seem to help. What do I need to do to get the playlist sent out as a file instead of displayed in the browser?
 
Old 02-23-2005, 12:57 AM   #4
rook
LQ Newbie
 
Registered: Sep 2003
Posts: 12

Original Poster
Rep: Reputation: 0
Okay, I got it working and I figured I should post the solution so others can use it if they want to do the same thing. Here's a simple step-by step.

1. First I added the mime-type .m4u to my Apache server configuration with the following line (this goes in the <Directory> section

AddType video/x-mpegurl .m4u

2. The I made a simple php script to list the contents of my movies folder and create a link that follows the following format: http://myserver/playmovie.php?filename=mymovie.avi

3. Here is what playmovie.php looks like:
<?php
header('Content-type: video/x-mpegurl');
header('Content-Disposition: attachment; filename="playlist.m4u"');

$home = "http://myserver/movies/";
$filename = $_GET['filename'];
echo $home . $filename; ?>

It sends the header for "playlist.m4u" which is created on the fly at the echo line.

4. I set up my WinXP machine to play .m4u files with mplayer through the File Types actions with the following action:

"C:\Program Files\mplayer\mplayer.exe" -playlist "%1"

5. I visited my myserver/movies/ and clicked a file. When the browser asked how to handle the .m4u file a told it to open with the associated program and never ask again.


That's it! Now when I want to watch a movie I just pop open a browser and choose. I'm now working on enhancing the php and adding some css stylesheets to improve the look of the filechooser. It's so much nicer than having to type in long urls into mplayer or having to open folders in My Network places. Now I have all the flexibility of a webserver for my media library! If anyone wants a copy of the php script I use to list my files, just e-mail me at jnoble1 at emich dot edu

Later!
 
Old 02-28-2005, 02:38 AM   #5
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
Hey, I might like a copy, and would think others might too, any chance you can just post it up on here?

Thanks!

Cool
 
Old 02-28-2005, 02:46 AM   #6
RandomLinuxNewb
Member
 
Registered: Oct 2003
Distribution: Slackware
Posts: 101

Rep: Reputation: 15
You might want to check out VideoLan.
 
Old 03-09-2005, 09:37 PM   #7
rook
LQ Newbie
 
Registered: Sep 2003
Posts: 12

Original Poster
Rep: Reputation: 0
Thanks for the idea. I have already tried VideoLAN however and I had a bunch more problems. It kept blue screening my XP machine and I would have had to wrote a rather large CGI back-end to automate it from a web page. VideoLAN looks like a powerful tool for more complex needs than mine though.
 
Old 03-13-2005, 04:03 PM   #8
rook
LQ Newbie
 
Registered: Sep 2003
Posts: 12

Original Poster
Rep: Reputation: 0
Here's the contents filelist.php :

Code:
<html>
<head>
<title>Movies</title>
<link type="text/css" rel="stylesheet" href="style.css">
</head>
<body>
<center><div class="title">Movies</div>
<hr size="0" width="60%"></center>
<div class="main">
<?php
function scandir($dir){
    $files = array();
    $dh = @opendir($dir);
    if ($dh!=FALSE){
        while (false !== ($filename = readdir($dh))) {
    if ($filename !== "." && $filename !==".." && $filename !==".journal" && $filename !=="lost+found"){
        $files[] = $filename;
    }
}
sort($files);
    }
    return $files;
}

$list = scandir("movies");
$i = 0;
$num = count($list);
while($i < $num) {
print "<a href=\"playmovie.php?filename=$list[$i]\">$list[$i]</a><br>";
$i++;
}
?>
</div>
</body>
</html>
Here's the stylesheet I use for a little flare:

Code:
A:link{
text-decoration: none;
font-family: helvetica, arial;
font-size: 100%;
color: #ffffff;
}
A:visited{
text-decoration: none;
font-family: helvetica, arial;
font-size: 100%;
color: #ffffff;
}
a:hover{
text-decoration: none;
font-family: helvetica, arial;
font-size: 100%;
color: #ffa0a0;
}
body{
background: #000000;
margin-top: 0px;
margin-left: 0px;
}
div.title{
font-family: Century Gothic, gothic;
font-size: 400%;
color: #ffffff
}
div.main{
margin-left: 30%;
}
That works quite nicely for me right now. I'll probably add pictures and a two column format when I get more movies. Sorry it took so long to get the code posted. I skipped right over that post.

Last edited by rook; 03-13-2005 at 04:05 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Dell Inspiron 8100: No scancodes from Page Up Page Down keys twosider Linux - Laptop and Netbook 1 10-18-2005 09:41 AM
lost start page (home page?) multiplaone Linux - Newbie 1 05-29-2005 06:10 PM
I cant change the default test page in apache server to add my page.y nhemapriya Linux - Newbie 3 05-13-2004 12:35 PM
RH & HP4050N PCL - page, pause, page, pause, page andguent Linux - Hardware 0 11-10-2003 08:35 AM
cannot view web page from local lan Tigger Linux - Networking 4 05-31-2003 01:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration