]> git.mdlowis.com Git - proto/atv.git/commitdiff
added gif support :)
authorMike Lowis <mike.lowis@gentex.com>
Wed, 10 Apr 2024 20:27:39 +0000 (16:27 -0400)
committerMike Lowis <mike.lowis@gentex.com>
Wed, 10 Apr 2024 20:27:39 +0000 (16:27 -0400)
atv/assets/index.html
atv/bin/atv-index

index af912eb1d93931555feb31dabf17fbb12189a1a3..8fb716869ea07aa734457fb8fed9ac6f2aa1faa1 100644 (file)
@@ -13,7 +13,7 @@
 <body>
 
 
-<img id="ImageView" src="" width="100%" height="100%" style="object-fit: scale-down; display: none">
+<img id="ImageView" src="" width="100%" height="100%" style="object-fit: contain; display: none">
 
 <video id="Video" width="100%" height="100%" src="" autoplay muted playsinline>
     <track id="SubtitleTrack"
@@ -83,6 +83,7 @@ const updatePlayer = (prev)=>{
         {
             ImageView.style.display = "block";
             ImageView.src = current["curr"]["path"];
+            Video.src = ""; // make sure no video is playing in the background
         }
         else
         {
index b0c84da6964837d5c84fdb3d1a7e8ab8f5e1375c..7ae447edf72f2bbd817f252243b05336c1dadff5 100644 (file)
@@ -2,12 +2,25 @@
 
 require 'json'
 
-IMG_TYPES = %w[jpg jpeg png]
+IMG_TYPES = %w[jpg jpeg png gif]
 VID_TYPES = %w[mp4 ogg webm]
 
 TYPES = "{#{(IMG_TYPES + VID_TYPES).join(",")}}"
 FILES = []
 CMD="ffprobe -show_entries format=duration -v quiet -of csv=\"p=0\" -i"
+DEFAULT_IMAGE_DURATION = 10
+
+def image_duration(path)
+  if path.end_with? "gif"
+    seconds = `#{CMD} \"#{path}\"`.chomp.to_f
+    if seconds < DEFAULT_IMAGE_DURATION then
+      seconds = ((DEFAULT_IMAGE_DURATION / seconds).floor * seconds)
+    end
+    seconds
+  else
+    DEFAULT_IMAGE_DURATION
+  end
+end
 
 ARGV.each do |root|
   # Generate the index
@@ -28,7 +41,7 @@ ARGV.each do |root|
       index << {
         "type"     => "image",
         "path"     => short_path,
-        "duration" => 10
+        "duration" => image_duration(path)
       }
     else
       puts "skipping: #{path}"
@@ -36,7 +49,6 @@ ARGV.each do |root|
   end
 
   # Save the index to disc
-  pp index
   File.open("#{root}/index.json", "wb") do |f|
     f.write JSON.dump(index)
   end