<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"
{
ImageView.style.display = "block";
ImageView.src = current["curr"]["path"];
+ Video.src = ""; // make sure no video is playing in the background
}
else
{
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
index << {
"type" => "image",
"path" => short_path,
- "duration" => 10
+ "duration" => image_duration(path)
}
else
puts "skipping: #{path}"
end
# Save the index to disc
- pp index
File.open("#{root}/index.json", "wb") do |f|
f.write JSON.dump(index)
end