Example #1
0
        async void process_Exited(object sender, EventArgs e)
        {
            var process = (Process)sender;

            if (_isoMount != null)
            {
                _isoMount.Dispose();
                _isoMount = null;
            }

            DisposeLogFileStream();

            try
            {
                _logger.Info("FFMpeg exited with code {0} for {1}", process.ExitCode, _task.Request.OutputPath);
            }
            catch
            {
                _logger.Info("FFMpeg exited with an error for {0}", _task.Request.OutputPath);
            }

            _task.OnCompleted();

            if (!string.IsNullOrEmpty(_task.LiveTvStreamId))
            {
                try
                {
                    await _liveTvManager.CloseLiveStream(_task.LiveTvStreamId, CancellationToken.None).ConfigureAwait(false);
                }
                catch (Exception ex)
                {
                    _logger.ErrorException("Error closing live tv stream", ex);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Handles the Exited event of the CurrentProcess control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        void CurrentProcess_Exited(object sender, EventArgs e)
        {
            _currentProcess = null;

            _userInput.GlobalKeyDown -= KeyboardListener_KeyDown;

            var process = (Process)sender;

            var playlist = _playlist.ToList();
            var index    = CurrentPlaylistIndex;
            var ticks    = CurrentPositionTicks;

            process.Dispose();

            if (_currentIsoMount != null)
            {
                _currentIsoMount.Dispose();
                _currentIsoMount = null;
            }

            var media = index != -1 && playlist.Count > 0 ? playlist[index] : null;

            var args = new PlaybackStopEventArgs
            {
                Playlist            = playlist,
                Player              = this,
                EndingPlaylistIndex = index,
                EndingPositionTicks = ticks,
                EndingMedia         = media
            };

            EventHelper.QueueEventIfNotNull(PlaybackCompleted, this, args, Logger);

            _playbackManager.ReportPlaybackCompleted(args);

            OnPlayerExited();
        }