void Playlist_StreamSelectionChanged(IHLSPlaylist sender, IHLSStreamSelectionChangedEventArgs args) { Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { SwitchTrackTypeVisual(args.To); }); }
/// <summary> /// Called when the stream selection changes between audio, video or both. /// </summary> /// <param name="sender">The currently playing HLS playlist.</param> /// <param name="args">The <see cref="IHLSStreamSelectionChangedEventArgs"/> that describes the stream /// selection switch.</param> private void HLSPlaylist_StreamSelectionChanged(object sender, IHLSStreamSelectionChangedEventArgs args) { if (null != StreamSelectionChanged) { this.StreamSelectionChanged(sender, args); } }
void Playlist_StreamSelectionChanged(IHLSPlaylist sender, IHLSStreamSelectionChangedEventArgs args) { Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { try { if (_timerPlaybackControlDisplay.IsEnabled) { _timerPlaybackControlDisplay.Stop(); } //if we switched to an audio only stream - show poster if (args.To == TrackType.AUDIO) { var hasme = VisualTreeHelper.FindElementsInHostCoordinates(new Point(LayoutRoot.ActualWidth / 2, LayoutRoot.ActualHeight / 2), LayoutRoot). Where(uie => uie is MediaElement).FirstOrDefault(); if (hasme != null) { MediaElement me = hasme as MediaElement; if (me.Parent is Panel) { Grid gridAudioOnly = new Grid() { Name = "appAudioOnly", HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch, VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch, Background = new SolidColorBrush(Windows.UI.Colors.DarkGray) }; gridAudioOnly.Children.Add(new Image() { Width = 200, Height = 200, Stretch = Stretch.Fill, HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center, VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center, Source = new BitmapImage(new Uri("ms-appx:///assets/audioonly.png")) }); (me.Parent as Panel).Children.Insert((me.Parent as Panel).Children.IndexOf(me) + 1, gridAudioOnly); } } } else if (args.To == TrackType.BOTH) //else hide poster if poster was being displayed { var hasme = VisualTreeHelper.FindElementsInHostCoordinates(new Point(mePlayer.ActualWidth / 2, mePlayer.ActualHeight / 2), mePlayer). Where(uie => uie is MediaElement).FirstOrDefault(); if (hasme != null) { MediaElement me = hasme as MediaElement; if (me.Parent is Panel) { (me.Parent as Panel).Children.RemoveAt((me.Parent as Panel).Children.IndexOf(me) + 1); } } } } catch (Exception Ex) { } }); }
void Playlist_StreamSelectionChanged(IHLSPlaylist sender, IHLSStreamSelectionChangedEventArgs args) { Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { SwitchTrackTypeVisual(args.To); }); }
/// <summary> /// Called when the stream selection changes between audio, video or both. /// </summary> /// <param name="sender">The currently playing HLS playlist.</param> /// <param name="args">The <see cref="IHLSStreamSelectionChangedEventArgs"/> that describes the stream /// selection switch.</param> private void HLSPlaylist_StreamSelectionChanged(object sender, IHLSStreamSelectionChangedEventArgs args) { if (null != StreamSelectionChanged) this.StreamSelectionChanged(sender, args); }
void Playlist_StreamSelectionChanged(IHLSPlaylist sender, IHLSStreamSelectionChangedEventArgs args) { Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { try { if (_timerPlaybackControlDisplay.IsEnabled) _timerPlaybackControlDisplay.Stop(); //if we switched to an audio only stream - show poster if (args.To == TrackType.AUDIO) { var hasme = VisualTreeHelper.FindElementsInHostCoordinates(new Point(LayoutRoot.ActualWidth / 2, LayoutRoot.ActualHeight / 2), LayoutRoot). Where(uie => uie is MediaElement).FirstOrDefault(); if (hasme != null) { MediaElement me = hasme as MediaElement; if (me.Parent is Panel) { Grid gridAudioOnly = new Grid() { Name = "appAudioOnly", HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch, VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch, Background = new SolidColorBrush(Windows.UI.Colors.DarkGray) }; gridAudioOnly.Children.Add(new Image() { Width = 200, Height = 200, Stretch = Stretch.Fill, HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center, VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center, Source = new BitmapImage(new Uri("ms-appx:///assets/audioonly.png")) }); (me.Parent as Panel).Children.Insert((me.Parent as Panel).Children.IndexOf(me) + 1, gridAudioOnly); } } } else if (args.To == TrackType.BOTH) //else hide poster if poster was being displayed { var hasme = VisualTreeHelper.FindElementsInHostCoordinates(new Point(mePlayer.ActualWidth / 2, mePlayer.ActualHeight / 2), mePlayer). Where(uie => uie is MediaElement).FirstOrDefault(); if (hasme != null) { MediaElement me = hasme as MediaElement; if (me.Parent is Panel) (me.Parent as Panel).Children.RemoveAt((me.Parent as Panel).Children.IndexOf(me) + 1); } } } catch (Exception Ex) { } }); }