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); }); }
private void HLSPlaylist_BitrateSwitchCompleted(IHLSPlaylist sender, IHLSBitrateSwitchEventArgs args) { this.WriteStatsMsgAsync( "HLSPlaylist_BitrateSwitchCompleted", "from bitrate: {0}, to bitrate: {1}", args.FromBitrate, args.ToBitrate); }
void Playlist_BitrateSwitchSuggested(IHLSPlaylist sender, IHLSBitrateSwitchEventArgs args) { _player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { try { if (args.FromBitrate > args.ToBitrate) { _downshiftPending = true; _upshiftPending = false; } else { _upshiftPending = true; _downshiftPending = false; } _targetBitrate = args.ToBitrate; if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("TargetBitrate")); PropertyChanged(this, new PropertyChangedEventArgs("UpshiftPending")); PropertyChanged(this, new PropertyChangedEventArgs("DownshiftPending")); } } catch (Exception Ex) { } }); }
void Playlist_BitrateSwitchCancelled(IHLSPlaylist sender, IHLSBitrateSwitchEventArgs args) { _player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { _data.IsBitrateShiftPending = false; _data.IsBitrateShiftingDown = false; _data.IsBitrateShiftingUp = false; }); }
void Playlist_SegmentSwitched(IHLSPlaylist sender, IHLSSegmentSwitchEventArgs args) { _player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { try { _data.CurrentSegment = args.ToSegment.SequenceNumber; } catch (Exception Ex) { } }); }
void Playlist_SegmentSwitched(IHLSPlaylist sender, IHLSSegmentSwitchEventArgs args) { Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { var hasme = VisualTreeHelper.FindElementsInHostCoordinates(new Point(gridMediaDisplay.ActualWidth / 2, gridMediaDisplay.ActualHeight / 2), gridMediaDisplay). Where(uie => uie is MediaElement).FirstOrDefault(); if (args.ToSegment.MediaType == TrackType.AUDIO && hasme != null) //first segment being played and audio only { SwitchTrackTypeVisual(TrackType.AUDIO); } }); }
void Playlist_SlidingWindowChanged(IHLSPlaylist sender, IHLSSlidingWindow args) { try { if (_initialPlaybackPosition == default(TimeSpan) && args.StartTimestamp != default(TimeSpan)) { _initialPlaybackPosition = args.StartTimestamp; } } catch (Exception Ex) { } }
void Playlist_BitrateSwitchCancelled(IHLSPlaylist sender, IHLSBitrateSwitchEventArgs args) { _player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { _downshiftPending = false; _upshiftPending = false; if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("UpshiftPending")); PropertyChanged(this, new PropertyChangedEventArgs("DownshiftPending")); } }); }
void Playlist_BitrateSwitchSuggested(IHLSPlaylist sender, IHLSBitrateSwitchEventArgs args) { _player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { try { _data.ToBitrate = args.ToBitrate; _data.IsBitrateShiftingDown = args.FromBitrate > args.ToBitrate; _data.IsBitrateShiftingUp = args.ToBitrate > args.FromBitrate; _data.IsBitrateShiftPending = true; } catch (Exception Ex) { } }); }
void Playlist_BitrateSwitchCompleted(IHLSPlaylist sender, IHLSBitrateSwitchEventArgs args) { _player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { try { if (_controller != null && _controller.IsValid && _controller.Playlist.IsMaster && _controller.Playlist != null && _controller.Playlist.ActiveVariantStream != null) { _data.CurrentBitrate = _controller.Playlist.ActiveVariantStream.Bitrate; } _data.IsBitrateShiftPending = false; _data.IsBitrateShiftingDown = false; _data.IsBitrateShiftingUp = false; } 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(); } } }
void Playlist_BitrateSwitchCompleted(IHLSPlaylist sender, IHLSBitrateSwitchEventArgs args) { _player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { try { _downshiftPending = false; _upshiftPending = false; _currentBitrate = args.ToBitrate; if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("CurrentBitrate")); PropertyChanged(this, new PropertyChangedEventArgs("UpshiftPending")); PropertyChanged(this, new PropertyChangedEventArgs("DownshiftPending")); } } catch (Exception Ex) { } }); }
void Playlist_SegmentSwitched(IHLSPlaylist sender, IHLSSegmentSwitchEventArgs args) { try { if (_controller.Playlist.ActiveVariantStream != null && _controller.Playlist.ActiveVariantStream.Playlist != null && !_controller.Playlist.IsLive && _totalSegments == 0) { _totalSegments = _controller.Playlist.ActiveVariantStream.Playlist.SegmentCount; _player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("TotalSegments")); } }); } else if (!_controller.Playlist.IsMaster) { _totalSegments = _controller.Playlist.SegmentCount; _player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("TotalSegments")); } }); } _currentSegment = args.ToSegment.SequenceNumber; _player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("CurrentSegment")); } }); } catch (Exception ex) { } }
void Playlist_SegmentSwitched(IHLSPlaylist sender, IHLSSegmentSwitchEventArgs args) { Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { try { var toSegment = args.ToSegment; if (toSegment.LoadState == SegmentState.LOADED) { var metadatastreams = toSegment.GetMetadataStreams(); if (metadatastreams != null) { if (nometadataStatus.Visibility == Visibility.Visible) { nometadataStatus.Visibility = Visibility.Collapsed; } foreach (var stm in metadatastreams) { var payloads = stm.GetPayloads(); if (payloads != null) { var entry = _segmentid3tags.Where((hms) => { return(hms.StreamID == stm.StreamID); }).FirstOrDefault(); if (entry == null) { entry = new HLSMetadataStream(stm.StreamID); _segmentid3tags.Add(entry); } entry.Payloads.AddRange(payloads.Select((pld) => { return(new HLSMetadataPayload(pld, args.ToBitrate, toSegment.SequenceNumber)); })); } } } } } catch (Exception ex) { } }); }
void Playlist_SegmentSwitched(IHLSPlaylist sender, IHLSSegmentSwitchEventArgs args) { Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { try { var pretaglist = args.ToSegment.GetUnprocessedTags(UnprocessedTagPlacement.PRE); var withintaglist = args.ToSegment.GetUnprocessedTags(UnprocessedTagPlacement.WITHIN); UnprocessedTagForSegment tagplacement = new UnprocessedTagForSegment() { ForSegmentSequence = args.ToSegment.SequenceNumber }; if (pretaglist != null && pretaglist.Count > 0) { tagplacement.Tags.AddRange(pretaglist); } if (withintaglist != null && withintaglist.Count > 0) { tagplacement.Tags.AddRange(withintaglist); } if (tagplacement.Tags.Count > 0) { _data.Add(tagplacement); } if (_data.Count > 0 && notagsStatus.Visibility == Visibility.Visible) { notagsStatus.Visibility = Visibility.Collapsed; } } catch (Exception Ex) { } }); }
void Playlist_SlidingWindowChanged(IHLSPlaylist sender, IHLSSlidingWindow args) { try { if (_initialPlaybackPosition == default(TimeSpan) && args.StartTimestamp != default(TimeSpan)) _initialPlaybackPosition = args.StartTimestamp; } catch(Exception Ex) { } }
void Playlist_SegmentSwitched(IHLSPlaylist sender, IHLSSegmentSwitchEventArgs args) { _player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { try { _data.CurrentSegment = args.ToSegment.SequenceNumber; } catch(Exception Ex) { } }); }
void Playlist_BitrateSwitchCompleted(IHLSPlaylist sender, IHLSBitrateSwitchEventArgs args) { _player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { try { if (_controller != null && _controller.IsValid && _controller.Playlist.IsMaster && _controller.Playlist != null && _controller.Playlist.ActiveVariantStream != null) _data.CurrentBitrate = _controller.Playlist.ActiveVariantStream.Bitrate; _data.IsBitrateShiftPending = false; _data.IsBitrateShiftingDown = false; _data.IsBitrateShiftingUp = false; } catch (Exception Ex) { } }); }
void Playlist_BitrateSwitchSuggested(IHLSPlaylist sender, IHLSBitrateSwitchEventArgs args) { _player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { try { _data.ToBitrate = args.ToBitrate; _data.IsBitrateShiftingDown = args.FromBitrate > args.ToBitrate; _data.IsBitrateShiftingUp = args.ToBitrate > args.FromBitrate; _data.IsBitrateShiftPending = true; } catch(Exception Ex) { } }); }
void Playlist_SegmentSwitched(IHLSPlaylist sender, IHLSSegmentSwitchEventArgs args) { Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { try { var pretaglist = args.ToSegment.GetUnprocessedTags(UnprocessedTagPlacement.PRE); var withintaglist = args.ToSegment.GetUnprocessedTags(UnprocessedTagPlacement.WITHIN); UnprocessedTagForSegment tagplacement = new UnprocessedTagForSegment() { ForSegmentSequence = args.ToSegment.SequenceNumber }; if (pretaglist != null && pretaglist.Count > 0) tagplacement.Tags.AddRange(pretaglist); if (withintaglist != null && withintaglist.Count > 0) tagplacement.Tags.AddRange(withintaglist); if (tagplacement.Tags.Count > 0) _data.Add(tagplacement); if (_data.Count > 0 && notagsStatus.Visibility == Visibility.Visible) notagsStatus.Visibility = Visibility.Collapsed; } catch(Exception Ex) { } }); }
void Playlist_SegmentSwitched(IHLSPlaylist sender, IHLSSegmentSwitchEventArgs args) { Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { var hasme = VisualTreeHelper.FindElementsInHostCoordinates(new Point(gridMediaDisplay.ActualWidth / 2, gridMediaDisplay.ActualHeight / 2), gridMediaDisplay). Where(uie => uie is MediaElement).FirstOrDefault(); if (args.ToSegment.MediaType == TrackType.AUDIO && hasme != null) //first segment being played and audio only SwitchTrackTypeVisual(TrackType.AUDIO); }); }
void Playlist_BitrateSwitchCompleted(IHLSPlaylist sender, IHLSBitrateSwitchEventArgs args) { _player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { try { _downshiftPending = false; _upshiftPending = false; _currentBitrate = args.ToBitrate; if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("CurrentBitrate")); PropertyChanged(this, new PropertyChangedEventArgs("UpshiftPending")); PropertyChanged(this, new PropertyChangedEventArgs("DownshiftPending")); } } catch(Exception Ex) { } }); }
void Playlist_SegmentSwitched(IHLSPlaylist sender, IHLSSegmentSwitchEventArgs args) { try { if (_controller.Playlist.ActiveVariantStream != null && _controller.Playlist.ActiveVariantStream.Playlist != null && !_controller.Playlist.IsLive && _totalSegments == 0) { _totalSegments = _controller.Playlist.ActiveVariantStream.Playlist.SegmentCount; _player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("TotalSegments")); } }); } else if (!_controller.Playlist.IsMaster) { _totalSegments = _controller.Playlist.SegmentCount; _player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("TotalSegments")); } }); } _currentSegment = args.ToSegment.SequenceNumber; _player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("CurrentSegment")); } }); } catch(Exception ex) { } }
void Playlist_SegmentSwitched(IHLSPlaylist sender, IHLSSegmentSwitchEventArgs args) { Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { try { var toSegment = args.ToSegment; if (toSegment.LoadState == SegmentState.LOADED) { var metadatastreams = toSegment.GetMetadataStreams(); if (metadatastreams != null) { if (nometadataStatus.Visibility == Visibility.Visible) nometadataStatus.Visibility = Visibility.Collapsed; foreach (var stm in metadatastreams) { var payloads = stm.GetPayloads(); if (payloads != null) { var entry = _segmentid3tags.Where((hms) => { return hms.StreamID == stm.StreamID; }).FirstOrDefault(); if (entry == null) { entry = new HLSMetadataStream(stm.StreamID); _segmentid3tags.Add(entry); } entry.Payloads.AddRange(payloads.Select((pld) => { return new HLSMetadataPayload(pld, args.ToBitrate, toSegment.SequenceNumber); })); } } } } } catch(Exception ex) { } }); }
void Playlist_BitrateSwitchSuggested(IHLSPlaylist sender, IHLSBitrateSwitchEventArgs args) { _player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { try { if (args.FromBitrate > args.ToBitrate) { _downshiftPending = true; _upshiftPending = false; } else { _upshiftPending = true; _downshiftPending = false; } _targetBitrate = args.ToBitrate; if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("TargetBitrate")); PropertyChanged(this, new PropertyChangedEventArgs("UpshiftPending")); PropertyChanged(this, new PropertyChangedEventArgs("DownshiftPending")); } } catch(Exception Ex) { } }); }
void Playlist_SegmentDataLoaded(IHLSPlaylist sender, IHLSSegment args) { }
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 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) { } }); }