A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 77 lines 3.0 kB view raw
1--[[ 2 __________ __ ___. 3 Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 \/ \/ \/ \/ \/ 8 $Id$ 9 Example Lua File Viewer script 10 Copyright (C) 2020 William Wilgus 11 This program is free software; you can redistribute it and/or 12 modify it under the terms of the GNU General Public License 13 as published by the Free Software Foundation; either version 2 14 of the License, or (at your option) any later version. 15 This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 16 KIND, either express or implied. 17]]-- 18 19require("actions") -- Contains rb.actions & rb.contexts 20-- require("buttons") -- Contains rb.buttons -- not needed for this example 21 22--local _timer = require("timer") 23--local _clr = require("color") -- clrset, clrinc provides device independent colors 24local _lcd = require("lcd") -- lcd helper functions 25--local _print = require("print") -- advanced text printing 26--local _img = require("image") -- image manipulation save, rotate, resize, tile, new, load 27--local _blit = require("blit") -- handy list of blit operations 28--local _draw = require("draw") -- draw all the things (primitives) 29--local _math = require("math_ex") -- missing math sine cosine, sqrt, clamp functions 30 31 32local scrpath = rb.current_path()--rb.PLUGIN_DIR .. "/demos/lua_scripts/" 33 34package.path = scrpath .. "/?.lua;" .. package.path --add lua_scripts directory to path 35 36require("printmenus") --menu 37require("filebrowse") -- file browser 38 39rb.actions = nil 40package.loaded["actions"] = nil 41 42-- uses print_table to display a menu 43function main_menu() 44 local mt = { 45 [1] = "Rocklua File Browser Example", 46 [2] = "Sort by Name", 47 [3] = "Sort by Size", 48 [4] = "Sort by Date", 49 [5] = "Exit" 50 } 51 52 local ft = { 53 [0] = exit_now, --if user cancels do this function 54 [1] = function(TITLE) return true end, -- shouldn't happen title occupies this slot 55 [2] = function(SBNAME) 56 _lcd:splashf(rb.HZ, "%s", file_choose("/", "", "name", false) or "None") 57 end, 58 [3] = function(SBSIZE) 59 _lcd:splashf(rb.HZ, "%s", file_choose("/", "", "size", true) or "None") 60 end, 61 [4] = function(SBDATE) 62 _lcd:splashf(rb.HZ, "%s", file_choose("/", "", "date") or "None") 63 end, 64 [5] = function(EXIT_) return true end 65 } 66 67 print_menu(mt, ft) 68 69end 70 71function exit_now() 72 _lcd:update() 73 os.exit() 74end -- exit_now 75 76main_menu() 77exit_now()