play: add current and total time of music

Signed-off-by: Mahyar Koshkouei <mk@deltabeard.com>
This commit is contained in:
Mahyar Koshkouei
2023-07-08 16:05:21 +01:00
parent ca583a5487
commit cdf49f8dcf
8 changed files with 142 additions and 30 deletions

View File

@@ -16,6 +16,7 @@ static uint32_t rateWav(void);
static uint8_t channelWav(void);
static uint64_t readWav(void* buffer);
static void exitWav(void);
static size_t getFileSamplesWav(void);
/**
* Set decoder parameters for WAV.
@@ -30,6 +31,7 @@ void setWav(struct decoder_fn* decoder)
decoder->buffSize = buffSize;
decoder->decode = &readWav;
decoder->exit = &exitWav;
decoder->getFileSamples = &getFileSamplesWav;
}
/**
@@ -43,6 +45,11 @@ int initWav(const char* file)
return !drwav_init_file(&wav, file, NULL);
}
static size_t getFileSamplesWav(void)
{
return wav.totalPCMFrameCount * (size_t)wav.channels;
}
/**
* Get sampling rate of Wav file.
*