Esempio n. 1
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);
        }
Esempio n. 2
0
 public void CropSelected()
 {
     _playlistControl.CropSelected();
 }