- 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.
This commit is contained in:
Ty Clifford
2026-06-24 12:15:03 -04:00
parent b24f0dc416
commit 75d5d39cda
6 changed files with 382 additions and 30 deletions
+46 -15
View File
@@ -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 *');
<div class="player-wrap" id="player-wrap">
<div class="shimmer-bar"></div>
<?php if ($video && !empty($video['sources'])): ?>
<?php if ($video && !empty($player_sources)): ?>
<!-- Title + brand overlay -->
<div class="title-overlay" id="title-overlay">
@@ -182,19 +204,28 @@ header('Content-Security-Policy: frame-ancestors *');
target="_blank" rel="noopener">tyclifford.com</a>
</div>
<video id="embed-player"
class="video-js vjs-default-skin vjs-big-play-centered"
controls preload="metadata"
<?php if ($video['thumbnail']): ?>
poster="<?= htmlspecialchars($base_url . MEDIA_URL . $video['thumbnail'], ENT_QUOTES) ?>"
<?php endif; ?>>
<?php foreach ($video['sources'] as $src): ?>
<source
src="<?= htmlspecialchars(source_public_url($src, $base_url . MEDIA_URL), ENT_QUOTES) ?>"
type="<?= htmlspecialchars($src['mime_type'], ENT_QUOTES) ?>">
<?php endforeach; ?>
<p class="vjs-no-js">Your browser does not support HTML5 video.</p>
</video>
<?php if (($primary_player_source['kind'] ?? '') === 'iframe'): ?>
<iframe class="provider-embed-frame"
src="<?= htmlspecialchars($primary_player_source['embed'], ENT_QUOTES) ?>"
title="<?= htmlspecialchars($video['title'], ENT_QUOTES) ?>"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share"
allowfullscreen
referrerpolicy="no-referrer-when-downgrade"></iframe>
<?php elseif (!empty($native_player_sources)): ?>
<video id="embed-player"
class="video-js vjs-default-skin vjs-big-play-centered"
controls preload="metadata"
<?php if ($video['thumbnail']): ?>
poster="<?= htmlspecialchars($base_url . MEDIA_URL . $video['thumbnail'], ENT_QUOTES) ?>"
<?php endif; ?>>
<?php foreach ($native_player_sources as $src): ?>
<source
src="<?= htmlspecialchars($src['url'], ENT_QUOTES) ?>"
type="<?= htmlspecialchars($src['mime'], ENT_QUOTES) ?>">
<?php endforeach; ?>
<p class="vjs-no-js">Your browser does not support HTML5 video.</p>
</video>
<?php endif; ?>
<?php else: ?>
@@ -211,7 +242,7 @@ header('Content-Security-Policy: frame-ancestors *');
<?php endif; ?>
</div>
<?php if ($video && !empty($video['sources'])): ?>
<?php if ($video && !empty($native_player_sources) && (!$primary_player_source || ($primary_player_source['kind'] ?? '') !== 'iframe')): ?>
<script>
document.addEventListener('DOMContentLoaded', function () {
var player = videojs('embed-player', {