From b670fcd50d42085a2db978bbcf2ccfd889d740ef Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Wed, 24 Oct 2018 10:49:52 -0400 Subject: lua add audio_play consolidate audio_ functions audio_play was removed from the rocklib I assume due to inconsistent behavior I've readded it with a check for audio paused which instead uses rewind/ff and then resumes audio the way to call the audio functions has changed as well rb.audio("option", var) so rb.audio_play(0, 0) becomes rb.audio("play", 0, 0) audio_audio_flush_and_reload_tracks becomes rb.audio("flushandreloadtracks") all functions except audio("getfilepos") return the previous (or still current) status added audio.lua to the includes for conversion to old functions if your script is broken by this change you simply add `require("audio")` to the top for the old functionality Change-Id: I364adf0c85d9c12b98cde29c26fbe5ee05b9d331 --- apps/plugins/lua/include_lua/audio.lua | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 apps/plugins/lua/include_lua/audio.lua (limited to 'apps/plugins/lua/include_lua') diff --git a/apps/plugins/lua/include_lua/audio.lua b/apps/plugins/lua/include_lua/audio.lua new file mode 100644 index 0000000000..51e5fbe228 --- /dev/null +++ b/apps/plugins/lua/include_lua/audio.lua @@ -0,0 +1,36 @@ +--[[ Lua RB Audio Operations +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2017 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 audio_ functions ]] +if not rb.audio then rb.splash(rb.HZ, "No Support!") return nil end + +rb.audio_status = function() return rb.audio("status") end +rb.audio_play = function (elapsed, offset) rb.audio("play", elapsed, offset) end +rb.audio_stop = function() rb.audio("stop") end +rb.audio_pause = function() rb.audio("pause") end +rb.audio_resume = function() rb.audio("resume") end +rb.audio_next = function() rb.audio("next") end +rb.audio_prev = function() rb.audio("prev") end +rb.audio_ff_rewind = function (newtime) rb.audio("ffrewind", newtime) end +rb.audio_flush_and_reload_tracks = function() rb.audio("flushandreloadtracks") end +rb.audio_get_file_pos = function() return rb.audio("getfilepos") end -- cgit v1.2.3