Billy Barrow преди 3 години
родител
ревизия
b76ad17a71
променени са 4 файла, в които са добавени 28 реда и са изтрити 5 реда
  1. 2 1
      .htaccess
  2. 6 0
      index.php
  3. 1 1
      ppub.php
  4. 19 3
      video_player.php

+ 2 - 1
.htaccess

@@ -1,5 +1,6 @@
 RewriteEngine on
 RewriteRule vanilla.css - [L]
 RewriteRule index.php - [L]
+RewriteRule ppvm_player.js - [L]
 RewriteRule ^(.+?(?=/))/(.*)/?$  index.php?ppub=$1&asset=$2    [L,QSA]
-RewriteRule ^(.+?(?=$|\/))$  index.php?ppub=$1    [L,QSA]
+RewriteRule ^(.+?(?=$|\/))$  index.php?ppub=$1    [L,QSA]

+ 6 - 0
index.php

@@ -211,6 +211,12 @@ else {
             }
         
             $cr_header = sprintf('Content-Range: bytes %d-%d/%d', $start, $finish_bytes, $file_size);
+
+            if($start > $file_size || $end > $file_size) {
+                header("HTTP/1.1 416 Range Not Satisfiable");
+                header($cr_header);
+                exit;
+            }
         
             header("HTTP/1.1 206 Partial content");
             header($cr_header);

+ 1 - 1
ppub.php

@@ -70,7 +70,7 @@ class Ppub {
 
     public function stream_asset($asset, $start = 0, $end = -1) {
         $start_location = $asset->start_location + $this->blob_start + $start;
-        $length = ($end >= 0) ? $asset->end_location - $asset->start_location : $end;
+        $length = ($end < 0) ? $asset->end_location - $asset->start_location - $start : $end - $start;
         fseek($this->handle, $start_location);
         $pos = 0;
         while($pos < $length) {

+ 19 - 3
video_player.php

@@ -2,6 +2,13 @@
 
 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);?>">
@@ -42,7 +49,7 @@ function ppvm_player($ppub, $path, $video) {
                 gap: 8px;
             }
 
-            body:hover .additional-contols, .paused {
+            body:hover .additional-contols.javascript, .paused.javascript, .additional-contols.noscript {
                 top: 0px;
                 opacity: 1;
             }
@@ -165,12 +172,21 @@ function ppvm_player($ppub, $path, $video) {
     </head>
     <body>
 
-        <video controls id="player" poster="<?php echo($video->metadata["poster"]);?>">
+        <video controls id="player" poster="<?php echo($video->metadata["poster"]);?>" preload="metadata" src="<?php echo($video->metadata["master"]);?>">
         </video>
 
+        <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>
+            </div>
+            <div class="additional-control noscript">
+                For the best experience, please enable JavaScript.
+            </div>
+        </div>
+
         <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"><strong><?php echo(htmlentities($ppub->metadata["title"]));?></strong></a>
+                <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>