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
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c
index 6c96f37..9ad6411 100644
--- a/apps/plugins/lua/rocklib.c
+++ b/apps/plugins/lua/rocklib.c
@@ -314,10 +314,14 @@
{
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 @@
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();