From c0dbfc813092faece53015c0f86313d742f7815a Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Tue, 9 Jul 2019 11:10:08 -0500 Subject: 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 --- apps/plugins/lua/rocklib.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'apps/plugins/lua/rocklib.c') 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(); -- cgit v1.2.3