Esempio n. 1
0
        private void playMovie(DBMovieInfo movie, int requestedPart)
        {
            logger.Debug("playMovie()");
            _playerState = MoviePlayerState.Processing;

            if (movie == null || requestedPart > movie.LocalMedia.Count || requestedPart < 1)
            {
                resetPlayer();
                return;
            }

            logger.Debug("Request: Movie='{0}', Part={1}", movie.Title, requestedPart);
            for (int i = 0; i < movie.LocalMedia.Count; i++)
            {
                logger.Debug("LocalMedia[{0}] = {1}, Duration = {2}", i, movie.LocalMedia[i].FullPath, movie.LocalMedia[i].Duration);
            }

            int part = requestedPart;

            // if this is a request to start the movie from the beginning, check if we should resume
            // or prompt the user for disk selection
            if (requestedPart == 1)
            {
                // check if we should be resuming, and if not, clear resume data
                _resumeActive = PromptUserToResume(movie);
                if (_resumeActive)
                {
                    part = movie.ActiveUserSettings.ResumePart;
                }
                else
                {
                    clearMovieResumeState(movie);
                }

                // if we have a multi-part movie composed of disk images and we are not resuming
                // ask which part the user wants to play
                if (!_resumeActive && movie.LocalMedia.Count > 1 && (movie.LocalMedia[0].IsImageFile || movie.LocalMedia[0].IsVideoDisc))
                {
                    GUIDialogFileStacking dlg = (GUIDialogFileStacking)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_FILESTACKING);
                    if (null != dlg)
                    {
                        dlg.SetNumberOfFiles(movie.LocalMedia.Count);
                        dlg.DoModal(GUIWindowManager.ActiveWindow);
                        part = dlg.SelectedFile;
                        if (part < 1)
                        {
                            resetPlayer();
                            return;
                        }
                    }
                }
            }

            DBLocalMedia mediaToPlay = movie.LocalMedia[part - 1];
            MediaState   mediaState  = mediaToPlay.State;

            while (mediaState != MediaState.Online)
            {
                switch (mediaState)
                {
                case MediaState.Removed:
                    _gui.ShowMessage("Error", Translation.MediaIsMissing);
                    resetPlayer();
                    return;

                case MediaState.Offline:
                    string bodyString = String.Format(Translation.MediaNotAvailableBody, mediaToPlay.MediaLabel);
                    // Special debug line to troubleshoot availability issues
                    logger.Debug("Media not available: Path={0}, DriveType={1}, Serial={2}, ExpectedSerial={3}",
                                 mediaToPlay.FullPath, mediaToPlay.ImportPath.GetDriveType().ToString(),
                                 mediaToPlay.ImportPath.GetVolumeSerial(), mediaToPlay.VolumeSerial);

                    // Prompt user to enter media
                    if (!_gui.ShowCustomYesNo(Translation.MediaNotAvailableHeader, bodyString, Translation.Retry, Translation.Cancel, true))
                    {
                        // user cancelled so exit
                        resetPlayer();
                        return;
                    }
                    break;

                case MediaState.NotMounted:
                    // Mount this media
                    MountResult result = mediaToPlay.Mount();
                    while (result == MountResult.Pending)
                    {
                        if (_gui.ShowCustomYesNo(Translation.VirtualDriveHeader, Translation.VirtualDriveMessage, Translation.Retry, Translation.Cancel, true))
                        {
                            // User has chosen to retry
                            // We stay in the mount loop
                            result = mediaToPlay.Mount();
                        }
                        else
                        {
                            // Exit the player
                            resetPlayer();
                            return;
                        }
                    }

                    // If the mounting failed (can not be solved within the loop) show error and return
                    if (result == MountResult.Failed)
                    {
                        _gui.ShowMessage(Translation.Error, Translation.FailedMountingImage);
                        // Exit the player
                        resetPlayer();
                        return;
                    }

                    // Mounting was succesfull, break the mount loop
                    break;
                }

                // Check mediaState again
                mediaState = mediaToPlay.State;
            }

            // Get the path to the playable video.
            string videoPath = mediaToPlay.GetVideoPath();

            // If the media is an image, it will be mounted by this point so
            // we flag the mounted playback variable
            mountedPlayback = mediaToPlay.IsImageFile;

            // if we do not have MediaInfo but have the AutoRetrieveMediaInfo setting toggled
            // get the media info
            if (!mediaToPlay.HasMediaInfo && MovingPicturesCore.Settings.AutoRetrieveMediaInfo)
            {
                mediaToPlay.UpdateMediaInfo();
                mediaToPlay.Commit();
            }

            // store the current media object so we can request it later
            queuedMedia = mediaToPlay;

            // start playback

            if (_resumeActive && movie.LocalMedia[0].IsBluray)
            {
                _forcePlay = true;
                g_Player.SetResumeBDTitleState = movie.ActiveUserSettings.ResumeTitleBD;
            }
            logger.Info("Playing: Movie='{0}' FullPath='{1}', VideoPath='{2}', Mounted='{3}'", movie.Title, mediaToPlay.FullPath, videoPath, mountedPlayback.ToString());
            playFile(videoPath, mediaToPlay.VideoFormat);
        }
