</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"
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();
+ }
}
}
};
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"
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"
# 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
puts "Failed to open URI #{uri}: #{e}"
end
end
- pp @data
+# pp @data
end
def files
# save off the tree
@cache[channel][:tree] = tree
- pp @cache[channel]
+# pp @cache[channel]
end
@cache[channel]