]> git.mdlowis.com Git - proto/atv.git/commitdiff
added image support
authorMike Lowis <mike.lowis@gentex.com>
Tue, 9 Apr 2024 20:40:19 +0000 (16:40 -0400)
committerMike Lowis <mike.lowis@gentex.com>
Tue, 9 Apr 2024 20:40:19 +0000 (16:40 -0400)
atv/assets/index.html
atv/atv.gemspec
atv/bin/atv-index
atv/lib/atv/database.rb

index 108bb11a7339d5bed22ab5c25a26de2bc354773d..af912eb1d93931555feb31dabf17fbb12189a1a3 100644 (file)
@@ -12,6 +12,9 @@
 </head>
 <body>
 
+
+<img id="ImageView" src="" width="100%" height="100%" style="object-fit: scale-down; display: none">
+
 <video id="Video" width="100%" height="100%" src="" autoplay muted playsinline>
     <track id="SubtitleTrack"
         label="English"
@@ -73,15 +76,27 @@ const updatePlayer = (prev)=>{
 
     if (diffTooBig || srcChanged || playStateChanged || chanChanged)
     {
-        Video.src = current["curr"]["path"] + "#t=" + elapsed;
-        SubtitleTrack.src = current["curr"]["path"] + ".vtt";
-        if (current["playing"])
+        ImageView.style.display = "none";
+        Video.style.display = "none";
+
+        if (current["curr"]["type"] == "image")
         {
-            Video.play()
+            ImageView.style.display = "block";
+            ImageView.src = current["curr"]["path"];
         }
         else
         {
-            Video.pause();
+            Video.style.display = "block";
+            Video.src = current["curr"]["path"] + "#t=" + elapsed;
+            SubtitleTrack.src = current["curr"]["path"] + ".vtt";
+            if (current["playing"])
+            {
+                Video.play()
+            }
+            else
+            {
+                Video.pause();
+            }
         }
     }
 };
index 66ab806b2a68da4013f1eb80587cf9871ba1f7ad..26e16e20c97b87d8fd08cbd0e12022bf91a1fbdf 100644 (file)
@@ -1,6 +1,6 @@
 Gem::Specification.new do |s|
   s.name        = 'atv'
-  s.version     = '1.0.0'
+  s.version     = '1.1.0'
   s.licenses    = ['MIT']
   s.summary     = "Websocket server that simulates a TV station"
   s.description = "Websocket server that simulates a TV station"
index 1970ebe6dfae03482a5fac84bb73675bad71c2c0..b0c84da6964837d5c84fdb3d1a7e8ab8f5e1375c 100644 (file)
@@ -2,7 +2,10 @@
 
 require 'json'
 
-TYPES = "{mp4,ogg,webm}"
+IMG_TYPES = %w[jpg jpeg png]
+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"
 
@@ -10,17 +13,30 @@ ARGV.each do |root|
   # Generate the index
   index = []
   Dir.glob("#{root}/**/*.#{TYPES}").each do |path|
+    ext = path.sub(/.*\.([^.]+)$/, '\1').downcase
     short_path = path.sub("#{root}/", '')
     puts short_path
-    duration = `#{CMD} \"#{path}\"`.chomp.to_f
-    entry = {
-      "path" => short_path,
-      "duration" => duration
-    }
-    index << entry
+
+    if (VID_TYPES.include?(ext))
+      duration = `#{CMD} \"#{path}\"`.chomp.to_f
+      index << {
+        "type"     => "video",
+        "path"     => short_path,
+        "duration" => duration
+      }
+    elsif (IMG_TYPES.include?(ext))
+      index << {
+        "type"     => "image",
+        "path"     => short_path,
+        "duration" => 10
+      }
+    else
+      puts "skipping: #{path}"
+    end
   end
 
   # Save the index to disc
+  pp index
   File.open("#{root}/index.json", "wb") do |f|
     f.write JSON.dump(index)
   end
index a925afbdeb67f8e8d44b60f12bdf2fa49b979ea0..28e42694b82fca8f355063c0430d68d0cdde1728 100644 (file)
@@ -29,7 +29,7 @@ module ATV
           puts "Failed to open URI #{uri}: #{e}"
         end
       end
-      pp @data
+#      pp @data
     end
 
     def files
@@ -66,7 +66,7 @@ module ATV
 
         # save off the tree
         @cache[channel][:tree] = tree
-        pp @cache[channel]
+#        pp @cache[channel]
 
       end
       @cache[channel]