Example #1
0
        protected override bool RenameWorker()
        {
            // make sure this job is approved
            if (!Approved)
            {
                logger.Warn("Tried renaming an unapproved file!");
                return(false);
            }

            //if not already set, store the original filename for reversion purposes
            if (_localMedia != null && _localMedia.OriginalFileName == String.Empty)
            {
                _localMedia.OriginalFileName = Path.GetFileNameWithoutExtension(_originalName);
                _localMedia.Commit();
            }

            // rename the file!
            try {
                File.Move(OriginalName, NewName);
            }
            catch (Exception e) {
                logger.ErrorException("Unexpected error in file rename process!", e);
                return(false);
            }

            return(true);
        }
Example #2
0
 // store the duration of the file if it is not set
 private void updateMediaDuration(DBLocalMedia localMedia)
 {
     if (localMedia.Duration == 0)
     {
         logger.Debug("UpdateMediaDuration: LocalMedia={0}, Format={1}, Duration={2}", localMedia.FullPath, localMedia.VideoFormat, g_Player.Player.Duration.ToString(NumberFormatInfo.InvariantInfo));
         localMedia.Duration = ((int)g_Player.Player.Duration) * 1000;
         localMedia.Commit();
     }
 }
 // store the duration of the file if it is not set
 private void updateMediaDuration(DBLocalMedia localMedia)
 {
     if (localMedia.Duration == 0) {
         logger.Debug("UpdateMediaDuration: LocalMedia={0}, Format={1}, Duration={2}", localMedia.FullPath, localMedia.VideoFormat, g_Player.Player.Duration.ToString(NumberFormatInfo.InvariantInfo));
         localMedia.Duration = ((int)g_Player.Player.Duration) * 1000;
         localMedia.Commit();
     }
 }
Example #4
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);
        }