Esempio n. 2
0
        private void BuildGraph()
        {
            int hr;
            try
            {
                lblTotalTime.Text = mvs.PlayTime.ToString();
                TimeSpan tt = TimeSpan.Parse(mvs.PlayTime);
                DateTime dt = new DateTime(tt.Ticks);
                lblTotalTime.Text = String.Format("{0:HH:mm:ss}", dt);

                if (mvs.LocalMedia[0].IsDVD)
                {

                    mediaToPlay = mvs.LocalMedia[0];
                    MediaState mediaState = mediaToPlay.State;
                    if (mediaState == MediaState.NotMounted)
                    {
                        MountResult result = mediaToPlay.Mount();
                    }

                    string videoPath = mediaToPlay.GetVideoPath();

                    if (videoPath != null)
                        FirstPlayDvd(videoPath);
                    else
                      FirstPlayDvd(mvs.LocalMedia[0].File.FullName);
                    // Add delegates for Windowless operations
                    AddHandlers();
                    MainForm_ResizeMove(null, null);

                }
                else
                {
                    _graphBuilder = (IFilterGraph2)new FilterGraph();
                    _rotEntry = new DsROTEntry((IFilterGraph)_graphBuilder);
                    _mediaCtrl = (IMediaControl)_graphBuilder;
                    _mediaSeek = (IMediaSeeking)_graphBuilder;
                    _mediaPos = (IMediaPosition)_graphBuilder;
                    _mediaStep = (IVideoFrameStep)_graphBuilder;
                    _vmr9Filter = (IBaseFilter)new VideoMixingRenderer9();
                    ConfigureVMR9InWindowlessMode();
                    AddHandlers();
                    MainForm_ResizeMove(null, null);
                    hr = _graphBuilder.AddFilter(_vmr9Filter, "Video Mixing Render 9");
                    AddPreferedCodecs(_graphBuilder);
                    DsError.ThrowExceptionForHR(hr);
                    hr = _graphBuilder.RenderFile(mvs.LocalMedia[0].File.FullName, null);
                    DsError.ThrowExceptionForHR(hr);
                }

            }
            catch (Exception e)
            {
                CloseDVDInterfaces();
                logger.ErrorException("An error occured during the graph building : \r\n\r\n",e);
            }
        }
Esempio n. 3
0
        private void BuildGraph()
        {
            int hr;

            try
            {
                lblTotalTime.Text = mvs.PlayTime.ToString();
                TimeSpan tt = TimeSpan.Parse(mvs.PlayTime);
                DateTime dt = new DateTime(tt.Ticks);
                lblTotalTime.Text = String.Format("{0:HH:mm:ss}", dt);

                if (mvs.LocalMedia[0].IsDVD)
                {
                    mediaToPlay = mvs.LocalMedia[0];
                    MediaState mediaState = mediaToPlay.State;
                    if (mediaState == MediaState.NotMounted)
                    {
                        MountResult result = mediaToPlay.Mount();
                    }



                    string videoPath = mediaToPlay.GetVideoPath();

                    if (videoPath != null)
                    {
                        FirstPlayDvd(videoPath);
                    }
                    else
                    {
                        FirstPlayDvd(mvs.LocalMedia[0].File.FullName);
                    }
                    // Add delegates for Windowless operations
                    AddHandlers();
                    MainForm_ResizeMove(null, null);
                }
                else
                {
                    _graphBuilder = (IFilterGraph2) new FilterGraph();
                    _rotEntry     = new DsROTEntry((IFilterGraph)_graphBuilder);
                    _mediaCtrl    = (IMediaControl)_graphBuilder;
                    _mediaSeek    = (IMediaSeeking)_graphBuilder;
                    _mediaPos     = (IMediaPosition)_graphBuilder;
                    _mediaStep    = (IVideoFrameStep)_graphBuilder;
                    _vmr9Filter   = (IBaseFilter) new VideoMixingRenderer9();
                    ConfigureVMR9InWindowlessMode();
                    AddHandlers();
                    MainForm_ResizeMove(null, null);
                    hr = _graphBuilder.AddFilter(_vmr9Filter, "Video Mixing Render 9");
                    AddPreferedCodecs(_graphBuilder);
                    DsError.ThrowExceptionForHR(hr);
                    hr = _graphBuilder.RenderFile(mvs.LocalMedia[0].File.FullName, null);
                    DsError.ThrowExceptionForHR(hr);
                }
            }
            catch (Exception e)
            {
                CloseDVDInterfaces();
                logger.ErrorException("An error occured during the graph building : \r\n\r\n", e);
            }
        }