コード例 #1
0
        private void SaveExternalPlayers()
        {
            OMLApplication.ExecuteSafe(delegate
            {
                List <string> mappings = new List <string>();

                try
                {
                    string chosenBluRayPlayer = _externalPlayerSelectionBluRay.Chosen as string;
                    ExternalPlayer.KnownPlayers bluRayPlayer = (ExternalPlayer.KnownPlayers)Enum.Parse(typeof(ExternalPlayer.KnownPlayers), chosenBluRayPlayer);

                    if (bluRayPlayer != ExternalPlayer.KnownPlayers.None)
                    {
                        if (!string.IsNullOrEmpty(_externalPlayerPathBluRay.Value) &&
                            _externalPlayerPathBluRay.Value.Trim().Length != 0)
                        {
                            mappings.Add(VideoFormat.BLURAY.ToString() + "|" + ((int)bluRayPlayer).ToString() + "|" + _externalPlayerPathBluRay.Value.Trim());
                        }
                    }

                    string chosenHDDVDPlayer = _externalPlayerSelectionHDDVD.Chosen as string;
                    ExternalPlayer.KnownPlayers hddvdPlayer = (ExternalPlayer.KnownPlayers)Enum.Parse(typeof(ExternalPlayer.KnownPlayers), chosenHDDVDPlayer);

                    if (hddvdPlayer != ExternalPlayer.KnownPlayers.None)
                    {
                        if (!string.IsNullOrEmpty(_externalPlayerPathHDDVD.Value) &&
                            _externalPlayerPathHDDVD.Value.Trim().Length != 0)
                        {
                            mappings.Add(VideoFormat.HDDVD.ToString() + "|" + ((int)hddvdPlayer).ToString() + "|" + _externalPlayerPathHDDVD.Value.Trim());
                        }
                    }

                    string chosenAllPlayer = _externalPlayerSelectionAll.Chosen as string;
                    ExternalPlayer.KnownPlayers allPlayer = (ExternalPlayer.KnownPlayers)Enum.Parse(typeof(ExternalPlayer.KnownPlayers), chosenAllPlayer);

                    if (allPlayer != ExternalPlayer.KnownPlayers.None)
                    {
                        if (!string.IsNullOrEmpty(_externalPlayerPathAll.Value) &&
                            _externalPlayerPathAll.Value.Trim().Length != 0)
                        {
                            mappings.Add(VideoFormat.ALL.ToString() + "|" + ((int)allPlayer).ToString() + "|" + _externalPlayerPathAll.Value.Trim());
                        }
                    }

                    OMLSettings.ExternalPlayerMapping = mappings;
                    ExternalPlayer.RefreshExternalPlayerList();
                }
                catch (Exception ex)
                {
                    Utilities.DebugLine("[Settings] Error saving external player settings", ex);
                }
            });
        }
