private async Task UpdateCaptionTracksAsync()
{
// can be called before the this._MediaPlayer is assigned, this is also
// called during MediaOpened which inits the caption track list
if (null == this._MediaPlayer)
return;
await this._MediaPlayer.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
{
if (ClosedCaptionType.CC608Instream == this._CaptionType)
{
this._MediaPlayer.AvailableCaptions.Clear();
this._MediaPlayer.SelectedCaption = null;
// MMPPF will add the "Off" option automatically when a caption track is selected
this._MediaPlayer.AvailableCaptions.Add(new Caption() { Id = "1", Description = "CC1" });
this._MediaPlayer.AvailableCaptions.Add(new Caption() { Id = "2", Description = "CC2" });
this._MediaPlayer.AvailableCaptions.Add(new Caption() { Id = "3", Description = "CC3" });
this._MediaPlayer.AvailableCaptions.Add(new Caption() { Id = "4", Description = "CC4" });
// raise event
if (null != this.AvailableCaptionsPopulated)
this.AvailableCaptionsPopulated(this, EventArgs.Empty);
}
else if(this._CaptionType == ClosedCaptionType.WebVTTSidecar)
{
try
{
if (this._Controller != null &&
this._Controller.IsValid &&
this._Controller.Playlist != null &&
this._Controller.Playlist.IsMaster)
{
this._WebVTTCaptions = new HLSWebVTTCaptions(this._MediaPlayer, this._Controller);
await this._WebVTTCaptions.UpdateCaptionOptionsAsync();
// raise event
if (null != this.AvailableCaptionsPopulated)
this.AvailableCaptionsPopulated(this, EventArgs.Empty);
}
}
catch { }
}
});
}