Exemplo n.º 1
0
        private static void PlayLiveStream(string rtspUrl, Process liveStreamPlayerProcess)
        {
            LiveStream liveStream = Proxies.ControlService.GetLiveStreamByRtspUrl(rtspUrl).Result;

            if (liveStream != null)
            {
                if (liveStreamPlayerProcess == null)
                {
                    _keepAliveThread            = new KeepAliveThread();
                    _keepAliveThread.LiveStream = liveStream;
                    _keepAliveThread.Start();

                    string name = String.IsNullOrEmpty(liveStream.TimeshiftFile) ? liveStream.RtspUrl : liveStream.TimeshiftFile;

                    MessageBox.Show("Can't play stream " + name + " in VLC." + Environment.NewLine + Environment.NewLine
                                    + "Press OK to stop the stream.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    _keepAliveThread.Stop(true);
                }
                else
                {
                    bool exited = false;
                    while (!exited)
                    {
                        if (!Proxies.ControlService.KeepLiveStreamAlive(liveStream).Result)
                        {
                            break;
                        }
                        exited = _playerExitedEvent.WaitOne(_checkInterval, false);
                    }
                }

                Proxies.ControlService.StopLiveStream(liveStream).Wait();
            }
            else
            {
                MessageBox.Show("Failed to find live stream for " + rtspUrl, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        private static void PlayLiveStream(string rtspUrl, Process liveStreamPlayerProcess)
        {
            LiveStream liveStream = Proxies.ControlService.GetLiveStreamByRtspUrl(rtspUrl).Result;
            if (liveStream != null)
            {
                if (liveStreamPlayerProcess == null)
                {
                    _keepAliveThread = new KeepAliveThread();
                    _keepAliveThread.LiveStream = liveStream;
                    _keepAliveThread.Start();

                    string name = String.IsNullOrEmpty(liveStream.TimeshiftFile) ? liveStream.RtspUrl : liveStream.TimeshiftFile;

                    MessageBox.Show("Can't play stream " + name + " in VLC." + Environment.NewLine + Environment.NewLine
                        + "Press OK to stop the stream.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    _keepAliveThread.Stop(true);
                }
                else
                {
                    bool exited = false;
                    while (!exited)
                    {
                        if (!Proxies.ControlService.KeepLiveStreamAlive(liveStream).Result)
                        {
                            break;
                        }
                        exited = _playerExitedEvent.WaitOne(_checkInterval, false);
                    }
                }

                Proxies.ControlService.StopLiveStream(liveStream).Wait();
            }
            else
            {
                MessageBox.Show("Failed to find live stream for " + rtspUrl, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }