| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637 |
- <?php
- function ppvm_player($ppub, $path, $video) {
- $metadata = $ppub->metadata;
- $short_title = $metadata["title"];
- // if(strlen($short_title) > 30) {
- // $short_title = substr($short_title, 0, 30);
- // $short_title .= "…";
- // }
- ?>
- <!DOCTYPE html>
- <html lang="<?php echo($metadata["language"] ?? SITE_LANGUAGE);?>">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title><?php echo(htmlentities($metadata["title"]));?> - <?php echo(SITE_NAME);?></title>
- <meta name="description" content="<?php echo(htmlentities($metadata["description"]));?>">
- <meta name="author" content="<?php echo(htmlentities($metadata["author"]));?>">
- <link rel="alternate" type="application/x-ppub" title="<?php echo(htmlentities($metadata["title"]));?> (as PPUB)" href="?download=true" />
- <script type="text/javascript" src="<?php echo(SITE_URL);?>/ppvm_player.js"></script>
- <script type="text/javascript" src="<?php echo(SITE_URL);?>/custom-controls.js"></script>
- <style type="text/css">
- body {
- margin: 0px;
- background-color: #000;
- }
- video {
- display: block;
- width: 100%;
- height: 100%;
- object-fit: contain;
- }
-
- #video-container {
- position: relative;
- width: 100vw;
- height: 100vh;
- background-color: #000;
- }
- .additional-contols {
- background: rgba(45, 45, 45, 0.8);
- padding: 6px;
- color: #ffffff;
- position: absolute;
- top: -36px;
- left: 0;
- right: 0;
- opacity: 0;
- transition: 0.2s all;
- padding-top: 0px;
- padding-bottom: 0px;
- font-size: 14px;
- z-index: 2147483646; /* High z-index to stay visible in fullscreen */
- }
- /* Removed body:hover .additional-contols.javascript to let JavaScript handle visibility */
- .paused.javascript, .noscript {
- top: 0px;
- opacity: 1;
- }
-
- .additional-contols.show {
- top: 0px;
- opacity: 1;
- }
-
- /* Ensure top controls are visible in fullscreen mode */
- :fullscreen .additional-contols,
- :-webkit-full-screen .additional-contols,
- :-moz-full-screen .additional-contols,
- :-ms-fullscreen .additional-contols {
- opacity: 1 !important;
- top: 0 !important;
- z-index: 2147483646 !important;
- }
-
- /* Removed fullscreen hover rules to let JavaScript handle visibility */
- .noscript-text {
- white-space: nowrap;
- margin-right: 10px;
- margin-left: 30px;
- }
- body, input {
- font: 1rem -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto, Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji", "Segoe UI Symbol";
- }
- dialog {
- background: rgba(45, 45, 45, 1);
- color: #ffffff;
- border: 1px solid aliceblue;
- max-width: 75%;
- }
- dialog p{
- margin-top: 2px;
- }
- dialog::backdrop {
- background: rgba(45, 45, 45, 0.8);
- }
- dialog .contents {
- margin: -15px;
- margin-bottom: 0px;
- padding: 15px;
- padding-bottom: 0px;
- max-height: calc(75vh - 55px);
- overflow-y: auto;
- }
- dialog .controls {
- border-top: 1px solid dimgrey;
- padding-top: 10px;
- }
- a {
- color: skyblue;
- }
- a:visited {
- color: aquamarine;
- }
- .additional-contols a {
- color: #ffffff;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- flex-shrink: 2;
- }
- .additional-control {
- display: flex;
- flex-wrap: nowrap;
- align-items: baseline;
- justify-content: start;
- }
- .filler {
- flex: 1;
- }
- .site a {
- text-decoration: none;
- color: #ffffff;
- margin: 8px;
- }
- .site a:hover {
- color: skyblue;
- text-decoration: underline;
- }
- .additional-control button, .additional-control select {
- background: rgba(45, 45, 45, 0);
- border: 1px solid rgba(45, 45, 45, 0);
- color: #ffffff;
- cursor: pointer;
- text-decoration: underline;
- text-align: right;
- margin-top: 0px;
- margin-bottom: 2px;
- margin-left: 2px;
- margin-right: 2px;
- padding-left: 6px;
- padding-right: 6px;
- padding-bottom: 3px;
- padding-top: 1px;
- height: 23px;
- -webkit-appearance: none;
- }
- .additional-control select {
- margin-left: auto;
- }
- .additional-control button:hover, .additional-control select:hover {
- color: skyblue;
- }
- .additional-control button:focus, .additional-control select:focus {
- color: skyblue;
- }
- .additional-control select option {
- color: #000000;
- }
- summary {
- cursor: pointer;
- }
- #share-modal textarea, pre {
- width: 500px;
- background: rgb(30, 30, 30);
- color: #fff;
- border: none;
- padding: 8px;
- margin-top: 8px;
- margin-bottom: 18px;
- border-radius: 4px;
- overflow: scroll;
- white-space: pre;
- }
- #download-modal li {
- margin-bottom: 8px;
- }
- /* Custom Video Controls Styles */
- .video-controls {
- position: absolute;
- bottom: 0;
- left: 0;
- right: 0;
- background: rgba(45, 45, 45, 0.8);
- padding: 10px;
- color: #ffffff;
- opacity: 0;
- transition: opacity 0.3s ease;
- z-index: 10;
- }
- .video-controls.show {
- opacity: 1;
- }
- /* Removed body:hover .video-controls to let JavaScript handle visibility */
- .video-controls:hover,
- .video-controls:focus-within {
- opacity: 1;
- }
-
- /* Ensure controls are initially visible and properly positioned */
- #video-container .video-controls {
- position: absolute !important;
- bottom: 0 !important;
- left: 0 !important;
- right: 0 !important;
- }
-
- /* Ensure controls are properly positioned in fullscreen mode */
- :fullscreen #video-container .video-controls,
- :-webkit-full-screen #video-container .video-controls,
- :-moz-full-screen #video-container .video-controls,
- :-ms-fullscreen #video-container .video-controls {
- position: absolute;
- bottom: 0;
- left: 0;
- right: 0;
- z-index: 2147483647;
- }
-
- /* Ensure top controls are visible in fullscreen mode */
- :fullscreen .additional-contols,
- :-webkit-full-screen .additional-contols,
- :-moz-full-screen .additional-contols,
- :-ms-fullscreen .additional-contols {
- opacity: 1;
- top: 0;
- z-index: 2147483646;
- }
- .controls-row {
- display: flex;
- align-items: center;
- gap: 10px;
- }
- .control-btn {
- background: none;
- border: none;
- color: #ffffff;
- cursor: pointer;
- font-size: 18px;
- padding: 5px;
- border-radius: 3px;
- transition: background-color 0.2s;
- }
- .control-btn:hover {
- background-color: rgba(255, 255, 255, 0.2);
- }
- .control-btn:focus {
- outline: 2px solid skyblue;
- }
- .progress-container {
- flex: 1;
- position: relative;
- height: 5px;
- background-color: rgba(255, 255, 255, 0.3);
- border-radius: 2.5px;
- cursor: pointer;
- }
- .progress-bar {
- position: absolute;
- width: 100%;
- height: 100%;
- background-color: rgba(255, 255, 255, 0.3);
- border-radius: 2.5px;
- }
- .progress-filled {
- position: absolute;
- width: 0%;
- height: 100%;
- background-color: skyblue;
- border-radius: 2.5px;
- }
-
- .progress-buffered {
- position: absolute;
- width: 0%;
- height: 100%;
- background-color: rgba(135, 206, 250, 0.3);
- border-radius: 2.5px;
- }
- .seek-slider {
- position: absolute;
- width: 100%;
- height: 100%;
- opacity: 0;
- cursor: pointer;
- -webkit-appearance: none;
- appearance: none;
- background: transparent;
- }
- .seek-slider::-webkit-slider-thumb {
- -webkit-appearance: none;
- appearance: none;
- width: 15px;
- height: 15px;
- background: skyblue;
- border-radius: 50%;
- cursor: pointer;
- opacity: 0;
- transition: opacity 0.2s;
- }
- .seek-slider::-moz-range-thumb {
- width: 15px;
- height: 15px;
- background: skyblue;
- border-radius: 50%;
- cursor: pointer;
- opacity: 0;
- transition: opacity 0.2s;
- border: none;
- }
- .progress-container:hover .seek-slider::-webkit-slider-thumb,
- .progress-container:hover .seek-slider::-moz-range-thumb {
- opacity: 1;
- }
- .time-display {
- font-size: 14px;
- min-width: 100px;
- text-align: center;
- }
- .volume-container {
- display: flex;
- align-items: center;
- }
- .volume-slider {
- width: 80px;
- height: 5px;
- background: rgba(255, 255, 255, 0.3);
- border-radius: 2.5px;
- outline: none;
- -webkit-appearance: none;
- appearance: none;
- cursor: pointer;
- }
- .volume-slider::-webkit-slider-thumb {
- -webkit-appearance: none;
- appearance: none;
- width: 12px;
- height: 12px;
- background: skyblue;
- border-radius: 50%;
- cursor: pointer;
- }
- .volume-slider::-moz-range-thumb {
- width: 12px;
- height: 12px;
- background: skyblue;
- border-radius: 50%;
- cursor: pointer;
- border: none;
- }
- /* Responsive adjustments */
- @media (max-width: 768px) {
- .video-controls {
- padding: 8px;
- }
-
- .control-btn {
- font-size: 16px;
- padding: 3px;
- }
-
- .time-display {
- font-size: 12px;
- min-width: 80px;
- }
-
- .volume-slider {
- width: 60px;
- }
- }
- @media (max-width: 480px) {
- .controls-row {
- gap: 5px;
- }
-
- .time-display {
- display: none;
- }
-
- .volume-slider {
- width: 50px;
- }
- }
- </style>
- </head>
- <body>
- <div id="video-container">
- <video id="player" poster="<?php echo($video->metadata["poster"]);?>" preload="metadata" src="<?php echo($video->metadata["master"]);?>">
- </video>
-
- <!-- Top Controls (moved inside video container) -->
- <div id="controls" class="additional-contols paused">
- <div class="additional-control site">
- <a href="<?php echo(SITE_URL);?>/<?php echo($_GET["ppub"]);?>/<?php echo($_GET["asset"]);?>" target="_blank" title="<?php echo(htmlentities($metadata["title"]));?>"><strong><?php echo(htmlentities($short_title));?></strong></a>
- <button onclick="showInfo()">Info</button>
- <button onclick="shareVideo()">Share</button>
- <button onclick="downloadVideo()">Download</button>
- <select name="quality" id="quality-selector" onchange="qualitySelected()">
- </select>
- </div>
- </div>
-
- <!-- Custom Video Controls -->
- <div id="custom-controls" class="video-controls">
- <div class="controls-row">
- <button id="play-pause-btn" class="control-btn" aria-label="Play/Pause">▶</button>
- <div class="progress-container">
- <div id="progress-bar" class="progress-bar">
- <div id="progress-filled" class="progress-filled"></div>
- <div id="progress-buffered" class="progress-buffered"></div>
- </div>
- <input type="range" id="seek-slider" class="seek-slider" min="0" max="100" value="0" step="0.1">
- </div>
- <span id="time-display" class="time-display">0:00 / 0:00</span>
- <button id="mute-btn" class="control-btn" aria-label="Mute/Unmute">🔊</button>
- <div class="volume-container">
- <input type="range" id="volume-slider" class="volume-slider" min="0" max="1" value="1" step="0.1">
- </div>
- <button id="fullscreen-btn" class="control-btn" aria-label="Fullscreen">⛶</button>
- </div>
- </div>
- </div>
- <div id="no-script" class="additional-contols noscript">
- <div class="additional-control site">
- <a href="<?php echo(SITE_URL);?>/<?php echo($_GET["ppub"]);?>/<?php echo($_GET["asset"]);?>" target="_blank" title="<?php echo(htmlentities($metadata["title"]));?>"><strong><?php echo(htmlentities($short_title));?></strong></a>
- <span class="noscript-text">For the best experience, please enable JavaScript.</span>
- </div>
- </div>
- <dialog id="download-modal">
- <form method="dialog">
- <div class="contents">
- <p><strong>Download video</strong><br/>
- <a href="<?php echo($video->metadata["master"]); ?>" download>Download the full quality version of this video</a> or select a different version to suit your needs below.
- </p>
- <details>
- <summary>Other formats and versions</summary>
- <ul>
- <?php
- foreach ($video->entries as $entry) {
- $entry_asset = $ppub->asset_index[$entry->filename];
- echo(" <li><a href=\"" . $entry->filename . "\" download>" . htmlentities($entry->label) . "</a><br/>\n");
- echo(" <small>" . round(($entry_asset->end_location - $entry_asset->start_location) / 1000000, 2) . "MB, " . $entry_asset->mimetype . "</small></li>\n");
- }
- ?>
- </ul>
- </details>
- <p>
- <?php if ($ppub->metadata["copyright"] != null) { ?>
- <br/>
- <?php echo($ppub->metadata["copyright"]);?>
- <?php } if ($ppub->metadata["licence"] != null) { ?>
- <br/>
- <a href="<?php echo($ppub->metadata["licence"]);?>" target="_blank">See Licence</a>
- <?php } ?></p>
- </div>
- <div class="controls">
- <button value="cancel">Close</button>
- </div>
- </form>
- </dialog>
- <dialog id="info-modal">
- <form method="dialog">
- <div class="contents">
- <p><strong><?php echo(htmlentities($ppub->metadata["title"]));?></strong>
- <?php if($ppub->metadata["author"] != null) {
- preg_match("/^([^<]*(?= *<|$))<*([^>]*)>*/", $ppub->metadata["author"], $author);
- ?>
- <br/>By <?php
- if(isset($author[2]) && $author[2] != '') {
- echo("<a href=\"mailto:".$author[2]."\">");
- echo(htmlentities(trim($author[1])));
- echo("</a>");
- } else {
- echo(htmlentities($ppub->metadata["author"]));
- }
- ?>.
- <?php } if ($ppub->metadata["tags"] != null and USE_PPIX) { ?>
- <br/>Tagged with:
- <?php
- foreach(explode(" ", $ppub->metadata["tags"]) as $tag) {
- ?>
- <a href="<?php echo(SITE_URL);?>/?tag=<?php echo(urlencode($tag));?>" target="_blank"><?php echo(htmlentities($tag));?></a>
- <?php
- }
- ?>
- <?php } if ($ppub->metadata["date"] != null) { ?>
- <br/>Last updated on <?php echo(htmlentities((new DateTime($ppub->metadata["date"]))->format(DATE_FORMAT)));?>.
- <br/><?php } if ($ppub->metadata["copyright"] != null) { ?>
- <?php echo($ppub->metadata["copyright"]);?>
- <?php } if ($ppub->metadata["licence"] != null) { ?>
- <a href="<?php echo($ppub->metadata["licence"]);?>" target="_blank">See Licence</a>
- <?php } ?></p>
- <br/><small>Powered by <a href="https://github.com/Tilo15/php-ppub" target="_blank">php-ppub</a></small></p>
- </div>
- <div class="controls">
- <button value="cancel">Close</button>
- </div>
- </form>
- </dialog>
- <dialog id="share-modal">
- <form method="dialog">
- <div class="contents">
- <p><strong>Share this video</strong><br/>
- With your friends, colleagues, distant family, or strangers on the internet.
- </p>
- <div>
- <label>Link:</label>
- <pre><?php echo(SITE_URL);?>/<?php echo($_GET["ppub"]);?>/<?php echo($_GET["asset"]);?></pre>
- </div>
- <div>
- <label>Embed:</label><br/>
- <textarea readonly rows="3"><?php generate_embed($path, $video);?></textarea>
- </div>
- </div>
- <div class="controls">
- <button value="cancel" autofocus>Close</button>
- </div>
- </form>
- </dialog>
- <dialog id="unplayable-modal">
- <form method="dialog">
- <div class="contents">
- <p><strong>Unable to playback content</strong><br/>
- Your browser does not appear to support any of the available codecs.
- </p>
- </div>
- <div class="controls">
- <button value="cancel">Close</button>
- </div>
- </form>
- </dialog>
- <script type="text/javascript">
- setup_playback({
- entries: [
- <?php
- foreach ($video->entries as $entry) {
- $entry_asset = $ppub->asset_index[$entry->filename];
- $size = ($entry_asset->end_location - $entry_asset->start_location);
- echo(" { type: \"" . $entry->type . "\", mimetype: \"" . $entry_asset->mimetype . "\", path: \"" . $entry->filename . "\", label: \"" . $entry->label . "\", byterate: " . $size / (float)$video->metadata["duration"] . ", filesize: " . $size . ", metadata: { ");
- foreach ($entry->metadata as $key => $val) {
- echo(str_replace("-", "_", $key) . ": \"" . $val . "\", ");
- }
- echo("}},\n");
- }
- ?>
- ]
- });
- </script>
- </body>
- </html>
- <?php
- }
- function generate_embed($path, $video) {
- $percent = 56.25;
- if(isset($video->metadata["ratio"])) {
- $ratio = explode(":", $video->metadata["ratio"]);
- $percent = (min($ratio[0], $ratio[1]) / max($ratio[0], $ratio[1])) * 100;
- }
- ?>
- <div class="ppvm-player" style="position: relative; height:0; background: #2d2d2d; padding-bottom: <?php echo($percent);?>%">
- <iframe src="<?php echo(SITE_URL);?>/<?php echo($_GET["ppub"]);?>/<?php echo($_GET["asset"]);?>?embed=true/" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" allowfullscreen></iframe>
- </div><?php
- }
- ?>
|