コード例 #2
0
        private void SetupExternalPlayers()
        {
            ExternalPlayerItem bluRayPlayer = ExternalPlayer.GetExternalForFormat(VideoFormat.BLURAY);
            ExternalPlayerItem allPlayers   = ExternalPlayer.GetExternalForFormat(VideoFormat.ALL);
            ExternalPlayerItem hddvdPlayer  = ExternalPlayer.GetExternalForFormat(VideoFormat.HDDVD);

            List <string> externalPlayerChoices = new List <string>();

            foreach (string player in Enum.GetNames(typeof(ExternalPlayer.KnownPlayers)))
            {
                externalPlayerChoices.Add(player);
            }

            _externalPlayerSelectionAll.Options    = externalPlayerChoices;
            _externalPlayerSelectionBluRay.Options = externalPlayerChoices;
            _externalPlayerSelectionHDDVD.Options  = externalPlayerChoices;

            _externalPlayerSelectionBluRay.Chosen = (bluRayPlayer == null)
                                                 ? ExternalPlayer.KnownPlayers.None.ToString()
                                                 : bluRayPlayer.PlayerType.ToString();

            _externalPlayerSelectionAll.Chosen = (allPlayers == null)
                                                 ? ExternalPlayer.KnownPlayers.None.ToString()
                                                 : allPlayers.PlayerType.ToString();

            _externalPlayerSelectionHDDVD.Chosen = (hddvdPlayer == null)
                                                 ? ExternalPlayer.KnownPlayers.None.ToString()
                                                 : hddvdPlayer.PlayerType.ToString();

            List <string> localFixedDrivesOptions = new List <string>();

            foreach (DriveInfo dInfo in GetFileSystemDrives())
            {
                localFixedDrivesOptions.Add(dInfo.Name);
            }

            _localFixedDrivesBluRay.Options = localFixedDrivesOptions;
            _localFixedDrivesHDDVD.Options  = localFixedDrivesOptions;
            _localFixedDrivesAll.Options    = localFixedDrivesOptions;
            _LocalFixedDrives.Options       = localFixedDrivesOptions;

            _externalPlayerPathBluRay.Value = (bluRayPlayer != null) ? bluRayPlayer.Path : string.Empty;
            _externalPlayerPathHDDVD.Value  = (hddvdPlayer != null) ? hddvdPlayer.Path : string.Empty;
            _externalPlayerPathAll.Value    = (allPlayers != null) ? allPlayers.Path : string.Empty;
        }
