manto07m 3 роки тому
батько
коміт
1f6a422468

+ 7 - 6
script/js/video-list.js

@@ -1,4 +1,4 @@
-$(document).ready(function() {
+$(document).ready(function () {
     initList(".");
 });
 
@@ -10,7 +10,7 @@ function initList(dir) {
             dir: dir,
         },
         dataType: "json"
-    }).done(function(result) {
+    }).done(function (result) {
 
         $("#video-list").empty();
 
@@ -38,9 +38,10 @@ function initList(dir) {
             if (file_tables[j]["file_path"].includes(".m3u8")) {
                 $("#video-list").append('<div class="col-md-3">' +
                     '<section class="panel">' +
-                    "<a href='#' onclick='getVideo(" + file_tables[j]["title"].split("-")[0] + ")'>" +
-                    '<img class="static" src="./assets/videos/教育訓練/108年Revit上課影音檔/' + file_tables[j]["title"] + '.jpg">' +
-                    '<img class="active" src="./assets/videos/教育訓練/108年Revit上課影音檔/' + file_tables[j]["title"] + '.gif">' +
+                    "<a href='#' onclick='getVideo(" + file_tables[j]["id"] + ")'>" +
+                    '<img class="static" src="' + file_tables[j]["file_path"].replace("m3u8", "jpg") + '">' +
+                    '<img class="active" src="' + file_tables[j]["file_path"].replace("m3u8", "gif") +
+                    '">' +
                     '</a>' +
                     '<div class="panel-body" id="">' +
                     "<p><i class='fa fa-video-camera'></i><a href='#' onclick='getVideo(" + file_tables[j]["title"].split("-")[0] + ")'>" + file_tables[j]["title"] + "</a></p>" +
@@ -49,7 +50,7 @@ function initList(dir) {
                     '</div>');
             }
         }
-    }).error(function(error) {
+    }).error(function (error) {
         console.log(error);
     });
 }

+ 2 - 2
script/php/video/getDir.php

@@ -6,7 +6,7 @@ if (isset($_POST["dir"])) {
     $dir_tables = [];
     $dir = $_POST["dir"];
     $array = [];
-    $sql = "SELECT [title], [file_path] FROM [BIMComponents].[dbo].[Video_Table] WHERE dir_name = '" . $dir . "'";
+    $sql = "SELECT [id],[title], [file_path] FROM [BIMComponents].[dbo].[Video_Table] WHERE dir_name = '" . $dir . "'";
     $fetchResult = sqlsrv_query($conn, $sql);
     while ($row = sqlsrv_fetch_array($fetchResult, SQLSRV_FETCH_ASSOC)) {
         array_push($file_tables, $row);
@@ -28,4 +28,4 @@ if (isset($_POST["dir"])) {
     echo json_encode($array);
 
     sqlsrv_close($conn);
-}
+}

+ 5 - 5
script/php/videoToHLS.php

@@ -22,19 +22,19 @@ function Convert($file_path, $ffmpeg)
     $r_1080p = (new Representation)->setKiloBitrate(4096)->setResize(1920, 1080);
 
 
-   // if (!file_exists("../." . substr($file_path, 0, -4) . ".m3u8")) {
+    if (!file_exists("../." . substr($file_path, 0, -4) . ".m3u8")) {
         $video = $ffmpeg->open("../." . $file_path);
-       /* $video->hls()
+        $video->hls()
             ->x264()
             ->setHlsTime(300)
             ->addRepresentations([$r_1080p])
-            ->save("../." . substr($file_path, 0, -4) . ".m3u8");*/
+            ->save("../." . substr($file_path, 0, -4) . ".m3u8");
         $video->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(40))
             ->save("../." . substr($file_path, 0, -4) . ".jpg");
         $video
             ->gif(FFMpeg\Coordinate\TimeCode::fromSeconds(40), new FFMpeg\Coordinate\Dimension(640, 480), 5)
             ->save("../." . substr($file_path, 0, -4) . ".gif");
-   // }
+    }
 }
 
 
@@ -47,7 +47,7 @@ function FindPath($root, $folder, $ffmpeg)
     echo ("<ul>");
     foreach ($paths as $path) {
         if (str_contains($path, '.')) {
-            if (str_contains(strtolower($path), '.mp4')) {
+            if (str_contains(strtolower($path), '.mp4') || str_contains(strtolower($path), '.wmv')) {
                 echo ("<li data-jstree='{ " . '"type" : "file"' . " }' >");
                 $title = explode(".", $path)[0];
                 $file_path = substr($rootPath, 4) . "/" . $path;

+ 1 - 1
script/php/video_tools.php

@@ -40,7 +40,7 @@ function FindPath($root, $folder, $ffmpeg)
                  END";
                     $fetchResult = sqlsrv_query($GLOBALS["conn"], $sql);
                 }
-            } else if (!str_contains(strtolower($path), '.gif') && !str_contains(strtolower($path), '.jpg') && !str_contains(strtolower($path), '.ts') && !str_contains(strtolower($path), '.mp4')) {
+            } else if (!str_contains(strtolower($path), '.gif') && !str_contains(strtolower($path), '.jpg') && !str_contains(strtolower($path), '.ts') && !str_contains(strtolower($path), '.mp4') && !str_contains(strtolower($path), '.wmv')) {
                 echo ("<li data-jstree='{ " . '"type" : "file"' . " }' >");
                 $title = explode(".", $path)[0];
                 $type = explode(".", $path)[1];