Example #1
0
        private void InitMediaPlayer()
        {
            _mediaElementManager = new MediaElementManager(Dispatcher, () =>
            {
                UpdateState(MediaElementState.Opening);
                return(TiviMediaElement);
            },
                                                           me => UpdateState(MediaElementState.Closed));

            _httpClients = new HttpClients(userAgent: ApplicationInformation.CreateUserAgent());

            _positionTimer = new DispatcherTimer {
                Interval = TimeSpan.FromSeconds(1)
            };
            _positionTimer.Tick += OnPositionSamplerOnTick;

            if (null == TiviMediaElement)
            {
                Debug.WriteLine("MainPage Play no media element");
                return;
            }

            InitializeMediaStream();
            if (!string.IsNullOrEmpty(_streamLink))
            {
                _mediaStreamFascade.Source = new Uri(_streamLink);
            }
        }
Example #2
0
        // Constructor
        public LivePlayer()
        {
            InitializeComponent();

            _mediaElementManager = new MediaElementManager(Dispatcher,
                                                           () =>
            {
                UpdateState(MediaElementState.Opening);

                return(mediaElement1);
            },
                                                           me => UpdateState(MediaElementState.Closed));

            _httpClients = new HttpClients(userAgent: ApplicationInformation.CreateUserAgent());

            _positionSampler = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(75)
            };
            _positionSampler.Tick += OnPositionSamplerOnTick;

#if STREAM_SWITCHING
            _timer = new DispatcherTimer();

            _timer.Tick += (sender, args) =>
            {
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();

                var gcMemory = GC.GetTotalMemory(true).BytesToMiB();

                var source = Sources[_count];

                Debug.WriteLine("Switching to {0} (GC {1:F3} MiB App {2:F3}/{3:F3}/{4:F3} MiB)", source, gcMemory,
                                DeviceStatus.ApplicationCurrentMemoryUsage.BytesToMiB(),
                                DeviceStatus.ApplicationPeakMemoryUsage.BytesToMiB(),
                                DeviceStatus.ApplicationMemoryUsageLimit.BytesToMiB());

                InitializeMediaStream();

                _mediaStreamFascade.Source = null == source ? null : new Uri(source);

                if (++_count >= Sources.Length)
                {
                    _count = 0;
                }

                _positionSampler.Start();
            };

            _timer.Interval = TimeSpan.FromSeconds(15);

            _timer.Start();
#endif // STREAM_SWITCHING
        }
Example #3
0
        // Constructor
        public LivePlayer()
        {
            InitializeComponent();

            _mediaElementManager = new MediaElementManager(Dispatcher,
                () =>
                {
                    UpdateState(MediaElementState.Opening);

                    return mediaElement1;
                },
                me => UpdateState(MediaElementState.Closed));

            _httpClients = new HttpClients(userAgent: ApplicationInformation.CreateUserAgent());

            _positionSampler = new DispatcherTimer
                               {
                                   Interval = TimeSpan.FromMilliseconds(75)
                               };
            _positionSampler.Tick += OnPositionSamplerOnTick;

#if STREAM_SWITCHING
            _timer = new DispatcherTimer();

            _timer.Tick += (sender, args) =>
                           {
                               GC.Collect();
                               GC.WaitForPendingFinalizers();
                               GC.Collect();

                               var gcMemory = GC.GetTotalMemory(true).BytesToMiB();

                               var source = Sources[_count];

                               Debug.WriteLine("Switching to {0} (GC {1:F3} MiB App {2:F3}/{3:F3}/{4:F3} MiB)", source, gcMemory,
                                   DeviceStatus.ApplicationCurrentMemoryUsage.BytesToMiB(),
                                   DeviceStatus.ApplicationPeakMemoryUsage.BytesToMiB(),
                                   DeviceStatus.ApplicationMemoryUsageLimit.BytesToMiB());

                               InitializeMediaStream();

                               _mediaStreamFascade.Source = null == source ? null : new Uri(source);

                               if (++_count >= Sources.Length)
                                   _count = 0;

                               _positionSampler.Start();
                           };

            _timer.Interval = TimeSpan.FromSeconds(15);

            _timer.Start();
#endif // STREAM_SWITCHING
        }
Example #4
0
 public TsMediaManager(ISegmentReaderManagerFactory segmentReaderManagerFactory, IMediaElementManager mediaElementManager, IMediaStreamSource mediaStreamSource, Func<Buffering.IBufferingManager> bufferingManagerFactory, IMediaManagerParameters mediaManagerParameters, IMediaParserFactory mediaParserFactory, IPlatformServices platformServices);
Example #5
0
 public TsMediaManager(ISegmentReaderManagerFactory segmentReaderManagerFactory, IMediaElementManager mediaElementManager, IMediaStreamSource mediaStreamSource, Func <Buffering.IBufferingManager> bufferingManagerFactory, IMediaManagerParameters mediaManagerParameters, IMediaParserFactory mediaParserFactory, IPlatformServices platformServices);
 public static void SetParameter(this IMediaStreamFascade mediaStreamFascade, IMediaElementManager mediaElementManager);
 public static void SetParameter(this IMediaStreamFascade mediaStreamFascade, IMediaElementManager mediaElementManager);