summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorWilliam Wilgus <me.theuser@yahoo.com>2019-07-09 11:10:08 -0500
committerWilliam Wilgus <me.theuser@yahoo.com>2019-07-10 05:07:25 +0200
commitc0dbfc813092faece53015c0f86313d742f7815a (patch)
treee9e116d1f01afc0281864bc642565649ca67468f /apps
parent152e415b0d0d11078578e3268776465ffc58871a (diff)
lua add track length & elapsed to rb.audio()
track elapsed is needed to use fast-forward and rewind effectively track length might as well be added too.. Change-Id: I906c92eb5260164c6177d8c0a8ff879b1fad7898
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/lua/rocklib.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c
index 6c96f37a94..9ad6411b2f 100644
--- a/apps/plugins/lua/rocklib.c
+++ b/apps/plugins/lua/rocklib.c
@@ -314,10 +314,14 @@ RB_WRAP(audio)
{
enum e_audio {AUDIO_STATUS = 0, AUDIO_PLAY, AUDIO_STOP, AUDIO_PAUSE,
AUDIO_RESUME, AUDIO_NEXT, AUDIO_PREV, AUDIO_FFREWIND,
- AUDIO_FLUSHANDRELOADTRACKS, AUDIO_GETPOS, AUDIO_ECOUNT};
- const char *audio_option[] = {"status", "play", "stop", "pause",
- "resume", "next", "prev", "ff_rewind",
- "flush_and_reload_tracks", "get_file_pos", NULL};
+ AUDIO_FLUSHANDRELOADTRACKS, AUDIO_GETPOS, AUDIO_LENGTH,
+ AUDIO_ELAPSED, AUDIO_ECOUNT};
+ const char *audio_option[] = {"status", "play", "stop",
+ "pause", "resume", "next",
+ "prev", "ff_rewind",
+ "flush_and_reload_tracks",
+ "get_file_pos", "length",
+ "elapsed", NULL};
long elapsed, offset, newtime;
int status = rb->audio_status();
@@ -365,6 +369,18 @@ RB_WRAP(audio)
case AUDIO_GETPOS:
lua_pushinteger(L, rb->audio_get_file_pos());
return 1;
+ case AUDIO_LENGTH:
+ if ((status & AUDIO_STATUS_PLAY) == AUDIO_STATUS_PLAY)
+ lua_pushinteger(L, rb->audio_current_track()->length);
+ else
+ lua_pushnil(L);
+ return 1;
+ case AUDIO_ELAPSED:
+ if ((status & AUDIO_STATUS_PLAY) == AUDIO_STATUS_PLAY)
+ lua_pushinteger(L, rb->audio_current_track()->elapsed);
+ else
+ lua_pushnil(L);
+ return 1;
}
rb->yield();