fixed jump to second of playtime
This commit is contained in:
parent
67ded19c93
commit
29316ffd13
|
|
@ -4694,18 +4694,9 @@ uint32_t Audio::getAudioCurrentTime() { // return current time in seconds
|
|||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
bool Audio::setAudioPlayPosition(uint16_t sec) {
|
||||
if(!m_f_psramFound) { log_w("PSRAM must be activated"); return false;} // guard
|
||||
if(m_dataMode != AUDIO_LOCALFILE /* && m_streamType == ST_WEBFILE */) return false; // guard
|
||||
if(!m_avr_bitrate) return false; // guard
|
||||
//if(m_codec == CODEC_OPUS) return false; // not impl. yet
|
||||
//if(m_codec == CODEC_VORBIS) return false; // not impl. yet
|
||||
// Jump to an absolute position in time within an audio file
|
||||
// e.g. setAudioPlayPosition(300) sets the pointer at pos 5 min
|
||||
if(sec > getAudioFileDuration()) sec = getAudioFileDuration();
|
||||
uint32_t filepos = m_audioDataStart + (m_avr_bitrate * sec / 8);
|
||||
if(m_dataMode == AUDIO_LOCALFILE) return setFilePos(filepos);
|
||||
// if(m_streamType == ST_WEBFILE) return httpRange(m_lastHost, filepos);
|
||||
return false;
|
||||
return setFilePos(filepos);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
void Audio::setVolumeSteps(uint8_t steps) {
|
||||
|
|
@ -4737,23 +4728,15 @@ bool Audio::setTimeOffset(int sec) { // fast forward or rewind the current posit
|
|||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
bool Audio::setFilePos(uint32_t pos) {
|
||||
if(!m_f_psramFound) { log_w("PSRAM must be activated"); return false;} // guard
|
||||
if(m_dataMode != AUDIO_LOCALFILE /* && m_streamType == ST_WEBFILE */) return false; // guard
|
||||
if(m_dataMode == AUDIO_LOCALFILE && !audiofile) return false; // guard
|
||||
if(m_codec == CODEC_AAC) return false; // guard, not impl. yet
|
||||
|
||||
uint32_t startAB = m_audioDataStart; // audioblock begin
|
||||
uint32_t endAB = m_audioDataStart + m_audioDataSize; // audioblock end
|
||||
if(pos < (int32_t)startAB) {pos = startAB;}
|
||||
if(pos >= (int32_t)endAB) {pos = endAB;}
|
||||
|
||||
|
||||
if(m_codec == CODEC_OPUS) return false; // not impl. yet
|
||||
if(m_codec == CODEC_VORBIS) return false; // not impl. yet
|
||||
if(!audiofile) return false;
|
||||
if(pos < m_audioDataStart) pos = m_audioDataStart; // issue #96
|
||||
if(pos > m_fileSize) pos = m_fileSize;
|
||||
m_resumeFilePos = pos;
|
||||
memset(m_outBuff, 0, 2048 * 2 * sizeof(int16_t));
|
||||
m_validSamples = 0;
|
||||
if(m_dataMode == AUDIO_LOCALFILE /* || m_streamType == ST_WEBFILE */) {
|
||||
m_resumeFilePos = pos; // used in processLocalFile()
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
bool Audio::setSampleRate(uint32_t sampRate) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue