play_video.php 📹

This script dynamically serves tutorial videos in a standalone player page. It reads a GET parameter to select a video, sets up metadata, and invokes JW Player to stream the corresponding MP4 file.

Purpose

  • Provide an iframe-ready player for site tours.
  • Map a short code (v query param) to a video file, title, and description.
  • Autostart the video with a clean, minimal UI.

Dependencies

  • inc/config.php for site configuration and resource paths
  • JW Player library:
    • js/mediaplayer/jwplayer.js
    • js/mediaplayer/player.swf
  • Video assets in the tour_videos/ directory (e.g. signup.mp4, quote_and_ship.mp4).

Video Mapping Table 🎬

Query Key File Title Description
signup signup.mp4 Signup How to register a company to use site.
address_book address_book.mp4 Address Book How to manage address book.
product_catalog product_catalog.mp4 Product Catalog How to manage product catalog.
quote quote_and_ship.mp4 Quote and Ship How to get a quote and make shipment.
my_shipments my_shipments.mp4 My Shipments How to manage shipments.
cancel_claim cancel_claim.mp4 Cancel and Claim Shipment How to cancel and claim a shipment.
create_bol create_bol.mp4 Create Bill of Lading How to create bill of lading.
saved_bol saved_bol_files.mp4 View Saved Bill of Lading How to get saved bill of lading files.
apply_for_credit apply_for_credit.mp4 Application For Credit How to apply for credit.

This mapping is defined via a PHP switch on $_GET['v'] .

Key Code Snippets

<?php
include_once("inc/config.php");

$video_file = "";
$title      = "";
$description= "";

if (!empty($_GET["v"])) {
    switch ($_GET["v"]) {
        case 'signup':
            $video_file = "signup.mp4";
            $title      = "Signup";
            $description= "How to register a company to use website.";
            break;
        // … other cases …
    }
}
?>

Sets up the video metadata before any HTML output .

<div id="container">Loading the player …</div>
<script type="text/javascript">
jwplayer("container").setup({
    autostart : true,
    controlbar: "none",
    file      : "tour_videos/<?=$video_file?>",
    flashplayer: "js/mediaplayer/player.swf",
    height    : 600,
    width     : 800,
    title     : "<?=$title?>",
    description: "<?=$description?>",
    plugins   : {
        hd: {
            file      : "tour_videos/<?=$video_file?>",
            fullscreen: true
        }
    }
});
</script>

Initializes JW Player with autoplay, no control bar, and an HD plugin .

Usage Flow 🔄

  1. User clicks a “Take a Tour” link (.tour_video).
  2. Fancybox opens play_video.php?v=<key> in an iframe.
  3. PHP selects the video and outputs the HTML+JS.
  4. JW Player loads and autoplays the chosen MP4.

The “Take a Tour” page binds Fancybox to .tour_video anchors to launch this player .

Integration with Template System

  • In inc/template_vars.php, play_video.php is registered as a valid route ($TEMPLATE["play_video.php"] = '') .
  • Despite the global template system, this file outputs its own <html>/<head> to ensure it loads cleanly inside an iframe.

Similar Implementations 🔁

  • linuxfront-v2/play_video.php contains an almost identical player script for another sub-project, demonstrating code reuse across portals .

By following this structure, play_video.php remains a single-responsibility component, focused solely on video selection and playback, while deferring configuration and surrounding UI to shared resources.