Launch a video file via a PHP page
Kaorentin
Posted messages
182
Status
Member
-
avion-f16 Posted messages 19182 Registration date Status Contributor Last intervention -
avion-f16 Posted messages 19182 Registration date Status Contributor Last intervention -
Hello,
I set up a small local site to gather videos. So, we can navigate through the videos via their covers. I grouped all this in a MySQL database.
Anyway, that's just the context.
Here's my problem:
I want to open a video from the browser. However, after quite a bit of tinkering, I managed to launch a video, but there's no sound.
Here's the code used:
// page.php //
<?php echo "<a href='read.php?file=D:\Unwatched Films\video.avi'>"; ?>
// Here, we are on the video page in question, clicking the link opens read.php with the video parameter in question.
// read.php //
<?php
exec($_GET['file']);
?>
// It's that simple!
Do I need to add some info to tell it to play the audio as well? (It seems unbelievable!)
Thanks in advance for your answer!
Corentin.
Configuration: Windows 7 / Firefox 4.0.1
I set up a small local site to gather videos. So, we can navigate through the videos via their covers. I grouped all this in a MySQL database.
Anyway, that's just the context.
Here's my problem:
I want to open a video from the browser. However, after quite a bit of tinkering, I managed to launch a video, but there's no sound.
Here's the code used:
// page.php //
<?php echo "<a href='read.php?file=D:\Unwatched Films\video.avi'>"; ?>
// Here, we are on the video page in question, clicking the link opens read.php with the video parameter in question.
// read.php //
<?php
exec($_GET['file']);
?>
// It's that simple!
Do I need to add some info to tell it to play the audio as well? (It seems unbelievable!)
Thanks in advance for your answer!
Corentin.
Configuration: Windows 7 / Firefox 4.0.1
1 answer
Hello,
The exec() function is used to execute a command or a program.
https://www.php.net/manual/en/function.exec.php
Try using readfile() instead.
And if the sound issue persists, then it means that the browser does not have the necessary plugins to read the audio codec.
--
Thought leads the world.
The exec() function is used to execute a command or a program.
https://www.php.net/manual/en/function.exec.php
Try using readfile() instead.
And if the sound issue persists, then it means that the browser does not have the necessary plugins to read the audio codec.
--
Thought leads the world.
Unfortunately, now when I launch the file, I have sound but VLC doesn't open anymore...
Well, it opens in the background, but doesn't display :/
And I can't bring it up :s
Is there a way to pass the execution of a program as a parameter to readfile? Something like readfile(exec(vlc), video.avi) (roughly speaking).
If you want to open VLC, then try this instead:
exec('C:\Path\to\vlc.exe C:\Path\to\video.avi');Don't confuse it; it is not about specifying the two paths independently, but about specifying the VLC program which takes the file to open as a parameter.Always this sound problem! I can see the video that plays in VLC, but with no sound :/
(by the way, I say VLC, but it does the same thing with MPC and others).
And regarding the readfile that only plays the sound, I get this error:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 734361601 bytes) in C:\wamp\www\cmdb\all\read.php on line 3
Knowing that my read.php only contains
<?php
readfile($_GET['file']);
?>
<?php define('VLCBIN', '"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe"'); define('MOVIE' , '"C:\Users\user\Desktop\test.avi"'); exec(VLCBIN.' '.MOVIE); ?>The double quotes are there for a reason:Single quotes are used to contain the string
And the doubles, which will be sent to Windows, are used to handle spaces in paths.
So Windows receives this (with no line break):
Does vlc open for you?