Using the API to display the remaining track time in mm:ss

derek

Member
I'm trying to use the RadioBoss API to work with the NVDA screen reader. I'm putting together a team to work on an add-on, which will be able to give radioboss global hotkeys, and speak track progress information from anywhere; Specifically, I want to have NDVA speak the remaining time left on a track in minutes and seconds format.

Here's what I'm getting back when I send the "action=playbackinfo" command:

```xml
<Playback pos="30899" len="245466" state="play" playlistpos="108" streams="2" netstream="n/a" playingtimeleft="37087708"
```

The `playingtimeleft` value seems to be in either samples or milliseconds, but I'm not sure how to convert it to minutes and seconds.

Can anyone help me figure out how to format that data properly? Thanks!
 
playingtimeleft is in milliseconds and specifies the remaining playback duration for the whole playlist.
 
Last edited:
playingtimeleft is in milliseconds and specifies the remaining playback duration for the whole playlist.
Makes sense. Is it possible to get the API to return the remaining time of the currently playing track? It's possible to see every other property of the currently playing track, which is also useful. In fact, I've never thought to get the remaining time of the playlist, but now that I know about this, I will definitely make that useful!
 
So, just so I'm clear, can you break this down a bit more? I need to know the current track, and its remaining time. If you're saying that the only way I can get the remaining time is to look at the start time of each song, that would only work if radioboss is never paused. Otherwise, I'd have to keep a running check every second to make sure radioboss doesn't pause, and if the user presses pause the calculations would have to be redone. I really hope that I'm wrong about all of this.
 
to get the API to return the remaining time of the currently playing track?
You can calculate it as len - pos (both values are returned in the <Playback> section) - that is, subtract current playback position from the track's total duration.
 
Back
Top