|
|
@ -9,6 +9,7 @@ local playback = require("playback") |
|
|
|
local theme = require("theme") |
|
|
|
local theme = require("theme") |
|
|
|
local screen = require("screen") |
|
|
|
local screen = require("screen") |
|
|
|
local database = require("database") |
|
|
|
local database = require("database") |
|
|
|
|
|
|
|
local img = require("images") |
|
|
|
|
|
|
|
|
|
|
|
return screen:new{ |
|
|
|
return screen:new{ |
|
|
|
create_ui = function(self) |
|
|
|
create_ui = function(self) |
|
|
@ -54,43 +55,66 @@ return screen:new{ |
|
|
|
} |
|
|
|
} |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
local buttons = header:Object({ |
|
|
|
if (self.mediatype == database.MediaTypes.Music) then |
|
|
|
flex = { |
|
|
|
local buttons = header:Object({ |
|
|
|
flex_direction = "row", |
|
|
|
flex = { |
|
|
|
flex_wrap = "wrap", |
|
|
|
flex_direction = "row", |
|
|
|
justify_content = "space-between", |
|
|
|
flex_wrap = "wrap", |
|
|
|
align_items = "center", |
|
|
|
justify_content = "space-between", |
|
|
|
align_content = "center" |
|
|
|
align_items = "center", |
|
|
|
}, |
|
|
|
align_content = "center" |
|
|
|
w = lvgl.PCT(100), |
|
|
|
}, |
|
|
|
h = lvgl.SIZE_CONTENT, |
|
|
|
w = lvgl.PCT(100), |
|
|
|
pad_column = 4 |
|
|
|
h = lvgl.SIZE_CONTENT, |
|
|
|
}) |
|
|
|
pad_column = 4 |
|
|
|
local original_iterator = self.iterator:clone() |
|
|
|
}) |
|
|
|
local enqueue = widgets.IconBtn(buttons, "//lua/img/enqueue.png", "Enqueue") |
|
|
|
local original_iterator = self.iterator:clone() |
|
|
|
enqueue:onClicked(function() |
|
|
|
local enqueue = widgets.IconBtn(buttons, "//lua/img/enqueue.png", "Enqueue") |
|
|
|
queue.add(original_iterator) |
|
|
|
enqueue:onClicked(function() |
|
|
|
playback.playing:set(true) |
|
|
|
queue.add(original_iterator) |
|
|
|
end) |
|
|
|
playback.playing:set(true) |
|
|
|
local shuffle_play = widgets.IconBtn(buttons, "//lua/img/shuffleplay.png", "Shuffle") |
|
|
|
end) |
|
|
|
shuffle_play:onClicked(function() |
|
|
|
local shuffle_play = widgets.IconBtn(buttons, "//lua/img/shuffleplay.png", "Shuffle") |
|
|
|
queue.clear() |
|
|
|
shuffle_play:onClicked(function() |
|
|
|
queue.random:set(true) |
|
|
|
queue.clear() |
|
|
|
queue.add(original_iterator) |
|
|
|
queue.random:set(true) |
|
|
|
playback.playing:set(true) |
|
|
|
queue.add(original_iterator) |
|
|
|
backstack.push(playing:new()) |
|
|
|
playback.playing:set(true) |
|
|
|
end) |
|
|
|
backstack.push(playing:new()) |
|
|
|
-- enqueue:add_flag(lvgl.FLAG.HIDDEN) |
|
|
|
end) |
|
|
|
local play = widgets.IconBtn(buttons, "//lua/img/play_small.png", "Play") |
|
|
|
-- enqueue:add_flag(lvgl.FLAG.HIDDEN) |
|
|
|
play:onClicked(function() |
|
|
|
local play = widgets.IconBtn(buttons, "//lua/img/play_small.png", "Play") |
|
|
|
queue.clear() |
|
|
|
play:onClicked(function() |
|
|
|
queue.random:set(false) |
|
|
|
queue.clear() |
|
|
|
queue.add(original_iterator) |
|
|
|
queue.random:set(false) |
|
|
|
playback.playing:set(true) |
|
|
|
queue.add(original_iterator) |
|
|
|
backstack.push(playing:new()) |
|
|
|
playback.playing:set(true) |
|
|
|
end) |
|
|
|
backstack.push(playing:new()) |
|
|
|
|
|
|
|
end) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local get_icon_func = nil |
|
|
|
|
|
|
|
local show_listened = self.mediatype == database.MediaTypes.Audiobook or self.mediatype == database.MediaTypes.Podcast |
|
|
|
|
|
|
|
if show_listened then |
|
|
|
|
|
|
|
get_icon_func = function (item) |
|
|
|
|
|
|
|
local contents = item:contents() |
|
|
|
|
|
|
|
if type(contents) == "userdata" then |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
local track = database.track_by_id(contents) |
|
|
|
|
|
|
|
if not track then return end |
|
|
|
|
|
|
|
if (track.play_count > 0) then |
|
|
|
|
|
|
|
return img.listened |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
return img.unlistened |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
widgets.InfiniteList(self.root, self.iterator, { |
|
|
|
widgets.InfiniteList(self.root, self.iterator, { |
|
|
|
|
|
|
|
get_icon = get_icon_func, |
|
|
|
callback = function(item) |
|
|
|
callback = function(item) |
|
|
|
return function() |
|
|
|
return function() |
|
|
|
local contents = item:contents() |
|
|
|
local contents = item:contents() |
|
|
@ -98,6 +122,7 @@ return screen:new{ |
|
|
|
backstack.push(require("browser"):new{ |
|
|
|
backstack.push(require("browser"):new{ |
|
|
|
title = self.title, |
|
|
|
title = self.title, |
|
|
|
iterator = contents, |
|
|
|
iterator = contents, |
|
|
|
|
|
|
|
mediatype = self.mediatype, |
|
|
|
breadcrumb = tostring(item) |
|
|
|
breadcrumb = tostring(item) |
|
|
|
}) |
|
|
|
}) |
|
|
|
else |
|
|
|
else |
|
|
|