コード例 #3
0
        /// <summary>
        /// Creates the movie player based on the the video formatin in the Title.
        /// </summary>
        /// <param name="title">The title.</param>
        /// <returns></returns>
        static public IPlayMovie CreateMoviePlayer(MediaSource source)
        {
            // this is an attempt to determine the physical location of the media if it was moved unexpectedly.
            // The following function call is responsible for quite a bit of slow down and the user community
            //  strongly believes that the app should not be responsible for auto-correcting movie locations.
            //  For what it's worth I agree so I'm commenting it out for now.
            // source.Disk.FindPath();
            // NOTE FROM TRANSLUCENT:  We dot NOT code for personal quirks at the expense of everyone else when it kills performance.
            // Keep this turned OFF!  If you disagree feel free to chat with me about it.

            string      mediaPath   = null;
            VideoFormat mediaFormat = VideoFormat.UNKNOWN;

            // for now play just online titles. add offline capabilities later
            OMLApplication.DebugLine("[MoviePlayerFactory] Determing MoviePlayer to use for: {0}", source);
            if ((File.Exists(source.MediaPath) || Directory.Exists(source.MediaPath)) || source.Format == VideoFormat.URL)
            {
                // This is for transcoding debugging
                if (OMLSettings.DebugTranscoding)
                {
                    OMLApplication.DebugLine("[MoviePlayerFactory] TranscodePlayer created (debug): {0}", source);
                    return(new TranscodePlayer(source));
                }

                // if we need to be mounted - do that now so we can get the real type
                if (NeedsMounting(source.Format))
                {
                    mediaFormat = MountImage(source.MediaPath, out mediaPath);
                }

                // if we don't need mounting or the mounting failed setup the paths
                if (mediaFormat == VideoFormat.UNKNOWN)
                {
                    mediaFormat = source.Format;
                    mediaPath   = source.MediaPath;
                }

                if (mediaFormat == VideoFormat.URL)
                {
                    OMLApplication.DebugLine("[MoviePlayerFactory] UrlMoviePlayer created: {0}", source);
                    return(new MoviePlayerUrl(source));
                }

                if (!OMLApplication.Current.IsExtender &&
                    ExternalPlayer.ExternalPlayerExistForType(mediaFormat))
                {
                    OMLApplication.DebugLine("[MoviePlayerFactory] ExternalPlayer created: {0}", source);
                    return(new ExternalPlayer(mediaPath, mediaFormat));
                }
                else if (mediaFormat == VideoFormat.WPL) // if its a playlist, do that first
                {
                    OMLApplication.DebugLine("[MoviePlayerFactory] WPLMoviePlayer created: {0}", source);
                    return(new MoviePlayerWPL(source));
                }
                else if (mediaFormat == VideoFormat.WVX) // if its a playlist, do that first
                {
                    OMLApplication.DebugLine("[MoviePlayerFactory] WVXMoviePlayer created: {0}", source);
                    return(new MoviePlayerWVX(source));
                }
                else if (IsExtenderDVD_NoTranscoding(source)) // play the dvd
                {
                    OMLApplication.DebugLine("[MoviePlayerFactory] ExtenderDVDPlayer created: {0}", source);
                    return(new ExtenderDVDPlayer(source));
                }
                else if (OMLApplication.Current.IsExtender && mediaFormat == VideoFormat.BLURAY && FileScanner.IsBluRay(mediaPath))
                {
                    OMLApplication.DebugLine("[MoviePlayerFactory] ExtenderBlurayPlayer created: {0}", source);
                    // we need to figure out if you are on an extender and using windows7, then don't try to transcode stuff
                    if (OMLApplication.IsWindows7)
                    {
                        OMLApplication.DebugLine("[MoviePlayerFactory] VideoPlayer created: {0}", source);
                        return(new VideoPlayer(source));
                    }
                    return(new TranscodeBluRayPlayer(source));
                }
                else if (OMLApplication.Current.IsExtender && mediaFormat == VideoFormat.HDDVD && FileScanner.IsHDDVD(mediaPath))
                {
                    OMLApplication.DebugLine("[MoviePlayerFactory] ExtenderHDDVDPlayer created: {0}", source);
                    // we need to figure out if you are on an extender and using windows7, then don't try to transcode stuff
                    if (OMLApplication.IsWindows7)
                    {
                        OMLApplication.DebugLine("[MoviePlayerFactory] VideoPlayer created: {0}", source);
                        return(new VideoPlayer(source));
                    }
                    return(new TranscodeHDDVDPlayer(source));
                }
                else if (OMLApplication.Current.IsExtender && NeedsTranscode(mediaFormat)) // if it needs to be transcoded
                {
                    OMLApplication.DebugLine("[MoviePlayerFactory] TranscodePlayer created ({1}): {0}", source, mediaFormat);
                    // we need to figure out if you are on an extender and using windows7, then don't try to transcode stuff
                    if (OMLApplication.IsWindows7 && mediaFormat != VideoFormat.MKV)
                    {
                        OMLApplication.DebugLine("[MoviePlayerFactory] VideoPlayer created: {0}", source);
                        return(new VideoPlayer(source));
                    }
                    return(new TranscodePlayer(source));
                }
                else if (mediaFormat == VideoFormat.DVD && FileScanner.IsDVD(mediaPath)) // play the dvd
                {
                    OMLApplication.DebugLine("[MoviePlayerFactory] DVDMoviePlayer created: {0}", source);
                    return(new DVDPlayer(source, mediaPath));
                }
                else if (mediaFormat == VideoFormat.BLURAY && FileScanner.IsBluRay(mediaPath))
                {
                    OMLApplication.DebugLine("[MoviePlayerFactory] BluRayPlayer created: {0}", source);
                    return(new BluRayPlayer(source, mediaPath));
                }
                else if (mediaFormat == VideoFormat.HDDVD && FileScanner.IsHDDVD(mediaPath))
                {
                    OMLApplication.DebugLine("[MoviePlayerFactory] HDDVDPlayer created: {0}", source);
                    return(new HDDVDPlayer(source, mediaPath));
                }
                //                else if (source.Format == VideoFormat.FOLDER)
                //                {
                //                    OMLApplication.DebugLine("[MoviePlayerFactory] FolderPlayer created: {0}", source);
                //                    return new FolderPlayer(movieItem);
                //                }
                else // try to play it (likely is avi/mkv/etc)
                {
                    OMLApplication.DebugLine("[MoviePlayerFactory] VideoPlayer created: {0}", source);
                    return(new VideoPlayer(source));
                }
            }
            else
            {
                OMLApplication.DebugLine("[MoviePlayerFactory] UnavailableMoviePlayer created");
                return(new UnavailableMoviePlayer(source));
            }
        }