How to play all video files in browser using php?
Dear all, i want to play most of all video files in browser, is it开发者_如何转开发 possible? can any buddy help me out.
thanks in advance.
PHP is a server-side programming language for dynamically generating content. This will not help you play videos for the end-user. For that, you will either need to stream the video and count on the user having a plugin, or you will need to use some sort of end-user video player, perhaps using Flash. PHP isn't really what you're looking for here, as it just generates content to send to the browser.
At work we do just this. Assuming that you're talking about a webserver, it's pretty easy to set up. I second the earlier recommendation of flowplayer from http://www.flowplayer.org.
Load your videos into a webserver-accessible directory, generate a list of them with php, and use that list to activate the flowplayer, which can be controlled with javascript.
I assume you're talking about a web server, and you want all of them to appear in your browser window?
You're going to need a JavaScript or Flash video player to play the files in the browser. Some that I've used in the past are http://flowplayer.org/ and http://ajaxian.com/archives/jsonvid-pure-javascript-video-player
You probably want to use PHP, if you're going to use PHP, to list all the video files on your server (which I am assuming is Linux). You're going to want to use UNIX utilities instead of building your own, I'd imagine; probably a recursive find command. So your PHP code will look something like:
<?php
$files = `find BASE_DIRECTORY -name *.FILE_EXTENSION`;
foreach ($files as $file)
{
// Display viewer
}
?>
In any browser you can play only those formats which are supported by that browser. In case of video, mp4 is the format supported by maximum browsers, so you need to convert any uploaded video to mp4 format before playing.
精彩评论