|
|
@ -13,6 +13,7 @@ local theme = require("theme") |
|
|
|
local playback = require("playback") |
|
|
|
local playback = require("playback") |
|
|
|
local queue = require("queue") |
|
|
|
local queue = require("queue") |
|
|
|
local table_iterator = require("table_iterator") |
|
|
|
local table_iterator = require("table_iterator") |
|
|
|
|
|
|
|
local img = require("images") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return screen:new { |
|
|
|
return screen:new { |
|
|
@ -59,28 +60,49 @@ return screen:new { |
|
|
|
} |
|
|
|
} |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
local playlists = {} |
|
|
|
local is_playlist = function(item) |
|
|
|
-- Find playlists |
|
|
|
return item:filepath():match("%.playlist$") |
|
|
|
local fs_iter = filesystem.iterator("") |
|
|
|
or item:filepath():match("%.m3u8?$") |
|
|
|
for item in fs_iter do |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local get_icon_func = function(item) |
|
|
|
|
|
|
|
if item:is_directory() then |
|
|
|
|
|
|
|
return img.files |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
return img.enqueue |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local playlists_and_dirs = {}; |
|
|
|
|
|
|
|
for item in self.iterator do |
|
|
|
if |
|
|
|
if |
|
|
|
item:filepath():match("%.playlist$") or |
|
|
|
is_playlist(item) or |
|
|
|
item:filepath():match("%.m3u8?$") then |
|
|
|
item:is_directory() then |
|
|
|
table.insert(playlists, item) |
|
|
|
table.insert(playlists_and_dirs, item) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
widgets.InfiniteList(self.root, table_iterator:create(playlists), { |
|
|
|
widgets.InfiniteList(self.root, table_iterator:create(playlists_and_dirs), { |
|
|
|
focus_first_item = true, |
|
|
|
focus_first_item = true, |
|
|
|
|
|
|
|
get_icon = get_icon_func, |
|
|
|
callback = function(item) |
|
|
|
callback = function(item) |
|
|
|
return function() |
|
|
|
return function() |
|
|
|
queue.open_playlist(item:filepath()) |
|
|
|
if item:is_directory() then |
|
|
|
playback.playing:set(true) |
|
|
|
backstack.push( |
|
|
|
backstack.push(playing:new()) |
|
|
|
require("playlist_browser"):new { |
|
|
|
|
|
|
|
title = self.title, |
|
|
|
|
|
|
|
iterator = filesystem.iterator(item:filepath()), |
|
|
|
|
|
|
|
breadcrumb = item:filepath() |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
elseif |
|
|
|
|
|
|
|
is_playlist(item) then |
|
|
|
|
|
|
|
-- TODO: playlist viewer |
|
|
|
|
|
|
|
queue.open_playlist(item:filepath()) |
|
|
|
|
|
|
|
playback.playing:set(true) |
|
|
|
|
|
|
|
backstack.push(playing:new()) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
}) |
|
|
|
}) |
|
|
|
end |
|
|
|
end |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|