Some file formats, such as .sid and .ay, support multiple tracks per file - we should recognise these, and our UI components should provide the ability to select a specific track.
I suggest this is done by extending the Track API:
track.getSubTrackCount(callback) - calls callback() with the number of sub-tracks in the file. This may require fetching the file first, hence the need for the callback. Players / formats that don't support multiple tracks can simply call callback(1) immediately.
var audioElement = track.open(subTrackNumber) - return an audio element for the given sub-track number, just like track.open() does now. Players / formats that don't support multiple tracks can simply ignore the subTrackNumber parameter and return their one and only track. Players that do support multiple tracks should gracefully handle a missing subTrackNumber parameter and return their first track, for backwards compatibility. If the player fetched the file during a previous call to getSubTrackCount, it should avoid fetching the file again during track.open() or audioElement.play().
optionally, or instead of getSubTrackCount:track.getSubTrackMetadata(callback) - returns an array of metadata objects, one for each track. Each metadata object should contain at minimum a name, and (if the player supports it) a duration.
Some file formats, such as .sid and .ay, support multiple tracks per file - we should recognise these, and our UI components should provide the ability to select a specific track.
I suggest this is done by extending the Track API:
track.getSubTrackCount(callback)
- callscallback()
with the number of sub-tracks in the file. This may require fetching the file first, hence the need for the callback. Players / formats that don't support multiple tracks can simply callcallback(1)
immediately.var audioElement = track.open(subTrackNumber)
- return an audio element for the given sub-track number, just liketrack.open()
does now. Players / formats that don't support multiple tracks can simply ignore the subTrackNumber parameter and return their one and only track. Players that do support multiple tracks should gracefully handle a missingsubTrackNumber
parameter and return their first track, for backwards compatibility. If the player fetched the file during a previous call togetSubTrackCount
, it should avoid fetching the file again duringtrack.open()
oraudioElement.play()
.track.getSubTrackMetadata(callback)
- returns an array of metadata objects, one for each track. Each metadata object should contain at minimum a name, and (if the player supports it) a duration.