-
Checking Current Source:
if (m_srcManager->IsCurrentSourceStorage() == true)
Here, the function first checks whether the current source of media is from storage (as opposed to streaming or another source). The actions following this condition are only executed if the media source is valid.
-
Retrieving Playback Progress:
auto pbProgress = m_srcManager->GetCurrentSourceHandler()->GetPlaybackProgress();
The GetPlaybackProgress method retrieves the current playback progress of the media, likely returning information such as elapsed time in milliseconds.
-
Condition for Previous Track:
if (pbProgress.ElapsedMsec < PREV_NAVIGATION_THRESHOLD_MS)
{
// Take audio and play previous track
}
else
{
// Seek to beginning of the track
}
A threshold check (PREV_NAVIGATION_THRESHOLD_MS) is performed on the elapsed playback time:
- If the elapsed time is less than the threshold, it implies that the user has just started playing the track (i.e., is still in the initial phase), so the system allows for playing the previous track without significant delay or disruption.
- If the elapsed time is greater than or equal to the threshold, the action shifts to seeking.
-
Playing Previous Track (if elapsed time < threshold):
if (m_audioManEP->takeAudio() == true)
m_queue->prev(count);
If the elapsed time is within the threshold, the function attempts to take control of the audio (presumably to stop the current playback) and then calls the prev function on the m_queue to play the previous audio track, effectively moving back in the playlist.
-
Seeking to the Beginning of the Track (if elapsed time >= threshold):
m_player->setMute(true);
m_player->seekPositionTo(multimediamanager::helper::millisecToQTime(0));
m_player->setMute(false);
When the user has been playing for too long (past the threshold), the player mutes itself temporarily, seeks to the beginning of the media (position set to 0 milliseconds), and then unmutes itself. This creates an experience where the user can effectively "restart" the media from the beginning rather than jumping back to the previous track outright.