mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
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
This commit is contained in:
parent
152e415b0d
commit
c0dbfc8130
1 changed files with 20 additions and 4 deletions
|
@ -314,10 +314,14 @@ RB_WRAP(audio)
|
||||||
{
|
{
|
||||||
enum e_audio {AUDIO_STATUS = 0, AUDIO_PLAY, AUDIO_STOP, AUDIO_PAUSE,
|
enum e_audio {AUDIO_STATUS = 0, AUDIO_PLAY, AUDIO_STOP, AUDIO_PAUSE,
|
||||||
AUDIO_RESUME, AUDIO_NEXT, AUDIO_PREV, AUDIO_FFREWIND,
|
AUDIO_RESUME, AUDIO_NEXT, AUDIO_PREV, AUDIO_FFREWIND,
|
||||||
AUDIO_FLUSHANDRELOADTRACKS, AUDIO_GETPOS, AUDIO_ECOUNT};
|
AUDIO_FLUSHANDRELOADTRACKS, AUDIO_GETPOS, AUDIO_LENGTH,
|
||||||
const char *audio_option[] = {"status", "play", "stop", "pause",
|
AUDIO_ELAPSED, AUDIO_ECOUNT};
|
||||||
"resume", "next", "prev", "ff_rewind",
|
const char *audio_option[] = {"status", "play", "stop",
|
||||||
"flush_and_reload_tracks", "get_file_pos", NULL};
|
"pause", "resume", "next",
|
||||||
|
"prev", "ff_rewind",
|
||||||
|
"flush_and_reload_tracks",
|
||||||
|
"get_file_pos", "length",
|
||||||
|
"elapsed", NULL};
|
||||||
long elapsed, offset, newtime;
|
long elapsed, offset, newtime;
|
||||||
int status = rb->audio_status();
|
int status = rb->audio_status();
|
||||||
|
|
||||||
|
@ -365,6 +369,18 @@ RB_WRAP(audio)
|
||||||
case AUDIO_GETPOS:
|
case AUDIO_GETPOS:
|
||||||
lua_pushinteger(L, rb->audio_get_file_pos());
|
lua_pushinteger(L, rb->audio_get_file_pos());
|
||||||
return 1;
|
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();
|
rb->yield();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue