示例#1
0
        /// <summary>
        /// Gets the MediaInfo for the given videopath
        /// </summary>
        /// <param name="self"></param>
        /// <param name="videoPath">path to the video</param>
        /// <returns>MediaInfoWrapper object for this video</returns>
        public static MediaInfoWrapper GetMediaInfo(this VideoFormat self, string videoPath)
        {
            string mainFeatureFile;

            if (self == VideoFormat.DVD)
            {
                // because dvds have multiple files
                // we must build a list of all IFO files, and loop through them.
                // the best file wins
                List <string> files = new List <string>();
                files.AddRange(Directory.GetFiles(Path.GetDirectoryName(videoPath), "*.ifo"));
                mainFeatureFile = VideoUtility.FindFeatureFilm(files);
            }
            else
            {
                mainFeatureFile = self.GetMainFeatureFilePath(videoPath);
            }

            if (videoPath != mainFeatureFile)
            {
                logger.Debug("Format={0}, FeatureFilmFile='{1}'", self, mainFeatureFile);
            }

            return(new MediaInfoWrapper(mainFeatureFile));
        }
        // start playback of a file (using known format)
        private void playFile(string media, VideoFormat videoFormat)
        {
            logger.Debug("Processing media for playback: File={0}, VideoFormat={1}", media, videoFormat);

            // HD Playback
            if (videoFormat == VideoFormat.Bluray || videoFormat == VideoFormat.HDDVD) {

                // Take proper action according to playback setting
                bool hdExternal = MovingPicturesCore.Settings.UseExternalPlayer;

                // Launch external player if user has configured it for HD playback.
                if (hdExternal) {
                    LaunchHDPlayer(media);
                    return;
                }

                // Alternate playback HD content (without menu)
                string newMedia = videoFormat.GetMainFeatureFilePath(media);
                 if (newMedia != null) {
                    // Check if the stream extension is in the mediaportal extension list.
                    if (Utility.IsMediaPortalVideoFile(newMedia)) {
                        media = newMedia;
                    }
                    else {
                        // Show a dialog to the user that explains how to configure the alternate playback
                        string ext = (videoFormat == VideoFormat.Bluray) ? ".M2TS" : ".EVO";
                        logger.Info("HD Playback: extension '{0}' is missing from the mediaportal configuration.", ext);
                        _gui.ShowMessage(Translation.PlaybackFailedHeader, String.Format(Translation.PlaybackFailed, ext));
                        resetPlayer();
                        return;
                    }
                }

                logger.Info("HD Playback: Internal, Media={0}", media);
            }

            // We start listening to external player events
            listenToExternalPlayerEvents = true;

            // Play the file using the mediaportal player
            bool success = g_Player.Play(media.Trim());

            // We stop listening to external player events
            listenToExternalPlayerEvents = false;

            // if the playback started and we are still playing go full screen (internal player)
            if (success && g_Player.Playing)
                g_Player.ShowFullScreenWindow();
            else if (!success) {
                // if the playback did not happen, reset the player
                logger.Info("Playback failed: Media={0}", media);
                resetPlayer();
            }
        }