+PATH
+ remote: .
+ specs:
+ atv (1.0.0)
+ iodine
+
GEM
- remote: https://rubygems.org/
specs:
diff-lcs (1.5.0)
docile (1.4.0)
- gentex-gems-teamcity_utils (1.13.2)
- nokogiri (~> 1.6)
- rexml (~> 3.0)
- gentex-gpkg (1.29.0)
- bundler
- rexml (~> 3.0)
- yawpa (~> 1.1)
- json (2.7.1)
- nokogiri (1.13.8-x86_64-linux)
- racc (~> 1.4)
- racc (1.6.0)
+ iodine (0.7.55)
rake (13.1.0)
- rexml (3.2.5)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
yard (0.9.34)
- yawpa (1.3.0)
PLATFORMS
- x86_64-linux
+ ruby
DEPENDENCIES
- gentex-gems-teamcity_utils (~> 1.3)
- gentex-gpkg (>= 1.16, < 99.0)
- json (~> 2.0)
+ atv!
rake (~> 13.0)
rspec (~> 3.0)
simplecov (~> 0.9)
yard (~> 0.9)
BUNDLED WITH
- 2.4.7
+ 2.1.4
end
require "rake/clean"
-require "gpkg/rake_tasks"
+require "bundler/gem_tasks"
require "rspec"
require "rspec/core/rake_task"
require "yard"
require "simplecov"
-require "json"
-require "gentex/gems/teamcity_utils"
CLEAN.include "pkg"
CLEAN.include "coverage"
CLOBBER.include ".yardoc"
CLOBBER.include "doc"
-task :default => :spec
-
RSpec::Core::RakeTask.new(:spec, :example_string) do |task, args|
if args.example_string
ENV["partial_specs"] = "1"
end
end
-task :spec do
- # Report coverage % to TeamCity
- if Gentex::Gems::TeamcityUtils.server_exec?
- begin
- cov_pct = JSON.load(File.read("coverage/.last_run.json"))["result"]["line"]
- Gentex::Gems::TeamcityUtils.append_build_status(" (cov: #{cov_pct}%)")
- rescue Exception => e
- $stderr.puts "Error reporting coverage: #{e.message}"
- end
- end
-end
-
YARD::Rake::YardocTask.new do |yard|
yard.options = ["--private", "--title", "atv gem"]
yard.files = ["lib/**/*.rb"]
end
end
-task :build_pkg => :yard
+task :build => :yard
task :default => [
:spec,
- :yard,
- :build_pkg,
+ :build,
]
</video>
<script>
-const updatePlayer = (data)=>{
- console.log(data["curr"]);
- console.log(data["curr"]["duration"])
- const duration = data["curr"]["duration"];
- const elapsed = data["time"]
- if (elapsed > 0 && elapsed < duration)
+let current = {};
+
+const secondsSinceMidnight = ()=>{
+ const now = new Date();
+ const midnight = new Date(
+ now.getFullYear(),
+ now.getMonth(),
+ now.getDate(),
+ 0,0,0);
+ return (now.getTime() - midnight.getTime()) / 1000;
+};
+
+const updatePlayer = ()=>{
+ const curr_time = secondsSinceMidnight();
+ if (!current["start_time"])
+ {
+ current["start_time"] = secondsSinceMidnight() - current["time"];
+ }
+ console.log(current);
+ const start_time = current["start_time"];
+ const duration = current["curr"]["duration"];
+ const elapsed = Math.floor(curr_time - start_time);
+ if (elapsed >= 0 && elapsed < duration)
{
- Video.src = data["curr"]["path"] + "#t=" + Math.floor(elapsed);
+ Video.src = current["curr"]["path"] + "#t=" + Math.floor(elapsed);
}
};
const Cmd = {
play: (data)=>{
- console.log(data);
- updatePlayer(data);
+ current = data;
+ updatePlayer();
}
};
-# -*- encoding: utf-8 -*-
-require "gpkg/gem_specification"
-lib = File.expand_path("../lib", __FILE__)
-$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
+Gem::Specification.new do |s|
+ s.name = 'atv'
+ s.version = '1.0.0'
+ s.licenses = ['MIT']
+ s.summary = "Websocket server that simulates a TV station"
+ s.description = "Websocket server that simulates a TV station"
+ s.authors = ["Mike Lowis"]
+ s.email = 'mike@mdlowis.com'
+ s.files = Dir.glob(["{bin,assets,lib,doc}/**/*", "*.gemspec"]).select {|f| File.file?(f)}
+# s.homepage = 'https://rubygems.org/gems/example'
+# s.metadata = { "source_code_uri" => "https://github.com/example/example" }
+ s.bindir = "bin"
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
-Gpkg.gem_specification do |gpkg|
- gpkg.name = "gems/atv"
- gpkg.version = "1.0.0"
- gpkg.authors = ["Mike Lowis"]
- gpkg.email = ["mike@mdlowis.com"]
- gpkg.summary = %q{Websocket server that simulates a TV station}
- gpkg.description = %q{Websocket server that simulates a TV station}
- gpkg.homepage = ""
- gpkg.licenses = ["Nonstandard"]
+ s.add_dependency "iodine"
- gpkg.files = Dir.glob(["{bin,assets,lib,doc}/**/*", "*.gemspec"]).select {|f| File.file?(f)}
+ s.add_development_dependency "rspec", "~> 3.0"
+ s.add_development_dependency "simplecov", "~> 0.9"
+ s.add_development_dependency "yard", "~> 0.9"
+ s.add_development_dependency "rake", "~> 13.0"
- gpkg.executables = gpkg.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
- gpkg.test_files = gpkg.files.grep(%r{^(test|spec|features)/})
- gpkg.require_paths = ["lib"]
-
- gpkg.add_development_dependency "json", "~> 2.0"
- gpkg.add_development_dependency "rspec", "~> 3.0"
- gpkg.add_development_dependency "simplecov", "~> 0.9"
- gpkg.add_development_dependency "yard", "~> 0.9"
- gpkg.add_development_dependency "rake", "~> 13.0"
end
require 'atv/player'
require 'atv/server'
-db = ATV::Database.new(ENV["ETV_ROOT"] || "/var/www/atv")
+db = ATV::Database.new(ENV["ATV_ROOT"] || "/var/www/atv")
channels = [
ATV::Channel.new('Everything', db,
["Movies", "Shorts", "Shows"])
@items = selectors.map do |sel|
files.select {|f| f["path"].start_with? sel }
end.flatten.shuffle
- @time = @items[@index]["duration"] - 10
+# @time = @items[@index]["duration"] - 10
end
def update(playing)
+ return false if @items.length == 0
@time += 1 if playing
item = @items[@index]
if @time >= item["duration"] then
@index = 0
end
@time = 0
- @time = @items[@index]["duration"] - 10
+# @time = @items[@index]["duration"] - 10
end
def state()
def load()
if File.exist? @path
@data = JSON.parse(File.read(@path))
- else
- scan()
- save()
end
+ scan()
+ save()
end
def save()
end
def scan()
- Dir.glob("#{@path}/**/*.{mp4,webm,ogg}").each do |f|
- next if @data[f]
+ Dir.glob("#{@root}/**/*.{mp4,webm,ogg}").each do |f|
+ short_path = f.sub("#{@root}/", '')
+ next if @data[short_path]
+ puts f
duration = `#{CMD} \"#{f}\"`.chomp.to_f
- @data[f] = { "duration" => duration }
+ @data[short_path] = { "duration" => duration }
end
end
end