This tutorial will show you how, in PHP, you can detect which player to play certain videos. It might be a bit long winded but you should understand how it all works.
Step 1
When uploading a video you will need to get it to insert the infromation into the database and also have it detect the MIME Type of the video. To do that you can use this varible:
$_FILES['videoname']['type']
Step 2
That'll detect the MIME type of the file. Now we need to create the function. Start by setting the function and giving it 2 properties. ($filename = the filename (eg; mydance.wmv), $folder = the folder where its in (eg; videos)). Then you should connect to the database and get it to pull the the information from it, like the MIME Type (eg; $vd_mime). Then you'll need to create a switch / case option that'll check all the various MIME Types. This one checks WMV, AVI, MPEG and MOV. The code between each of the case statements is the embed codes, you'll notice that they are also calling the properties from the function too - this adds a bit of customisation to it.
Step 3
Once you have done all that just get it to return the filename. And when you have this code in your PHP scripts then all you need to use is
That'll show your video in the correct player.
Comments
Comments:
31st Aug 2008 19:01
Dale a quick note:
Wouldent it be easier to set up a seperate function with varibles within in it that you pass from the switch statement?
It would save a lot of code, and make your code tidier, and easier to understand, i understand that in PHP V4 passing to functions was a tad slow, but things in PHP V5 is a lot quicker.
Failing that set up a class!
By Anthony
31st Aug 2008 18:53
for: Fabion
If you cant read the code, be a better programmer ;)
By Anthony
1st Oct 2007 2:37
hay cool script but dude please try to comment your code please, this is like a shit load of code, but I'm not complaining thanks.
By Fabion
1st Oct 2007 10:47
Fabion - I'll get around to sorting it all out soon. :)