예제 #1
0
        /// <summary>
        /// Resets player variables
        /// </summary>
        private void resetPlayer()
        {
            // If we have an image mounted, unmount it
            if (mountedPlayback)
            {
                queuedMedia.UnMount();
                mountedPlayback = false;
            }

            // reset player variables

            if (GUIGraphicsContext.IsFullScreenVideo)
            {
                GUIGraphicsContext.IsFullScreenVideo = false;
            }

            activeMedia   = null;
            queuedMedia   = null;
            _playerState  = MoviePlayerState.Idle;
            _resumeActive = false;
            _forcePlay    = false;
            listenToExternalPlayerEvents = false;
            donePlayingCustomIntros      = false;
            customIntrosPlayed           = 0;
            ClearPlayProperties();

            logger.Debug("Reset.");
        }
예제 #2
0
        public void Play(DBMovieInfo movie, int part)
        {
            // stop the mediainfo background process if it is running
            MovingPicturesCore.ProcessManager.CancelProcess(typeof(MediaInfoUpdateProcess));

            // stop the internal player if it's running
            if (g_Player.Playing)
            {
                g_Player.Stop();
            }

            // set player state working
            _playerState = MoviePlayerState.Processing;

            // queue the local media object in case we first need to play the custom intro
            // we can get back to it later.
            queuedMedia = movie.LocalMedia[part - 1];

            // try playing our custom intro (if present). If successful quit, as we need to
            // wait for the intro to finish.
            bool success = playCustomIntro();

            if (success)
            {
                return;
            }

            // Start movie
            playMovie(movie, part);
        }
예제 #3
0
        private void onMediaStarted(DBLocalMedia localMedia)
        {
            // set playback active
            _playerState = MoviePlayerState.Playing;

            DBMovieInfo previousMovie = CurrentMovie;

            activeMedia = localMedia;

            // Update OSD (delayed)
            Thread newThread = new Thread(new ThreadStart(UpdatePlaybackInfo));

            newThread.IsBackground = true;
            newThread.Start();

            // only invoke movie started event if we were not playing this movie before
            if (previousMovie != CurrentMovie)
            {
                if (MovieStarted != null)
                {
                    MovieStarted(CurrentMovie);
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Resets player variables
        /// </summary>
        private void resetPlayer()
        {
            // If we have an image mounted, unmount it
            if (mountedPlayback) {
                queuedMedia.UnMount();
                mountedPlayback = false;
            }

            // reset player variables

            if (GUIGraphicsContext.IsFullScreenVideo)
                GUIGraphicsContext.IsFullScreenVideo = false;

            activeMedia = null;
            queuedMedia = null;
            _playerState = MoviePlayerState.Idle;
            _resumeActive = false;
            _forcePlay = false;
            listenToExternalPlayerEvents = false;
            donePlayingCustomIntros = false;
            customIntrosPlayed = 0;
            ClearPlayProperties();

            logger.Debug("Reset.");
        }
예제 #5
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
                switch (PromptUserToResume(movie))
                {
                  case ResumeDialogResult.Resume: _resumeActive = true; part = movie.ActiveUserSettings.ResumePart; break;
                  case ResumeDialogResult.FromBeginning: _resumeActive = false; clearMovieResumeState(movie); break;
                  case ResumeDialogResult.Cancel:return;
                }

                // 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);
        }
예제 #6
0
        private void onMediaStarted(DBLocalMedia localMedia)
        {
            // set playback active
            _playerState = MoviePlayerState.Playing;

            DBMovieInfo previousMovie = CurrentMovie;
            activeMedia = localMedia;

            // Update OSD (delayed)
            Thread newThread = new Thread(new ThreadStart(UpdatePlaybackInfo));
            newThread.IsBackground = true;
            newThread.Start();

            // only invoke movie started event if we were not playing this movie before
            if (previousMovie != CurrentMovie) {
                if (MovieStarted != null) MovieStarted(CurrentMovie);
            }
        }
예제 #7
0
        public void Play(DBMovieInfo movie, int part)
        {
            // stop the mediainfo background process if it is running
            MovingPicturesCore.ProcessManager.CancelProcess(typeof(MediaInfoUpdateProcess));

            // stop the internal player if it's running
            if (g_Player.Playing)
                g_Player.Stop();

            // set player state working
            _playerState = MoviePlayerState.Processing;

            // queue the local media object in case we first need to play the custom intro
            // we can get back to it later.
            queuedMedia = movie.LocalMedia[part-1];

            // try playing our custom intro (if present). If successful quit, as we need to
            // wait for the intro to finish.
            bool success = playCustomIntro();
            if (success) return;

            // Start movie
            playMovie(movie, part);
        }
        private void onMediaStarted(DBLocalMedia localMedia)
        {
            // set playback active
            _playerState = MoviePlayerState.Playing;

            DBMovieInfo previousMovie = CurrentMovie;
            activeMedia = localMedia;

            // Update OSD (delayed)
            Thread newThread = new Thread(new ThreadStart(UpdatePlaybackInfo));
            newThread.Start();

            // only invoke movie started event if we were not playing this movie before
            if (previousMovie != CurrentMovie) {
                if (MovingPicturesCore.Settings.FollwitEnabled)
                    MovingPicturesCore.Follwit.CurrentlyWatching(localMedia.AttachedMovies[0], true);
                if (MovieStarted != null) MovieStarted(CurrentMovie);
            }
        }
예제 #9
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);
        }