コード例 #1
0
        public void TestInitialize()
        {
            _httpClients = Substitute.For <IHttpClients>();
            _httpClient  = Substitute.For <IHttpClient>();

            _httpClients.Client().Returns(_httpClient);
        }
コード例 #2
0
ファイル: PlayerPage.xaml.cs プロジェクト: thangk48cc/VietTV
        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);
            }
        }
コード例 #3
0
ファイル: LivePlayer.xaml.cs プロジェクト: Jesn/MangGuoTv
        // 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
        }
コード例 #4
0
        public BlockedTraffic(IHttpClients httpClients, Uri p2PStatusUri, TimeSpan timeout)
        {
            Ensure.NotNull(httpClients, nameof(httpClients));
            Ensure.NotNull(p2PStatusUri, nameof(p2PStatusUri));

            _p2PStatusUri = p2PStatusUri;

            _httpClient         = httpClients.Client();
            _httpClient.Timeout = timeout;
        }
コード例 #5
0
ファイル: LivePlayer.xaml.cs プロジェクト: Jesn/MangGuoTv
        // 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
        }
コード例 #6
0
        public BlockedTraffic(IHttpClients httpClients, Uri p2PStatusUri, TimeSpan timeout)
        {
            Ensure.NotNull(httpClients, nameof(httpClients));
            Ensure.NotNull(p2PStatusUri, nameof(p2PStatusUri));

            _p2PStatusUri = p2PStatusUri;
            _httpClient   = httpClients.Client(new HttpClientHandler
            {
                UseCookies = false
            });
            _httpClient.Timeout = timeout;
        }
コード例 #7
0
 public static IMediaStreamFascade Create(this MediaStreamFascadeParameters parameters, IHttpClients httpClients, Func <SM.Media.MediaParser.IMediaStreamSource, System.Threading.Tasks.Task> mediaStreamSourceSetter);
コード例 #8
0
        public void TestInitialize()
        {
            _httpClients = Substitute.For <IHttpClients>();
            _httpClient  = Substitute.For <IHttpClient>();

            _httpClients.Client(default).ReturnsForAnyArgs(_httpClient);
コード例 #9
0
 public static IMediaStreamFascade Create(this MediaStreamFascadeParameters parameters, IHttpClients httpClients, Func<SM.Media.MediaParser.IMediaStreamSource, System.Threading.Tasks.Task> mediaStreamSourceSetter);