From 75d5d39cdacbdb906d76dd68e590115659512dd3 Mon Sep 17 00:00:00 2001 From: Ty Clifford Date: Wed, 24 Jun 2026 12:15:03 -0400 Subject: [PATCH] - Implemented. The main database-backed player now understands provider URLs from lone-embed.php style handling. What changed: [includes/db.php (line 227)](/Users/tyemeclifford/Documents/GH/mediaplayer/includes/db.php:227) now classifies YouTube, Vimeo, Dailymotion, Twitch, Facebook, TikTok, Instagram, X/Twitter, SoundCloud, Spotify, Google Drive, Wistia, Streamable, Loom, plus direct Dropbox/GitHub media rewrites. [index.php (line 235)](/Users/tyemeclifford/Documents/GH/mediaplayer/index.php:235) renders provider URLs as iframe embeds, while uploaded/direct files still use Video.js. [embed.php (line 198)](/Users/tyemeclifford/Documents/GH/mediaplayer/embed.php:198) now supports those provider embeds too. [admin/add.php (line 260)](/Users/tyemeclifford/Documents/GH/mediaplayer/admin/add.php:260) and [admin/edit.php (line 383)](/Users/tyemeclifford/Documents/GH/mediaplayer/admin/edit.php:383) now describe external URLs as embed-capable and store recognized provider URLs as text/html. [README.md (line 63)](/Users/tyemeclifford/Documents/GH/mediaplayer/README.md:63) documents provider embed support. --- README.md | 5 +- admin/add.php | 8 +- admin/edit.php | 12 +- embed.php | 61 +++++++--- includes/db.php | 295 ++++++++++++++++++++++++++++++++++++++++++++++++ index.php | 31 ++++- 6 files changed, 382 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 28fd0ce..3568747 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ Styled to match the existing `gate.php` / `index.php` dark theme exactly. 3. Upload a thumbnail (JPG/PNG/WebP) 4. Add one or more video sources. Each source can be either: - an uploaded local video file, stored under `media/videos/` - - an external video URL, stored in SQLite and played directly by URL + - an external URL, stored in SQLite and played as a direct media source or provider embed 5. For uploaded files, supported formats include: - **MP4** (H.264) — widest compatibility - **WebM** (VP9) — smaller size, modern browsers @@ -73,7 +73,7 @@ Styled to match the existing `gate.php` / `index.php` dark theme exactly. 6. Set quality labels (1080p, 720p, 480p, etc.) 7. Save — Video.js will use the stored source location and auto-select the best format the browser supports -External URLs must use `http://` or `https://`. Uploaded files and remote URLs can be mixed on the same video. +External URLs must use `http://` or `https://`. Uploaded files and remote URLs can be mixed on the same video. Recognized provider URLs such as YouTube, Vimeo, Dailymotion, Twitch, Facebook, TikTok, Instagram, X/Twitter, SoundCloud, Spotify, Google Drive, Wistia, Streamable, and Loom render through their embed players. ### Public Search @@ -102,6 +102,7 @@ Use the **Sort Order** field — lower numbers appear first. Default is 0. - Playback rate controls: 0.5×, 1×, 1.25×, 1.5×, 2× - Multiple source fallback — browser picks best format automatically - Local uploaded sources and remote URL sources +- Provider embeds for popular video and audio platforms - Thumbnail posters - Keyboard accessible diff --git a/admin/add.php b/admin/add.php index 2f402b3..d8eb502 100644 --- a/admin/add.php +++ b/admin/add.php @@ -83,7 +83,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $db->prepare(" INSERT INTO video_sources (video_id, label, source_type, file_path, source_url, mime_type, quality, sort_order) VALUES (?,?,?,?,?,?,?,?) - ")->execute([$video_id, $label, 'remote', '', $url, mime_from_ext($url), $quality, $sort]); + ")->execute([$video_id, $label, 'remote', '', $url, source_storage_mime_from_url($url), $quality, $sort]); $inserted_sources++; continue; } @@ -259,7 +259,7 @@ render_head('Add Video — Admin', '

