I'm making a site where users can search for and play videos (which are stored on our server). I have someone else doing a lot of the backend stuff but he doesn't know how to embed the videos in the webpage from the php database.
I've heard this can be a hard thing to do, but if someone could at least get me started I would very much appreciate it.
We're using CakePHP for backend stuff if that helps.
Thanks a lot
I do not see the reason why the video must be stored in the database. If I were you, I'd store it in a dedicated folder, such as myApplication/static/videos/ and then just simply add a record to a videos database-table with related information about the video, which could be stuff like the following:
After that, it's pretty straight-forward: searching the database after keywords or a matching description - and upon a match simply generating the HTML5 markup:
// Gather information about the video
$video_data = get_video($id);
$markup = "<video width='". $video_data['source_width'] ."' height='". $video_data['source_height'] ."' controls='controls'>
<source src='". $video_data['source_path'] ."' type='". $video_data['type'] ."' />
</video>";
Be sure to clean any input which comes from the user that's going to be stored in the database. This does NOT include the source path, which should be generated upon file upload, without the need of any user interaction, that is if you're going to allow users to upload files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With