private void KillPlayerProcess()
 {
     try
     {
         if (_playerProcess.Id != 0)
         {
             PlayerCommunicatorControl communicator = new PlayerCommunicatorControl();
             communicator.SendRequest(RequestFactory.CreateRequest(MessageType.Termination));
         }
     }
     catch (System.Exception)
     {
     }
     // TODO. wait until exits or force it.
 }
        private void SetPlayerType(PlayerType playerType, bool shouldRunLocal)
        {
            try
            {
                // start player if it's not already running
                if (shouldRunLocal)
                {
                    bool isRunning = true;
                    try
                    {
                        if (_playerProcess.Id == 0)
                        {
                            isRunning = false;
                        }
                    }
                    catch (Exception)
                    {
                        isRunning = false;
                    }

                    if (!isRunning)
                    {
                        string arguments = SettingsManager.Instance.PlayerSettings.Port.ToString();
                        _playerProcess.StartInfo.Arguments = arguments;

                        // start process
                        _playerProcess.Start();
                    }
                }

                SetPlayerTypeRequest request = new SetPlayerTypeRequest();
                request.PlayerType = playerType;
                PlayerCommunicatorControl.SendRequest(request);
            }
            catch (System.Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Beispiel #3
0
        private void OnPlaybackPlay()
        {
            PlayRequest request = (PlayRequest)RequestFactory.CreateRequest(MessageType.Play);

            if (_playlistForm.GetCurrent().Count.Equals(0))
            {
                MessageBox.Show("Playlist is empty. Nothing to play", "Information");
                return;
            }

            request.Tracks = _playlistForm.GetCurrent();

            AResponse response = _playerCommunicatorControl.SendRequest(request);

            try
            {
                // if success
                if (response.ResponseType == ServerResponseType.Success)
                {
                    // set controls state
                    _mediaInfo.Open(_playlistForm.GetCurrent()[0]);
                    _playbackControl.PlaybackStarted(_mediaInfo.GetDuration());
                    _mediaInfo.Close();

                    _addonsForm.PlaybackStarted();

                    // Set volume
                    OnPlaybackVolume(_playbackControl.Volume);
                }
            }
            catch (System.Exception)
            {
            }
        }
        private void OnPlaybackPlay()
        {
            // Send play request
            PlayRequest request = (PlayRequest)RequestFactory.CreateRequest(MessageType.Play);

            if (_playlistForm.GetCurrent().Count.Equals(0))
            {
                MessageBox.Show("Playlist is empty. Nothing to play", "Information");
                return;
            }
            request.Tracks = _playlistForm.GetCurrent();
            _playerCommunicatorControl.SendRequest(request);

            // TODO set state based on response
            // set controls state
            _playbackControl.DisableSeeking();
            _playbackControl.PlaybackStarted(0);
        }
Beispiel #5
0
        private void OnPlaybackPlay()
        {
            // Check if valid selection on playlist
            if (_playlistControl.GetCurrent().Count.Equals(0))
            {
                MessageBox.Show("Playlist is empty. Nothing to play", "Information");
                return;
            }

            // Crop selected on playlist
            _playlistControl.CropSelected();

            // Lock playlist
            _playlistControl.LockListItems();

            // create the files list
            _files.Clear();
            int index = 0;

            foreach (string filename in _playlistControl.GetAll())
            {
                VideoFile newEntry = new VideoFile();
                newEntry.Filename      = filename;
                newEntry.Layout.ZOrder = index++;

                _files.Add(newEntry);
            }

            // Create and send Play playRequest
            PlayRequest playRequest = (PlayRequest)RequestFactory.CreateRequest(MessageType.Play);

            playRequest.Tracks = _playlistControl.GetAll();
            _playerCommunicatorControl.SendRequest(playRequest);

            // TODO set state based on response

            // set play state and compute maximum duration
            int maxDuration = 0;

            foreach (string track in _playlistControl.GetAll())
            {
                _mediaInfo.Open(track);
                int tmpDuration = _mediaInfo.GetDuration();
                _mediaInfo.Close();

                if (maxDuration < tmpDuration)
                {
                    maxDuration = tmpDuration;
                }
            }
            _playbackControl.PlaybackStarted(maxDuration);

            // Send Pause request
            _playerCommunicatorControl.SendRequest(RequestFactory.CreateRequest(MessageType.Pause));
            _playbackControl.PlaybackPaused();

            // Send layout request
            VideoLayoutRequest layoutRequest = new VideoLayoutRequest();

            foreach (VideoFile file in _files)
            {
                layoutRequest.TracksLayout.Add(file.Layout);
            }
            _playerCommunicatorControl.SendRequest(layoutRequest);

            // Send resume request
            _playerCommunicatorControl.SendRequest(RequestFactory.CreateRequest(MessageType.Resume));
            _playbackControl.PlaybackResumed();

            // Set volume
            OnPlaybackVolume(_playbackControl.Volume);
        }
Beispiel #6
0
        private void OnPlaybackPlay()
        {
            // Send sound effects
            SoundFxRequest soundFxRequest = new SoundFxRequest();

            soundFxRequest.Effects = _effectsForm.GetEnabledEffects();
            _playerCommunicatorControl.SendRequest(soundFxRequest);

            // Send play request
            PlayRequest request = (PlayRequest)RequestFactory.CreateRequest(MessageType.Play);

            if (_playlistForm.GetCurrent().Count.Equals(0))
            {
                MessageBox.Show("Playlist is empty. Nothing to play", "Information");
                return;
            }
            request.Tracks = _playlistForm.GetCurrent();
            _playerCommunicatorControl.SendRequest(request);

            // TODO set state based on response
            // set controls state
            _mediaInfo.Open(_playlistForm.GetCurrent()[0]);
            _playbackControl.PlaybackStarted(_mediaInfo.GetDuration());
            _mediaInfo.Close();
        }