From: Mike Lowis Date: Fri, 15 Mar 2024 17:51:01 +0000 (-0400) Subject: added randomization, made QR tags bigger and split out css to separate file X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=c672280e0e5af6d516a56f0ef24fa4da18574382;p=proto%2Fatv.git added randomization, made QR tags bigger and split out css to separate file --- diff --git a/atv/assets/admin.html b/atv/assets/admin.html index 13ec436..a27b3da 100644 --- a/atv/assets/admin.html +++ b/atv/assets/admin.html @@ -3,98 +3,7 @@ - + diff --git a/atv/assets/control.html b/atv/assets/control.html index f5657dd..d1c0cbe 100644 --- a/atv/assets/control.html +++ b/atv/assets/control.html @@ -3,104 +3,7 @@ - + diff --git a/atv/assets/index.html b/atv/assets/index.html index 604eaff..8a01ead 100644 --- a/atv/assets/index.html +++ b/atv/assets/index.html @@ -46,12 +46,12 @@
-
+
WIFI
-
+
APP
diff --git a/atv/assets/style.css b/atv/assets/style.css new file mode 100644 index 0000000..55a8595 --- /dev/null +++ b/atv/assets/style.css @@ -0,0 +1,95 @@ + html, body { + margin: 0; + padding: 0; + width: 100%; + height: 100%; + max-height: 100%; + background-color: #eaeaea; + overflow: hidden; + } + + .table { + display: block; + } + + .row { + display: flex; + flex: 1 0 auto; + border-bottom: 1px solid black; + } + + .label { + flex-shrink: 1; + padding: 1em; + width: 8em; + border-right: 1px solid black; + } + + .item { + flex-grow: 1; + border-left: 0; + padding: 1em; + } + + .row input { + flex-grow: 1; + height: 4em; + } + + td { + border: 1px solid #000; + padding: 1em; + } + + tr td:first-child { + width: 1%; + white-space: nowrap; + } + + input { + margin: 0.5em; + } + + article { + display: flex; + flex-flow: column; + height: 100%; + max-height: 100%; + } + + article section { + //border: 1px dotted black; + flex: 0 1 auto; + } + + .grow { + flex: 1 1 auto; + overflow: auto; + } + + .shrink { + flex: 0 1 auto; + } + + #breadCrumbs { + margin-left: 1em; + margin-right: 1em; + } + + #itemList { + margin-left: 1em; + margin-right: 1em; + } + + #itemList div { + background-color: #A7BDC7; + padding: 1em; + margin: 0.5em; + } + + #queueList div { + background-color: #A7BDC7; + padding: 1em; + margin: 0.5em; + text-align: left; + } diff --git a/atv/bin/atv b/atv/bin/atv index 88ad9ca..c46cfbf 100755 --- a/atv/bin/atv +++ b/atv/bin/atv @@ -18,7 +18,7 @@ DEFAULT_CONFIG = { "channels" => [ { "name" => "Everything", - "randomize" => false, + "randomize" => true, "play_ads" => true, "selectors" => [ "Movies", @@ -55,7 +55,8 @@ end db = ATV::Database.new(ATV_ROOT, CONFIG["sources"]) channels = CONFIG["channels"].map do |c| - ATV::Channel.new(c["name"], db, c["selectors"]) + ATV::Channel.new(db, c) +# ATV::Channel.new(c["name"], db, c["selectors"]) end player = ATV::Player.new(db, channels) diff --git a/atv/lib/atv/channel.rb b/atv/lib/atv/channel.rb index 35cfe9d..42a2c26 100644 --- a/atv/lib/atv/channel.rb +++ b/atv/lib/atv/channel.rb @@ -1,9 +1,14 @@ module ATV class Channel - def initialize(name, db, selectors = []) - @name = name + def initialize(db, config) + # configuration @db = db - @selectors = selectors + @name = config["name"] + @selectors = config["selectors"] + @play_ads = config["play_ads"] + @randomize = config["randomize"] + + # dynamic state @time = 0 @index = 0 @queue = [] @@ -25,12 +30,23 @@ module ATV @time = 0 if @queue.length > 0 @current = @queue.shift + elsif @randomize + @current = pick_random() else @index = ((@index+1) >= files.length ? 0 : (@index+1)) @current = files[@index] end end + def pick_random() + # random walk the tree to find a leaf item and play that + tree = filedata[:tree] + while tree["path"].nil? + tree = tree[tree.keys.sample] + end + tree + end + def state() next_index = ((@index+1) >= files.length ? 0 : (@index+1)) next_item = (@queue.length > 0 ? @queue.first : files[next_index]) @@ -65,7 +81,6 @@ module ATV end def items() -# pp filedata[:tree] { "items" => filedata[:tree] } end