Пример #1
0
        /// <summary>
        /// Mount the accessory to all outfits, or store it when the it can't be mounted.
        /// </summary>
        /// <param name="accessory">The accessory to add.</param>
        /// <param name="addSettings">The accessory mount settings.</param>
        /// <param name="mustMount">
        /// If true a failure to immediately mount will result in a failure to add.  Otherwise
        /// a failure to immeidately mount will result in the accessory being stored.
        /// </param>
        /// <returns>
        /// The result of the add operation.  (Will only ever be 'success' or 'failure'.)
        /// </returns>
        public MountResult Add(
            Accessory accessory, AccessoryAddSettings addSettings, bool mustMount = false)
        {
            if (!accessory)
            {
                Debug.LogError("Accessory is null.");
                return(MountResult.FailedOnError);
            }

            // Remember: Don't need to check mounter validity.  Settings setter does that.

            for (int i = 0; i < m_Items.Count; i++)
            {
                if (m_Items[i].Accessory && m_Items[i].Accessory == accessory)
                {
                    // This is an error.  Must use modify method to change configuration.
                    Debug.LogError("Accessory is already added: " + accessory.name, Owner);
                    return(MountResult.FailedOnError);
                }
            }

            MountResult status = MountResult.FailedOnError;

            var mountInfo = new AccessoryMountInfo();

            mountInfo.Accessory = accessory;
            mountInfo.Apply(addSettings);

            if (m_Outfit)
            {
                status = MountToOutfit(ref mountInfo);
            }
            else if (mustMount)
            {
                Debug.LogError("Must succeed failure.  No outfit: " + accessory.name, Owner);
                return(MountResult.FailedOnError);
            }

            bool isMounted = (status == MountResult.Success);

            if (!isMounted)
            {
                if (mustMount)
                {
                    Debug.LogErrorFormat(Owner,
                                         "Must succeed failure.  Failed to mount to outfit: Accessory: {0}, Status: {1}",
                                         accessory.name, status);

                    return(MountResult.FailedOnError);
                }

                StoreAccessory(ref mountInfo);
            }

            LinkAccessory(mountInfo);

            return(isMounted ? MountResult.Success : MountResult.Stored);
        }
Пример #2
0
 public bool Handle(MountResult result)
 {
     if (result.Result == MountErrorType.SUCCESS)
     {
         return(true);
     }
     HandleError(result.Description, result.InnerException);
     return(false);
 }
Пример #3
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);
        }
 /// <summary>
 /// The status is not 'success' and not 'stored'.
 /// </summary>
 /// <param name="status">The status to evaluate.</param>
 /// <returns>The status is not 'success' and not 'stored'.</returns>
 public static bool IsFailed(this MountResult status)
 {
     return(!(status == MountResult.Success || status == MountResult.Stored));
 }
Пример #5
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);
            }
        }