summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins')
-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();