Пример #1
0
        private async Task ClearLeoPlayer()
        {
            await HohoemaApp.UIDispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
            {
                if (MediaPlayer.Source == _MediaSource)
                {
                    MediaPlayer.Source = null;

                    CloseLive?.Invoke(this);
                }

                _Mss?.Dispose();
                _Mss = null;
                _MediaSource?.Dispose();
                _MediaSource = null;
                _AdaptiveMediaSource?.Dispose();
                _AdaptiveMediaSource = null;
            });
        }
Пример #2
0
        /// <summary>
        /// 放送開始からの経過時間を更新します
        /// </summary>
        /// <param name="state">Timerオブジェクトのコールバックとして登録できるようにするためのダミー</param>
        private async Task UpdateLiveElapsedTimeAsync()
        {
            using (var releaser = await _LiveElapsedTimeUpdateTimerLock.LockAsync())
            {
                var liveInfo = LiveInfo.VideoInfo.Video;
                // ローカルの現在時刻から放送開始のベース時間を引いて
                // 放送経過時間の絶対値を求める
                if (IsWatchWithTimeshift)
                {
                    LiveElapsedTimeFromOpen = MediaPlayer.PlaybackSession.Position + (TimeshiftPosition ?? TimeSpan.Zero);
                    LiveElapsedTime         = LiveElapsedTimeFromOpen - DurationBtwOpenToStart;
                }
                else
                {
                    LiveElapsedTimeFromOpen = DateTimeOffset.Now.ToOffset(JapanTimeZoneOffset) - _StartTimeOffset - liveInfo.OpenTime.Value;
                    LiveElapsedTime         = DateTimeOffset.Now.ToOffset(JapanTimeZoneOffset) - _StartTimeOffset - liveInfo.StartTime.Value;
                }

                // 生放送の時間経過を通知
                LiveElapsed?.Invoke(this, LiveElapsedTime);


                var liveDuration = liveInfo.EndTime.Value - liveInfo.StartTime.Value;

                // TODO: 終了時刻を過ぎたら生放送情報を更新する
                if (!_IsEndMarked && liveDuration <= LiveElapsedTime)
                {
                    _IsEndMarked = true;

                    // 放送が終了しているか確認
                    await Task.Delay(TimeSpan.FromSeconds(3));
                    await UpdateLiveStatus();

                    if ((LiveInfo?.IsOK ?? false) && LiveInfo.VideoInfo.Video.CurrentStatus == StatusType.Closed)
                    {
                        await ExitLiveViewing();

                        CloseLive?.Invoke(this);
                    }
                }
            }
        }
Пример #3
0
        private async void _RtmpClient_Stopped(NicovideoRtmpClientStoppedEventArgs args)
        {
            await HohoemaApp.UIDispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
            {
                using (var releaser = await _VideoStreamSrouceAssignLock.LockAsync())
                {
                    MediaPlayer.Source = null;

                    VideoStreamSource = null;
                    _MediaSource?.Dispose();
                    _MediaSource = null;
                }

                Debug.WriteLine("recieve exit live stream: " + LiveId);

                CloseLive?.Invoke(this);

                StartNextLiveDetection(DefaultNextLiveSubscribeDuration);
            });
        }
Пример #4
0
        private async Task ClearLeoPlayer()
        {
            _UIScheduler.Schedule(() =>
            {
                if (MediaPlayer.Source == _MediaSource)
                {
                    MediaPlayer.Source = null;

                    CloseLive?.Invoke(this);
                }

                _Mss?.Dispose();
                _Mss = null;
                _MediaSource?.Dispose();
                _MediaSource = null;
                _AdaptiveMediaSource?.Dispose();
                _AdaptiveMediaSource = null;
            });

            await Task.CompletedTask;
        }