overrideTrack method
Force the player to override a track. Or cancel the override.
trackId
should be a key of MediaInfo.tracks.
Implementation
bool overrideTrack(String trackId, bool enabled) {
if (!disposed &&
mediaInfo.value != null &&
mediaInfo.value!.tracks.containsKey(trackId) &&
overrideTracks.value.contains(trackId) != enabled) {
final ids = trackId.split('.');
_methodChannel.invokeMethod('overrideTrack', {
'id': id.value,
'groupId': int.parse(ids[0]),
'trackId': int.parse(ids[1]),
'value': enabled,
});
if (enabled) {
final newTracks = overrideTracks.value.difference(overrideTracks.value
.where((id) =>
id != trackId &&
mediaInfo.value!.tracks[id]!.type ==
mediaInfo.value!.tracks[trackId]!.type)
.toSet());
newTracks.add(trackId);
overrideTracks.value = newTracks;
} else {
overrideTracks.value = overrideTracks.value.difference({trackId});
}
return true;
}
return false;
}