PATH
remote: .
specs:
- atv (1.0.0)
+ atv (1.1.0)
iodine
GEM
<input type="button" value="Play" onclick="javascript:UI.play_pause()" id="playBtn"/>
<input type="button" value="Chan +" onclick="javascript:UI.chan_next()"/>
<input type="button" value="Chan -" onclick="javascript:UI.chan_prev()"/>
- <input type="button" value="Skip" onclick="javascript:UI.skip()"/>
+ </div>
+ <div class="row">
<input type="button" value="Enqueue" onclick="javascript:UI.select_file()"/>
+ <input type="button" value="Skip" onclick="javascript:UI.skip()"/>
</div>
</section>
</article>
else
{
UI.set_play_state(
- data["curr"]["path"], // Now Playing
+ data["curr"]["spath"], // Now Playing
data.playing // Playing or paused
);
}
<section>
<div class="row">
<input type="button" value="Enqueue" onclick="javascript:UI.select_file()"/>
+ <input type="button" value="Skip" onclick="javascript:UI.skip()"/>
</div>
</section>
</article>
else
{
UI.set_play_state(
- data["curr"]["path"], // Now Playing
+ data["curr"]["spath"], // Now Playing
data.playing // Playing or paused
);
}
SubtitleTrack.src = current["curr"]["path"] + ".vtt";
if (current["playing"])
{
- Video.play();
+ Video.play()
}
else
{
};
};
+const toggleMute = ()=>{
+ Video.muted = !Video.muted;
+ console.log(Video.muted);
+};
+
Video.addEventListener("ended", updatePlayer);
document.addEventListener("visibilitychange", updatePlayer);
+document.addEventListener("click", toggleMute);
+document.addEventListener("keypress", toggleMute);
(()=>{ connect(); })();
</script>
let path = [];
const showBrowser = ()=>{
- path = [];
browseView.style.display = "flex";
mainView.style.display = "none";
};
const showMain = ()=>{
- path = [];
browseView.style.display = "none";
mainView.style.display = "flex";
};
queueList.innerHTML = "";
for (const item of queue) {
const el = document.createElement("div");
- el.innerText = item.path;
+ el.innerText = item.spath;
queueList.appendChild(el);
}
} else {
for (const item of items) {
const el = document.createElement("div");
el.innerText = item.name;
- console.log(item);
- console.log('path' in item);
- if ('path' in item) {
- el.onclick = ()=>{ self.enqueue(item.path); };
+ if (item.type == "file") {
+ el.onclick = ()=>{
+ self.enqueue(path.concat(item.name).join("/"));
+ };
} else {
el.onclick = ()=>{ linkDown(item.name); };
}
CONFIG_PATH = "#{ATV_ROOT}/config.json"
DEFAULT_CONFIG = {
"sources" => [
+ "nas",
"local",
- "nas"
+ "usb"
],
"channels" => [
"Shorts",
"Shows",
"Photos",
- ]
+ ],
+ "ratios": {
+ "Movies": 1,
+ "TV Series": 2,
+ "Shorts": 4,
+ "Photos": 3
+ }
},
{
"name" => "Christmas",
channels = CONFIG["channels"].map do |c|
ATV::Channel.new(db, c)
-# ATV::Channel.new(c["name"], db, c["selectors"])
end
player = ATV::Player.new(db, channels)
@selectors = config["selectors"]
@play_ads = config["play_ads"]
@randomize = config["randomize"]
+ @ratios = config["ratios"]
# dynamic state
@time = 0
end
def pick_random()
- # random walk the tree to find a leaf item and play that
- tree = filedata[:tree]
+ if not @ratios.nil? then
+ options = @ratios.map {|e| Array.new(e[1], e[0]) }.flatten.map{|k| filedata[:tree][k] }.compact
+ else
+ options = filedata[:tree].values
+ end
+ random_walk(options.sample)
+ end
+
+ def random_walk(tree)
while tree["path"].nil?
tree = tree[tree.keys.sample]
end
index.each do |item|
short_path = item["path"]
item["path"] = URI::Parser.new.escape("#{source}/#{short_path}")
+ item["spath"] = short_path
@data[short_path] = item
end
rescue Exception => e
end.flatten.uniq.map do |e|
# Add item to the virtual directory tree
node = tree
- path = e.sub(%r{[^/]+/}, '').split("/")
+ path = e.split("/")
path[0..-2].each do |folder|
node[folder] ||= {}
node = node[folder]