public void Initialize(MediaPlayer player, IHLSController controller) { _player = player; _controller = controller; this.DataContext = _data; try { if (_controller.IsValid && _controller.Playlist != null) { _controller.Playlist.BitrateSwitchSuggested += Playlist_BitrateSwitchSuggested; _controller.Playlist.BitrateSwitchCompleted += Playlist_BitrateSwitchCompleted; _controller.Playlist.BitrateSwitchCancelled += Playlist_BitrateSwitchCancelled; _controller.Playlist.SegmentSwitched += Playlist_SegmentSwitched; } } catch (Exception Ex) { } _player.MediaOpened += _player_MediaOpened; _player.MediaFailed += _player_MediaFailed; _player.MediaEnded += _player_MediaEnded; _displayTimer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(2) }; _displayTimer.Tick += _displayTimer_Tick; _displayTimer.Start(); }
void _controllerFactory_HLSControllerReady(IHLSControllerFactory sender, IHLSController args) { _controller = args; ApplySettings(); if (_controller.Playlist != null) { _controller.Playlist.StreamSelectionChanged += Playlist_StreamSelectionChanged; } Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { try { if (_controller != null && _controller.IsValid) { ucPlaybackInfoOverlay.Initialize(mePlayer, _controller); } } catch (Exception Ex) { } }); }
/// <summary> /// Initialize object. /// </summary> /// <param name="mediaPlayer">MMPPF media player.</param> /// <param name="controller">HLS Client controller.</param> public HLSWebVTTCaptions(MediaPlayer mediaPlayer, IHLSController controller) { this._MediaPlayer = mediaPlayer; this._Controller = controller; this._Cancel = false; this.CurrentSubtitleId = null; }
public void Initialize(IHLSController controller, MediaPlayer player) { _data = new PlaybackStatusData(controller, player); this.DataContext = _data; _player = player; _controller = controller; _player.MediaOpened += _player_MediaOpened; _player.SeekCompleted += _player_SeekCompleted; _controller.PrepareResourceRequest += _controller_PrepareResourceRequest; }
void _controller_PrepareResourceRequest(IHLSController sender, IHLSResourceRequestEventArgs args) { try { //if there is a key request - display an encrypted flag if (args.Type == ResourceType.KEY) { Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { tblkEncryption.Text = "Encrypted"; }); } //always submit to prevent locking up the runtime args.Submit(); } catch (Exception Ex) { } }
void _controller_PrepareResourceRequest(IHLSController sender, IHLSResourceRequestEventArgs args) { try { //if there is a key request - display an encrypted flag if (args.Type == ResourceType.KEY) { Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { tblkEncryption.Text = "Encrypted"; }); } //always submit to prevent locking up the runtime args.Submit(); } catch(Exception Ex) { } }
private void HLSPlugin_HLSControllerReady(object sender, IHLSController e) { if (null != e) { this._HLSController = e; if (null != this._HLSPlaylist) { this.UnwireHLSPlaylistHandlers(); } if (null != e.Playlist) { this._HLSPlaylist = e.Playlist; this.WireHLSPlaylistHandlers(); } } }
/// <summary> /// Called when the HLS Client has initialized the <see cref="IHLSController"/> /// </summary> /// <param name="sender">The <see cref="IHLSControllerFactory"/> that was used to initialize the HLS Client.</param> /// <param name="controller">The <see cref="IHLSController"/> used to handle bitrate switching, etc.</param> private void HLSControllerFactory_HLSControllerReady(object sender, IHLSController controller) { try { this.UninitializeController(); this._Controller = controller; this.InitializeController(); if (null != this.HLSControllerReady) { this.HLSControllerReady(sender, this._Controller); } } catch { // Swallow these exceptions as 404s and other errors can cause the SDK code above to throw //throw; } }
void _controllerfactory_HLSControllerReady(IHLSControllerFactory sender, IHLSController args) { //save the controller _controller = args; //playing a batch ? if (_batch != null) { _controller.BatchPlaylists(_batch.Select(u => { return(u.AbsoluteUri); }).ToList()); } if (_controller.Playlist != null) { _controller.Playlist.StreamSelectionChanged += Playlist_StreamSelectionChanged; _controller.Playlist.SegmentSwitched += Playlist_SegmentSwitched; } _controller.PrepareResourceRequest += _controller_PrepareResourceRequest; _controller.InitialBitrateSelected += _controller_InitialBitrateSelected; Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { gridAudioOnly.Visibility = Visibility.Collapsed; try { if (_controller.IsValid) { ucPlaybackStatus.Initialize(_controller, mediaplayer); ucHLSSettings.Controller = _controller; ucMetadataUI.Controller = _controller; ucUnprocessedTagsUI.Controller = _controller; } } catch (Exception Ex) { } }).AsTask().Wait(); }
public PlaybackStatusData(IHLSController controller, MediaPlayer player) { _controller = controller; _player = player; _clocktimer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(250) }; _clocktimer.Tick += _clocktimer_Tick; player.MediaOpened += player_MediaOpened; _player.MediaEnded += _player_MediaEnded; _player.MediaFailed += _player_MediaFailed; _controller.Playlist.BitrateSwitchSuggested += Playlist_BitrateSwitchSuggested; _controller.Playlist.BitrateSwitchCompleted += Playlist_BitrateSwitchCompleted; _controller.Playlist.BitrateSwitchCancelled += Playlist_BitrateSwitchCancelled; _controller.Playlist.SegmentSwitched += Playlist_SegmentSwitched; _controller.Playlist.SlidingWindowChanged += Playlist_SlidingWindowChanged; }
void _controller_InitialBitrateSelected(IHLSController sender, IHLSInitialBitrateSelectedEventArgs args) { //use this to set any propeties on the initial ActiveVariant before playback starts //E.g. set an alternate audio track to start with //if (_controller != null && _controller.Playlist.IsMaster) //{ // var audiorenditions = _controller.Playlist.ActiveVariantStream.GetAudioRenditions(); // if (audiorenditions != null) // { // var match = audiorenditions.ToList().Find((r) => // { // return r.Name == "someotheralternateaudio"; // }); // if (match != null) // match.IsActive = true; // } //} args.Submit(); }
private async void OnForegroundDeactivated() { System.Diagnostics.Debug.WriteLine("Foreground: Deactivating"); try { if (mePlayer.Source != null) { _lastsrc = mePlayer.Source; } //we are deactivating - if we are playing if (mePlayer.CurrentState == MediaElementState.Playing && _controller != null && _controller.IsValid && _controller.Playlist != null) { if (_isbackgroundtaskrunning) { //let the task know we are deactivating and pass the stream state on ValueSet vs = new ValueSet(); vs.Add("FOREGROUND_DEACTIVATED", new StreamInfo(mePlayer.Source.ToString(), (ulong)mePlayer.Position.Ticks).ToString()); BackgroundMediaPlayer.SendMessageToBackground(vs); System.Diagnostics.Debug.WriteLine("Foreground: Deactivation message sent to background"); //release the foreground extension mePlayer.Source = null; _controller = null; } else { mePlayer.Source = null; _controller = null; } } } catch (Exception Ex) { } }
void _controller_PrepareResourceRequest(IHLSController sender, IHLSResourceRequestEventArgs args) { //var downloader = new CustomDownloader(); //args.SetDownloader(downloader); args.Submit(); }
/// <summary> /// Called when the HLS Client has initialized the <see cref="IHLSController"/> /// </summary> /// <param name="sender">The <see cref="IHLSControllerFactory"/> that was used to initialize the HLS Client.</param> /// <param name="controller">The <see cref="IHLSController"/> used to handle bitrate switching, etc.</param> private void HLSControllerFactory_HLSControllerReady(object sender, IHLSController controller) { try { this.UninitializeController(); this._Controller = controller; this.InitializeController(); if (null != this.HLSControllerReady) this.HLSControllerReady(sender, this._Controller); } catch { // Swallow these exceptions as 404s and other errors can cause the SDK code above to throw //throw; } }
private async void OnForegroundDeactivated() { System.Diagnostics.Debug.WriteLine("Foreground: Deactivating"); try { if (mePlayer.Source != null) _lastsrc = mePlayer.Source; //we are deactivating - if we are playing if (mePlayer.CurrentState == MediaElementState.Playing && _controller != null && _controller.IsValid && _controller.Playlist != null) { if (_isbackgroundtaskrunning) { //let the task know we are deactivating and pass the stream state on ValueSet vs = new ValueSet(); vs.Add("FOREGROUND_DEACTIVATED", new StreamInfo(mePlayer.Source.ToString(), (ulong)mePlayer.Position.Ticks).ToString()); BackgroundMediaPlayer.SendMessageToBackground(vs); System.Diagnostics.Debug.WriteLine("Foreground: Deactivation message sent to background"); //release the foreground extension mePlayer.Source = null; _controller = null; } else { mePlayer.Source = null; _controller = null; } } } catch (Exception Ex) { } }
void _controllerfactory_HLSControllerReady(IHLSControllerFactory sender, IHLSController args) { //save the controller _controller = args; //playing a batch ? if (_batch != null) { _controller.BatchPlaylists(_batch.Select(u => { return u.AbsoluteUri; }).ToList()); } if (_controller.Playlist != null) { _controller.Playlist.StreamSelectionChanged += Playlist_StreamSelectionChanged; _controller.Playlist.SegmentSwitched += Playlist_SegmentSwitched; } _controller.PrepareResourceRequest += _controller_PrepareResourceRequest; _controller.InitialBitrateSelected += _controller_InitialBitrateSelected; Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { gridAudioOnly.Visibility = Visibility.Collapsed; try { if (_controller.IsValid) { ucPlaybackStatus.Initialize(_controller, mediaplayer); ucHLSSettings.Controller = _controller; ucMetadataUI.Controller = _controller; ucUnprocessedTagsUI.Controller = _controller; } } catch (Exception Ex) { } }).AsTask().Wait(); }
private void HLSPlugin_HLSControllerReady(object sender, IHLSController e) { if (null != e) { this._HLSController = e; if (null != this._HLSPlaylist) this.UnwireHLSPlaylistHandlers(); if (null != e.Playlist) { this._HLSPlaylist = e.Playlist; this.WireHLSPlaylistHandlers(); } } }
void _controllerFactory_HLSControllerReady(IHLSControllerFactory sender, IHLSController args) { _controller = args; ApplySettings(); if (_controller.Playlist != null) { _controller.Playlist.StreamSelectionChanged += Playlist_StreamSelectionChanged; } Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { try { if (_controller != null && _controller.IsValid) ucPlaybackInfoOverlay.Initialize(mePlayer, _controller); } catch (Exception Ex) { } }); }