Video Sources

- Upload a video file or link to an external video URL. The database stores where each source lives, and the player uses that location at playback time. + Upload a video file, link a direct media file, or paste a provider page URL such as YouTube or Vimeo. The player will use a provider embed when the URL supports it. Uploaded files: MP4, WebM, OGV, MOV, MKV, AVI. Remote URLs must use http:// or https://.

@@ -270,7 +270,7 @@ render_head('Add Video — Admin', '
@@ -281,7 +281,7 @@ render_head('Add Video — Admin', '
diff --git a/admin/edit.php b/admin/edit.php index 95e578e..3047322 100644 --- a/admin/edit.php +++ b/admin/edit.php @@ -103,7 +103,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($source_type === 'remote') { $sql .= ", source_url=?, mime_type=?"; $params[] = $source_url; - $params[] = mime_from_ext($source_url); + $params[] = source_storage_mime_from_url($source_url); } $sql .= " WHERE id=? AND video_id=?"; $params[] = (int)$sid; @@ -149,7 +149,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $db->prepare(" INSERT INTO video_sources (video_id, label, source_type, file_path, source_url, mime_type, quality, sort_order) VALUES (?,?,?,?,?,?,?,?) - ")->execute([$id, $label, 'remote', '', $url, mime_from_ext($url), $quality, $sort]); + ")->execute([$id, $label, 'remote', '', $url, source_storage_mime_from_url($url), $quality, $sort]); $inserted_source_ids[] = (int)$db->lastInsertId(); continue; } @@ -340,7 +340,7 @@ render_head('Edit Video — Admin', '
- +
@@ -389,14 +389,14 @@ render_head('Edit Video — Admin', '

Add New Sources

-

Upload another file or link an external URL. Remote URLs must use http:// or https://.

+

Upload another file, link a direct media file, or paste a provider page URL such as YouTube or Vimeo.

@@ -407,7 +407,7 @@ render_head('Edit Video — Admin', '
diff --git a/embed.php b/embed.php index 997cba8..2b80baa 100644 --- a/embed.php +++ b/embed.php @@ -18,6 +18,19 @@ $script = dirname($_SERVER['SCRIPT_NAME'] ?? '/'); $script = rtrim($script, '/'); $base_url = $scheme . '://' . $host . $script . '/'; // e.g. https://tyclifford.com/live/ +$player_sources = []; +if ($video && !empty($video['sources'])) { + foreach ($video['sources'] as $source) { + $player_source = source_player_data($source, $base_url . MEDIA_URL); + if ($player_source) $player_sources[] = $player_source; + } +} +$primary_player_source = $player_sources[0] ?? null; +$native_player_sources = []; +foreach ($player_sources as $player_source) { + if (($player_source['kind'] ?? '') !== 'iframe') $native_player_sources[] = $player_source; +} + // X-Frame-Options: allow embedding from any origin. // If you want to restrict, change ALLOWALL to SAMEORIGIN or remove for CSP header instead. header('X-Frame-Options: ALLOWALL'); @@ -111,6 +124,15 @@ header('Content-Security-Policy: frame-ancestors *'); .video-js .vjs-current-time, .video-js .vjs-duration, .video-js .vjs-time-divider { color: rgba(255,255,255,.8) !important; font-size: .7em !important; } + .provider-embed-frame { + position: absolute; + inset: 0; + display: block; + width: 100%; + height: 100%; + border: 0; + background: #000; + } /* Title + branding overlay at top (fades out) */ .title-overlay { @@ -173,7 +195,7 @@ header('Content-Security-Policy: frame-ancestors *');
- +
@@ -182,19 +204,28 @@ header('Content-Security-Policy: frame-ancestors *'); target="_blank" rel="noopener">tyclifford.com
- + + + + + @@ -211,7 +242,7 @@ header('Content-Security-Policy: frame-ancestors *');
- +