示例#1
0
        private void onPlayBackStoppedOrChanged(g_Player.MediaType type, int timeMovieStopped, string filename)
        {
            if (type != g_Player.MediaType.Video || _playerState != MoviePlayerState.Playing)
            {
                return;
            }

            if (customIntrosPlayed > 0)
            {
                return;
            }

            logger.Debug("OnPlayBackStoppedOrChanged: File={0}, Movie={1}, Part={2}, TimeStopped={3}", filename, _activeMovie.Title, _activePart, timeMovieStopped);

            // Because we can't get duration for DVD's at start like with normal files
            // we are getting the duration when the DVD is stopped. If the duration of
            // feature is an hour or more it's probably the main feature and we will update
            // the database.
            if (g_Player.IsDVD && (g_Player.Player.Duration >= 3600))
            {
                DBLocalMedia playingFile = _activeMovie.LocalMedia[_activePart - 1];
                updateMediaDuration(playingFile);
            }

            int requiredWatchedPercent = MovingPicturesCore.Settings.MinimumWatchPercentage;
            int watchedPercentage      = _activeMovie.GetPercentage(_activePart, timeMovieStopped);
            int resumeTitleBD          = g_Player.SetResumeBDTitleState;

            logger.Debug("Watched: Percentage=" + watchedPercentage + ", Required=" + requiredWatchedPercent);

            // if enough of the movie has been watched
            if (watchedPercentage >= requiredWatchedPercent)
            {
                // run movie ended logic
                onMovieEnded(_activeMovie);
            }
            // otherwise, store resume data.
            else
            {
                byte[] resumeData = null;
                g_Player.Player.GetResumeState(out resumeData);
                updateMovieResumeState(_activeMovie, _activePart, timeMovieStopped, resumeData, resumeTitleBD);
                // run movie stopped logic
                onMovieStopped(_activeMovie);
            }
        }