1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
--[[ Lua RB Playlist Operations
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2018 William Wilgus
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
]]
-- [[ conversion to old style playlist_ functions ]]
if not rb.playlist then rb.splash(rb.HZ, "No Support!") return nil end
rb.playlist_amount = function()
return rb.playlist("amount")
end
rb.playlist_add = function (filename)
return rb.playlist("insert_track", filename, rb.PLAYLIST_INSERT_LAST, false, true)
end
rb.playlist_create = function(dir, filename)
return rb.playlist("create", dir, filename)
end
rb.playlist_start = function(index, elapsed, offset)
rb.playlist("start", index, elapsed, offset)
end
rb.playlist_resume_track = function(index, crc, elapsed, offset)
rb.playlist("resume_track", index, crc, elapsed, offset)
end
rb.playlist_resume = function() return rb.playlist("resume") end
rb.playlist_shuffle = function(random_seed, index)
rb.playlist("shuffle", random_seed, index)
end
rb.playlist_sync = function () rb.playlist("sync") end
rb.playlist_remove_all_tracks = function() return rb.playlist("remove_all_tracks") end
rb.playlist_insert_track = function(filename, pos, bqueue, bsync)
return rb.playlist("insert_track", filename, pos, bqueue, bsync)
end
rb.playlist_insert_directory = function(dir, pos, bqueue, brecurse)
return rb.playlist("insert_directory", dir, pos, bqueue, brecurse)
end
rb.playlist_tracks = function(dir, filename)
local tracks = {}
local count = 0
local fullpath = dir .. "/" .. filename
local file = io.open('/' .. fullpath, "r")
if not file then
rb.splash(rb.HZ, "Error opening /" .. fullpath)
return tracks
end
-- strip BOM --"\xEF\xBB\xBF"
local bom = file:read(3)
if not string.find(bom, "\239\187\191") then
file:seek("set", 0)
end
for line in file:lines() do
if string.len(line) > 3 and (not string.find(line, "%s*#.*")) then
count = count + 1
tracks[count] = line
end
end
file:close()
return tracks
end
|