Пример #1
0
        private async Task CloseRtmpConnection()
        {
            using (var releaser = await _RtmpClientAssignLock.LockAsync())
            {
                if (_RtmpClient != null)
                {
                    _RtmpClient.Started -= _RtmpClient_Started;
                    _RtmpClient.Stopped -= _RtmpClient_Stopped;

                    _RtmpClient?.Dispose();
                    _RtmpClient = null;

                    await Task.Delay(500);
                }
            }
        }
Пример #2
0
        private async Task OpenRtmpConnection(PlayerStatusResponse res)
        {
            await CloseRtmpConnection();

            using (var releaser = await _RtmpClientAssignLock.LockAsync())
            {
                if (_RtmpClient == null)
                {
                    _RtmpClient = new NicovideoRtmpClient();

                    _RtmpClient.Started += _RtmpClient_Started;
                    _RtmpClient.Stopped += _RtmpClient_Stopped;

                    await _RtmpClient.ConnectAsync(res);
                }
            }
        }
Пример #3
0
        private async Task OpenRtmpConnection(PlayerStatusResponse res)
        {
            await CloseRtmpConnection();

            using (var releaser = await _RtmpClientAssignLock.LockAsync())
            {
                if (_RtmpClient == null)
                {
                    _RtmpClient = new NicovideoRtmpClient();

                    _RtmpClient.Started += _RtmpClient_Started;
                    _RtmpClient.Stopped += _RtmpClient_Stopped;

                    try
                    {
                        await _RtmpClient.ConnectAsync(res);
                    }
                    catch (Exception ex)
                    {
                        _RtmpClient.Started -= _RtmpClient_Started;
                        _RtmpClient.Stopped -= _RtmpClient_Stopped;
                        _RtmpClient.Dispose();
                        _RtmpClient = null;
                        _EnsureStartLiveTimer?.Dispose();
                        _EnsureStartLiveTimer = null;

                        Debug.WriteLine("CAN NOT play Rtmp, Stop ensure open timer. : " + res.Stream.RtmpUrl);

                        FailedOpenLive?.Invoke(this, new FailedOpenLiveEventArgs()
                        {
                            Exception = ex,
                            Message   = "動画引用放送は未対応です"
                        });
                    }
                }
            }
        }