private void OnTrackDeleted(TrackType type, int trackId) { if (type == TrackType.Unknown || type == TrackType.Video) { return; } List <DictionaryKeyValue> target; if (type == TrackType.Audio) { target = _audioTracks; } else { target = _subtitlesTracks; } target.RemoveAll((t) => t.Id == trackId); if (target.Count > 0) { return; } if (type == TrackType.Subtitle) { _currentSubtitle = -1; } else { _currentAudioTrack = -1; } Playback_MediaTracksUpdated?.Invoke(type, trackId); }
private void OnTrackAdded(TrackType type, int trackId) { if (type == TrackType.Unknown) { return; } if (type == TrackType.Video) { PlayingType = PlayingType.Video; } List <DictionaryKeyValue> target; IList <TrackDescription> source; if (type == TrackType.Audio) { target = _audioTracks; source = _mediaService.MediaPlayer?.audioTrackDescription(); } else { target = _subtitlesTracks; source = _mediaService.MediaPlayer?.spuDescription(); } target?.Clear(); foreach (var t in source) { target?.Add(new DictionaryKeyValue() { Id = t.id(), Name = t.name(), }); } // This assumes we have a "Disable" track for both subtitles & audio if (type == TrackType.Subtitle && _subtitlesTracks?.Count > 1) { _currentSubtitle = 1; } else if (type == TrackType.Audio && _audioTracks?.Count > 1) { _currentAudioTrack = 1; } Playback_MediaTracksUpdated?.Invoke(type, trackId); }