diff options
author | William Wilgus <me.theuser@yahoo.com> | 2019-07-09 11:10:08 -0500 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2019-07-10 05:07:25 +0200 |
commit | c0dbfc813092faece53015c0f86313d742f7815a (patch) | |
tree | e9e116d1f01afc0281864bc642565649ca67468f /apps/plugins/lua/rocklib.c | |
parent | 152e415b0d0d11078578e3268776465ffc58871a (diff) | |
download | rockbox-c0dbfc813092faece53015c0f86313d742f7815a.tar.gz rockbox-c0dbfc813092faece53015c0f86313d742f7815a.zip |
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/plugins/lua/rocklib.c')
-rw-r--r-- | apps/plugins/lua/rocklib.c | 24 |
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) | |||
314 | { | 314 | { |
315 | enum e_audio {AUDIO_STATUS = 0, AUDIO_PLAY, AUDIO_STOP, AUDIO_PAUSE, | 315 | enum e_audio {AUDIO_STATUS = 0, AUDIO_PLAY, AUDIO_STOP, AUDIO_PAUSE, |
316 | AUDIO_RESUME, AUDIO_NEXT, AUDIO_PREV, AUDIO_FFREWIND, | 316 | AUDIO_RESUME, AUDIO_NEXT, AUDIO_PREV, AUDIO_FFREWIND, |
317 | AUDIO_FLUSHANDRELOADTRACKS, AUDIO_GETPOS, AUDIO_ECOUNT}; | 317 | AUDIO_FLUSHANDRELOADTRACKS, AUDIO_GETPOS, AUDIO_LENGTH, |
318 | const char *audio_option[] = {"status", "play", "stop", "pause", | 318 | AUDIO_ELAPSED, AUDIO_ECOUNT}; |
319 | "resume", "next", "prev", "ff_rewind", | 319 | const char *audio_option[] = {"status", "play", "stop", |
320 | "flush_and_reload_tracks", "get_file_pos", NULL}; | 320 | "pause", "resume", "next", |
321 | "prev", "ff_rewind", | ||
322 | "flush_and_reload_tracks", | ||
323 | "get_file_pos", "length", | ||
324 | "elapsed", NULL}; | ||
321 | long elapsed, offset, newtime; | 325 | long elapsed, offset, newtime; |
322 | int status = rb->audio_status(); | 326 | int status = rb->audio_status(); |
323 | 327 | ||
@@ -365,6 +369,18 @@ RB_WRAP(audio) | |||
365 | case AUDIO_GETPOS: | 369 | case AUDIO_GETPOS: |
366 | lua_pushinteger(L, rb->audio_get_file_pos()); | 370 | lua_pushinteger(L, rb->audio_get_file_pos()); |
367 | return 1; | 371 | return 1; |
372 | case AUDIO_LENGTH: | ||
373 | if ((status & AUDIO_STATUS_PLAY) == AUDIO_STATUS_PLAY) | ||
374 | lua_pushinteger(L, rb->audio_current_track()->length); | ||
375 | else | ||
376 | lua_pushnil(L); | ||
377 | return 1; | ||
378 | case AUDIO_ELAPSED: | ||
379 | if ((status & AUDIO_STATUS_PLAY) == AUDIO_STATUS_PLAY) | ||
380 | lua_pushinteger(L, rb->audio_current_track()->elapsed); | ||
381 | else | ||
382 | lua_pushnil(L); | ||
383 | return 1; | ||
368 | } | 384 | } |
369 | 385 | ||
370 | rb->yield(); | 386 | rb->yield(); |