3254523
3254523

Reputation: 3026

iOS App does not display time elapsed / total duration on certain audio items.

My iOS app streams audio files, plays them via AVAudioSession.

For some reason on certain audio items the time elapsed time/total duration does not display on the lock screen.

I tracked the file type to be .mp3 but it seems that not all .mp3 files share this issue.

Is there anything I can do on my end to ensure the total duration/time elapsed is displayed on the lock screen?

Upvotes: 0

Views: 440

Answers (1)

Octopus
Octopus

Reputation: 8325

If the mp3 is recorded in VBR (variable bit rate) there is no direct number-of-bytes to duration-in-seconds conversion. When you know the bitrate, you can directly calculate the remaining time from your current offset in the file, but a VBR file is constantly throttling the bitrate up and down. There should be info about the total duration of the track in the header and using a timer would help predict where you are, but I don't know how your audio player works on your lock screen. It might only know the current offset into the file, from where it can't calculate durations.

It might not be the reason specifically, as I don't know enough about software you are using, but its one possibility. If that's the reason, you could convert the file to a fixed bitrate.

Upvotes: 2

Related Questions