private void LoadSettings() { // load settings using (Settings reader = new MPSettings()) { int hours, minutes; hours = reader.GetValueAsInt("musicdbreorg", "hours", 0); minutes = reader.GetValueAsInt("musicdbreorg", "minutes", 0); VerifySchedule(ref hours, ref minutes); hoursTextBox.Text = hours.ToString(); minutesTextBox.Text = minutes.ToString(); if (hoursTextBox.Text.Length == 1) { hoursTextBox.Text = "0" + hoursTextBox.Text; } if (minutesTextBox.Text.Length == 1) { minutesTextBox.Text = "0" + minutesTextBox.Text; } cbMonday.Checked = reader.GetValueAsBool("musicdbreorg", "monday", true); cbTuesday.Checked = reader.GetValueAsBool("musicdbreorg", "tuesday", true); cbWednesday.Checked = reader.GetValueAsBool("musicdbreorg", "wednesday", true); cbThursday.Checked = reader.GetValueAsBool("musicdbreorg", "thursday", true); cbFriday.Checked = reader.GetValueAsBool("musicdbreorg", "friday", true); cbSaturday.Checked = reader.GetValueAsBool("musicdbreorg", "saturday", true); cbSunday.Checked = reader.GetValueAsBool("musicdbreorg", "sunday", true); } }
public void LoadSettings() { using (Settings xmlreader = new MPSettings()) { defStyle = new SubtitleStyle(); defStyle.Load(xmlreader); delayInterval = xmlreader.GetValueAsInt("subtitles", "delayInterval", 250); bool save = xmlreader.GetValueAsBool("subtitles", "saveNever", true); if (save) { autoSaveType = AutoSaveTypeEnum.NEVER; } else { save = xmlreader.GetValueAsBool("subtitles", "saveAsk", false); autoSaveType = (save ? AutoSaveTypeEnum.ASK : AutoSaveTypeEnum.ALWAYS); } posRelativeToFrame = xmlreader.GetValueAsBool("subtitles", "subPosRelative", false); overrideASSStyle = xmlreader.GetValueAsBool("subtitles", "subStyleOverride", false); subPaths = xmlreader.GetValueAsString("subtitles", "paths", @".\"); adjustPosY = xmlreader.GetValueAsInt("subtitles", "adjustY", 0); autoShow = xmlreader.GetValueAsBool("subtitles", "enabled", true); selectionOff = xmlreader.GetValueAsBool("subtitles", "selectionoff", true); LoadAdvancedSettings(xmlreader); } }
public override void LoadSettings() { if (_serialPort != null && _serialPort.IsOpen) _serialPort.Close(); using (Settings reader = new MPSettings()) { DeviceModelName = reader.GetValueAsString("Auto3DPlugin", "OptomaModel", "Default"); PortName = reader.GetValueAsString("Auto3DPlugin", "OptomaPort", "None"); } if (_serialPort != null) { _serialPort.PortName = PortName; try { if (_serialPort.PortName != "None") _serialPort.Open(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Auto3D"); Log.Info("Auto3D: " + ex.Message); } } }
private bool restartIRApp = false; // Restart Haupp. IR-app. after MP quit /// <summary> /// Initialization /// </summary> public HcwHelper() { InitializeComponent(); using (Settings xmlreader = new MPSettings()) { logVerbose = xmlreader.GetValueAsBool("remote", "HCWVerboseLog", false); port = xmlreader.GetValueAsInt("remote", "HCWHelperPort", 2110); hcwEnabled = xmlreader.GetValueAsBool("remote", "HCW", false); } connection = new Connection(logVerbose); if (hcwEnabled && (GetDllPath() != string.Empty) && connection.Start(port) && irremote.IRSetDllDirectory(GetDllPath())) { Thread checkThread = new Thread(new ThreadStart(CheckThread)); checkThread.IsBackground = true; checkThread.Priority = ThreadPriority.Highest; checkThread.Name = "HcwHelperChecker"; checkThread.Start(); connection.ReceiveEvent += new Connection.ReceiveEventHandler(OnReceive); StartIR(); } else { connection.Send(port + 1, "APP", "STOP", DateTime.Now); Application.Exit(); } }
public VolumeHandler(int[] volumeTable) { bool isDigital = true; //string mixerControlledComponent = "Wave"; using (Settings reader = new MPSettings()) { int levelStyle = reader.GetValueAsInt("volume", "startupstyle", 0); if (levelStyle == 0) { _startupVolume = Math.Max(0, Math.Min(65535, reader.GetValueAsInt("volume", "lastknown", 52428))); } if (levelStyle == 1) { _startupVolume = _mixer.Volume; } if (levelStyle == 2) { _startupVolume = Math.Max(0, Math.Min(65535, reader.GetValueAsInt("volume", "startuplevel", 52428))); } //mixerControlledComponent = reader.GetValueAsString("volume", "controlledMixer", "Wave"); isDigital = reader.GetValueAsBool("volume", "digital", false); _showVolumeOSD = reader.GetValueAsBool("volume", "defaultVolumeOSD", true); } _mixer = new Mixer.Mixer(); _mixer.Open(0, isDigital); _volumeTable = volumeTable; _mixer.ControlChanged += new Mixer.MixerEventHandler(mixer_ControlChanged); }
public void Init() { using (Settings xmlreader = new MPSettings()) { _remoteConfigured = xmlreader.GetValueAsBool("remote", "Centarea", false); _verboseLogging = xmlreader.GetValueAsBool("remote", "CentareaVerbose", false); _mapMouseButton = xmlreader.GetValueAsBool("remote", "CentareaMouseOkMap", true); _mapJoystick = xmlreader.GetValueAsBool("remote", "CentareaJoystickMap", false); } if (!_remoteConfigured) { return; } Log.Debug("Centarea: Initializing Centarea HID remote"); _inputHandler = new InputHandler("Centarea HID"); if (!_inputHandler.IsLoaded) { Log.Error("Centarea: Error loading default mapping file - please reinstall MediaPortal"); DeInit(); return; } else { Log.Info("Centarea: Centarea HID mapping loaded successfully"); _remoteActive = true; } }
private void LoadSettings() { using (Settings xmlreader = new MPSettings()) { int volumeStyle = xmlreader.GetValueAsInt("volume", "handler", 1); bool isDigital = xmlreader.GetValueAsBool("volume", "digital", true); btnClassic.Selected = volumeStyle == 0; btnWinXP.Selected = volumeStyle == 1; btnLogarithmic.Selected= volumeStyle == 2; btnCustom.Selected = volumeStyle == 3; btnVistaWin7.Selected = volumeStyle == 4; _customVolume = xmlreader.GetValueAsString("volume", "table", "0, 4095, 8191, 12287, 16383, 20479, 24575, 28671, 32767, 36863, 40959, 45055, 49151, 53247, 57343, 61439, 65535"); // When Upmixing has selected, we need to use Wave Volume _useMixing = xmlreader.GetValueAsBool("audioplayer", "mixing", false); if (_useMixing) { isDigital = true; } btnMasterVolume.Selected = !isDigital; btnWave.Selected = isDigital; btnEnableOSDVolume.Selected = xmlreader.GetValueAsBool("volume", "defaultVolumeOSD", true); } }
public Auto3DSequenceManager() { InitializeComponent(); using (Settings reader = new MPSettings()) { checkBoxSendOnAdd.Checked = reader.GetValueAsBool("Auto3DPluginSequenceManager", "SendCommandOnAdd", true); } listBox2D3D.ItemHeight = 19; listBox2D3DSBS.ItemHeight = 19; listBox2D3DTAB.ItemHeight = 19; listBox3D2D.ItemHeight = 19; listBox3DSBS2D.ItemHeight = 19; listBox3DTAB2D.ItemHeight = 19; listBox2D3D.DrawItem += listBox_DrawItem; listBox2D3DSBS.DrawItem += listBox_DrawItem; listBox2D3DTAB.DrawItem += listBox_DrawItem; listBox3D2D.DrawItem += listBox_DrawItem; listBox3DSBS2D.DrawItem += listBox_DrawItem; listBox3DTAB2D.DrawItem += listBox_DrawItem; CenterToParent(); }
private void LoadSettings() { using (Profile.Settings xmlreader = new MPSettings()) { // Music string playListFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal); playListFolder += @"\My Playlists"; _musicPlayListFolder = xmlreader.GetValueAsString("music", "playlists", playListFolder); if (string.Compare(_musicPlayListFolder, playListFolder) == 0) { if (Directory.Exists(playListFolder) == false) { try { Directory.CreateDirectory(playListFolder); } catch (Exception) { } } } btnMusicrepeatplaylist.Selected = xmlreader.GetValueAsBool("musicfiles", "repeat", false); btnMusicautoshuffle.Selected = xmlreader.GetValueAsBool("musicfiles", "autoshuffle", false); btnMusicsavecurrentasdefault.Selected = xmlreader.GetValueAsBool("musicfiles", "savePlaylistOnExit", true); btnMusicloaddefault.Selected = xmlreader.GetValueAsBool("musicfiles", "resumePlaylistOnMusicEnter", true); btnMusicplaylistscreen.Selected= xmlreader.GetValueAsBool("musicfiles", "playlistIsCurrent", true); // Videos _videosPlayListFolder = xmlreader.GetValueAsString("movies", "playlists", playListFolder); btnVideosrepeatplaylist.Selected = xmlreader.GetValueAsBool("movies", "repeat", true); } }
internal static double MatchConfiguredFPS(double probedFps) { if (fpsList == null) { fpsList = new List<double>(); NumberFormatInfo provider = new NumberFormatInfo() { NumberDecimalSeparator = "." }; Settings xmlreader = new MPSettings(); for (int i = 1; i < 100; i++) { string name = xmlreader.GetValueAsString("general", "refreshrate0" + Convert.ToString(i) + "_name", ""); if (string.IsNullOrEmpty(name)) continue; string fps = xmlreader.GetValueAsString("general", name + "_fps", ""); string[] fpsArray = fps.Split(';'); foreach (string fpsItem in fpsArray) { double fpsAsDouble = -1; double.TryParse(fpsItem, NumberStyles.AllowDecimalPoint, provider, out fpsAsDouble); if (fpsAsDouble > -1) fpsList.Add(fpsAsDouble); } } fpsList = fpsList.Distinct().ToList(); fpsList.Sort(); } if (fpsList != null && fpsList.Count > 0) { return fpsList.FirstOrDefault(f => Math.Abs(f - probedFps) < 0.24f); } return default(double); }
public override void LoadSettings() { if (_init == false) { return; } using (Settings xmlreader = new MPSettings()) { cbAllowNormal.Checked = xmlreader.GetValueAsBool("bdplayer", "allowarnormal", true); cbAllowOriginal.Checked = xmlreader.GetValueAsBool("bdplayer", "allowaroriginal", true); cbAllowZoom.Checked = xmlreader.GetValueAsBool("bdplayer", "allowarzoom", true); cbAllowZoom149.Checked = xmlreader.GetValueAsBool("bdplayer", "allowarzoom149", true); cbAllowStretch.Checked = xmlreader.GetValueAsBool("bdplayer", "allowarstretch", true); cbAllowNonLinearStretch.Checked = xmlreader.GetValueAsBool("bdplayer", "allowarnonlinear", true); cbAllowLetterbox.Checked = xmlreader.GetValueAsBool("bdplayer", "allowarletterbox", true); // // Set default aspect ratio // string defaultAspectRatio = xmlreader.GetValueAsString("movieplayer", "defaultar", defaultZoomModeComboBox.Items[0].ToString()); foreach (Geometry.Type item in Enum.GetValues(typeof (Geometry.Type))) { string currentAspectRatio = Util.Utils.GetAspectRatio(item); if (defaultAspectRatio == currentAspectRatio) { defaultZoomModeComboBox.SelectedItem = currentAspectRatio; break; } } } }
public override void LoadSettings() { using (Settings xmlreader = new MPSettings()) { // Get hostname entry _settingsHostname = xmlreader.GetValueAsString("tvservice", "hostname", string.Empty); if (string.IsNullOrEmpty(_settingsHostname)) { // Set hostname to local host mpTextBoxHostname.Text = Dns.GetHostName(); _verifiedHostname = string.Empty; Log.Debug("LoadSettings: set hostname to local host: \"{0}\"", mpTextBoxHostname.Text); } else { // Take verified hostname from MediaPortal.xml mpTextBoxHostname.Text = _settingsHostname; _verifiedHostname = mpTextBoxHostname.Text; mpTextBoxHostname.BackColor = Color.YellowGreen; Log.Debug("LoadSettings: take hostname from settings: \"{0}\"", mpTextBoxHostname.Text); } mpCheckBoxIsWakeOnLanEnabled.Checked = xmlreader.GetValueAsBool("tvservice", "isWakeOnLanEnabled", false); mpNumericTextBoxWOLTimeOut.Text = xmlreader.GetValueAsString("tvservice", "WOLTimeOut", "10"); mpCheckBoxIsAutoMacAddressEnabled.Checked = xmlreader.GetValueAsBool("tvservice", "isAutoMacAddressEnabled", true); mpTextBoxMacAddress.Text = xmlreader.GetValueAsString("tvservice", "macAddress", "00:00:00:00:00:00"); mpCheckBoxIsWakeOnLanEnabled_CheckedChanged(null, null); } }
public VolumeHandler(int[] volumeTable) { bool isDigital; using (Settings reader = new MPSettings()) { int levelStyle = reader.GetValueAsInt("volume", "startupstyle", 0); if (levelStyle == 0) { _startupVolume = Math.Max(0, Math.Min(65535, reader.GetValueAsInt("volume", "lastknown", 52428))); } if (levelStyle == 1) { } if (levelStyle == 2) { _startupVolume = Math.Max(0, Math.Min(65535, reader.GetValueAsInt("volume", "startuplevel", 52428))); } isDigital = reader.GetValueAsBool("volume", "digital", false); _showVolumeOSD = reader.GetValueAsBool("volume", "defaultVolumeOSD", true); } _mixer = new Mixer.Mixer(); _mixer.Open(0, isDigital); _volumeTable = volumeTable; _mixer.ControlChanged += mixer_ControlChanged; }
public override void LoadSettings() { int windowid = 0; using (Settings xmlreader = new MPSettings()) { checkBoxEnableScreensaver.Checked = xmlreader.GetValueAsBool("general", "IdleTimer", true); numericUpDownDelay.Value = xmlreader.GetValueAsInt("general", "IdleTimeValue", 300); radioBtnBlankScreen.Checked = xmlreader.GetValueAsBool("general", "IdleBlanking", false); radioButtonLoadPlugin.Checked = xmlreader.GetValueAsBool("general", "IdlePlugin", false); windowid = xmlreader.GetValueAsInt("general", "IdlePluginWindow", 0); } pluginsComboBox.DataSource = loadedPlugins; pluginsComboBox.DisplayMember = "PluginName"; pluginsComboBox.ValueMember = "PluginName"; if (windowid != 0) { for (int i = 0; i < loadedPlugins.Count; i++) { ItemTag t = loadedPlugins[i]; if (t.WindowId == windowid) { pluginsComboBox.SelectedIndex = i; break; } } } }
private void SaveSettings() { using (Settings xmlreader = new MPSettings()) { xmlreader.SetValue("tvservice", "hostname", _hostName); } }
public TvNotifyManager() { using (Settings xmlreader = new MPSettings()) { _enableRecNotification = xmlreader.GetValueAsBool("mytv", "enableRecNotifier", false); _preNotifyConfig = xmlreader.GetValueAsInt("mytv", "notifyTVBefore", 300); } _busy = false; _timer = new Timer(); _timer.Stop(); // check every 15 seconds for notifies _dummyuser = new User(); _dummyuser.IsAdmin = false; _dummyuser.Name = "Free channel checker"; _timer.Interval = 15000; _timer.Enabled = true; // Execute TvNotifyManager in a separate thread, so that it doesn't block the Main UI Render thread when Tvservice connection died new Thread(() => { _timer.Tick += new EventHandler(_timer_Tick); } ) {Name = "TvNotifyManager"}.Start(); _notifiedRecordings = new ArrayList(); }
protected override void OnPageLoad() { base.OnPageLoad(); //Load settings Log.Info("GUISkipSteps: {0}", "Load settings"); string regValue = string.Empty; using (Settings xmlreader = new MPSettings()) { try { regValue = xmlreader.GetValueAsString("movieplayer", "skipsteps", DEFAULT_SETTING); if (regValue == string.Empty) // config after wizard run 1st { regValue = DEFAULT_SETTING; Log.Info("GeneralSkipSteps - creating new Skip-Settings {0}", ""); } else if (OldStyle(regValue)) { regValue = ConvertToNewStyle(regValue); } labelCurrent.Label = regValue; } catch (Exception ex) { Log.Info("GeneralSkipSteps - Exception while loading Skip-Settings: {0}", ex.ToString()); } } SetCheckMarksBasedOnString(regValue); GUIControl.FocusControl(GetID, checkMarkButtonStep1.GetID); }
public override void LoadSettings() { using (Settings xmlreader = new MPSettings()) { try { defaultSubtitleLanguageComboBox.SelectedItem = xmlreader.GetValueAsString("bdplayer", "subtitlelanguage", m_strDefaultSubtitleLanguageISO); } catch (Exception ex) { CultureInfo ci = new CultureInfo(m_strDefaultSubtitleLanguageISO); Log.Error("LoadSettings - failed to load default subtitle language, using {0} - {1} ", ci.EnglishName, ex); defaultSubtitleLanguageComboBox.SelectedItem = ci.EnglishName; } //Use Internel Menu useBDInternalMenu.Checked = xmlreader.GetValueAsBool("bdplayer", "useInternalBDMenu", false); try { defaultAudioLanguageComboBox.SelectedItem=xmlreader.GetValueAsString("bdplayer", "audiolanguage", m_strDefaultAudioLanguageISO); } catch (Exception ex) { CultureInfo ci = new CultureInfo(m_strDefaultAudioLanguageISO); Log.Error("LoadSettings - failed to load default audio language, using {0} - {1} ", ci.EnglishName, ex); defaultAudioLanguageComboBox.SelectedItem = ci.EnglishName; } } }
private void Init() { using (Settings xmlreader = new MPSettings()) { controlEnabled = xmlreader.GetValueAsBool("remote", "AppCommand", false); controlEnabledGlobally = xmlreader.GetValueAsBool("remote", "AppCommandBackground", false); logVerbose = xmlreader.GetValueAsBool("remote", "AppCommandVerbose", false); } if (controlEnabled) { _inputHandler = new InputHandler("AppCommand"); if (!_inputHandler.IsLoaded) { controlEnabled = false; Log.Info("AppCommand: Error loading default mapping file - please reinstall MediaPortal"); } } if (controlEnabledGlobally) { _keyboardHook = new KeyboardHook(); _keyboardHook.KeyDown += new KeyEventHandler(OnKeyDown); _keyboardHook.IsEnabled = true; } }
public override void LoadSettings() { //Load parameters from XML File string preferredAudioLanguages; string preferredSubLanguages; using (Settings xmlreader = new MPSettings()) { cbTurnOnTv.Checked = xmlreader.GetValueAsBool("mytv", "autoturnontv", false); cbAutoFullscreen.Checked = xmlreader.GetValueAsBool("mytv", "autofullscreen", false); byIndexCheckBox.Checked = xmlreader.GetValueAsBool("mytv", "byindex", true); showChannelNumberCheckBox.Checked = xmlreader.GetValueAsBool("mytv", "showchannelnumber", false); int channelNumberMaxLen = xmlreader.GetValueAsInt("mytv", "channelnumbermaxlength", 3); channelNumberMaxLengthNumUpDn.Value = channelNumberMaxLen; int DeInterlaceMode = xmlreader.GetValueAsInt("mytv", "deinterlace", 0); if (DeInterlaceMode < 0 || DeInterlaceMode > 3) { DeInterlaceMode = 3; } cbDeinterlace.SelectedIndex = DeInterlaceMode; mpCheckBoxPrefAC3.Checked = xmlreader.GetValueAsBool("tvservice", "preferac3", false); mpCheckBoxPrefAudioOverLang.Checked = xmlreader.GetValueAsBool("tvservice", "preferAudioTypeOverLang", true); preferredAudioLanguages = xmlreader.GetValueAsString("tvservice", "preferredaudiolanguages", ""); preferredSubLanguages = xmlreader.GetValueAsString("tvservice", "preferredsublanguages", ""); mpCheckBoxEnableDVBSub.Checked = xmlreader.GetValueAsBool("tvservice", "dvbbitmapsubtitles", false); mpCheckBoxEnableTTXTSub.Checked = xmlreader.GetValueAsBool("tvservice", "dvbttxtsubtitles", false); mpCheckBoxEnableCCSub.Checked = xmlreader.GetValueAsBool("tvservice", "ccsubtitles", false); mpCheckBoxAutoShowSubWhenTvStarts.Checked = xmlreader.GetValueAsBool("tvservice", "autoshowsubwhentvstarts", true); enableAudioDualMonoModes.Checked = xmlreader.GetValueAsBool("tvservice", "audiodualmono", false); cbHideAllChannels.Checked = xmlreader.GetValueAsBool("mytv", "hideAllChannelsGroup", false); cbShowChannelStateIcons.Checked = xmlreader.GetValueAsBool("mytv", "showChannelStateIcons", true); cbContinuousScrollGuide.Checked = xmlreader.GetValueAsBool("mytv", "continuousScrollGuide", false); cbRelaxTsReader.Checked = xmlreader.GetValueAsBool("mytv", "relaxTsReader", false); chkRecnotifications.Checked = xmlreader.GetValueAsBool("mytv", "enableRecNotifier", false); txtNotifyBefore.Text = xmlreader.GetValueAsString("mytv", "notifyTVBefore", "300"); txtNotifyAfter.Text = xmlreader.GetValueAsString("mytv", "notifyTVTimeout", "15"); checkBoxNotifyPlaySound.Checked = xmlreader.GetValueAsBool("mytv", "notifybeep", true); cbConfirmTimeshiftStop.Checked = xmlreader.GetValueAsBool("mytv", "confirmTimeshiftStop", true); int showEpisodeinfo = xmlreader.GetValueAsInt("mytv", "showEpisodeInfo", 0); if (showEpisodeinfo > this.ShowEpisodeOptions.Length) { showEpisodeinfo = 0; } comboboxShowEpisodeInfo.SelectedIndex = showEpisodeinfo; } // Enable this Panel if the TvPlugin exists in the plug-in Directory Enabled = true; // Retrieve the languages and language codes for the Epg. List<KeyValuePair<String, String>> langs = TvLibrary.Epg.Languages.Instance.GetLanguagePairs(); FillLists(mpListViewAvailAudioLang, mpListViewPreferredAudioLang, preferredAudioLanguages, langs); FillLists(mpListViewAvailSubLang, mpListViewPreferredSubLang, preferredSubLanguages, langs); _SingleSeat = Network.IsSingleSeat(); }
private void SaveSettings() { using (Profile.Settings xmlwriter = new MPSettings()) { xmlwriter.SetValue("mpsettings", "pin", Util.Utils.EncryptPin(_pin)); } }
public override void LoadSettings() { if (_serialPort != null && _serialPort.IsOpen) _serialPort.Close(); using (Settings reader = new MPSettings()) { DeviceModelName = reader.GetValueAsString("Auto3DPlugin", "EpsonModel", "Default"); PortName = reader.GetValueAsString("Auto3DPlugin", "EpsonPort", "None"); } if (_serialPort != null) { _serialPort.PortName = PortName; try { if (_serialPort.PortName != "None") _serialPort.Open(); } catch (Exception ex) { Auto3DHelpers.ShowAuto3DMessage("Opening serial port failed: " + ex.Message, false, 0); Log.Info("Auto3D: " + ex.Message); } } }
public Log4netLogger() { string logPath = Config.GetFolder(Config.Dir.Log); using (Settings xmlreader = new MPSettings()) { _minLevel = (Level)Enum.Parse(typeof(Level), xmlreader.GetValueAsString("general", "loglevel", "2")); } _configuration = false; string appPath = Path.GetDirectoryName(Application.ExecutablePath); XmlDocument xmlDoc = new XmlDocument(); FileStream fs = new FileStream(Path.Combine(appPath, "log4net.config"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite); xmlDoc.Load(fs); fs.Close(); XmlNodeList nodeList = xmlDoc.SelectNodes("configuration/log4net/appender/file"); foreach (XmlNode node in nodeList) { if (node.Attributes != null) { foreach (XmlAttribute attribute in node.Attributes) { if (attribute.Name.Equals("value")) { attribute.Value = Path.Combine(logPath, Path.GetFileName(attribute.Value)); break; } } } } MemoryStream mStream = new MemoryStream(); xmlDoc.Save(mStream); mStream.Seek(0, SeekOrigin.Begin); log4net.Config.XmlConfigurator.Configure(mStream); }
private void LoadSettings() { using (Settings xmlreader = new MPSettings()) { _hostName = xmlreader.GetValueAsString("tvservice", "hostname", ""); } }
internal static bool IsPluginEnabled(string name) { using (Settings xmlreader = new MPSettings()) { return xmlreader.GetValueAsBool("plugins", name, false); } }
public override void DoModal(int dwParentId) { int nagCount; using (Settings xmlreader = new MPSettings()) { nagCount = xmlreader.GetValueAsInt("general", "skinobsoletecount", 0); } //if (chkIgnore != null) //{ chkIgnore.Visible = nagCount > 4; //} GUIPropertyManager.SetProperty("#userskin", _userSkin); _timeLeft = 0; timeStart = DateTime.Now; UpdateCountDown(0); base.DoModal(dwParentId); GUIPropertyManager.SetProperty("#userskin", ""); GUIPropertyManager.SetProperty("#countdownseconds", ""); if (RevertToUserSkin) { nagCount++; } using (Settings xmlwriter = new MPSettings()) { xmlwriter.SetValueAsBool("general", "dontshowskinversion", chkIgnore.Selected); xmlwriter.SetValue("general", "skinobsoletecount", nagCount); } }
public override void LoadSettings() { base.LoadSettings(); if (_init == false) { using (Settings xmlreader = new MPSettings()) { //VMR9 settings checkboxMpNonsquare.Checked = xmlreader.GetValueAsBool("general", "nonsquare", true); // http://msdn2.microsoft.com/en-us/library/ms787438(VS.85).aspx checkboxDXEclusive.Checked = xmlreader.GetValueAsBool("general", "exclusivemode", true); mpVMR9FilterMethod.Text = xmlreader.GetValueAsString("general", "dx9filteringmode", "Gaussian Quad Filtering"); // http://msdn2.microsoft.com/en-us/library/ms788066.aspx checkBoxVMRWebStreams.Checked = xmlreader.GetValueAsBool("general", "usevrm9forwebstreams", true); checkBoxDecimateMask.Checked = xmlreader.GetValueAsBool("general", "dx9decimatemask", false); // http://msdn2.microsoft.com/en-us/library/ms787452(VS.85).aspx bool ValueEVR = false; try { //EVR - VMR9 selection ValueEVR = OSInfo.OSInfo.VistaOrLater() ? true : false; } catch (Exception ex) { Log.Error("FilterVideoRendererConfig: Os detection unsuccessful - {0}", ex.Message); } radioButtonEVR.Checked = xmlreader.GetValueAsBool("general", "useEVRenderer", ValueEVR); } _init = true; } }
public LastFMConfig() { InitializeComponent(); using (var xmlreader = new MPSettings()) { chkAutoDJ.Checked = xmlreader.GetValueAsBool("lastfm:test", "autoDJ", true); numRandomness.Value = xmlreader.GetValueAsInt("lastfm:test", "randomness", 100); chkAnnounce.Checked = xmlreader.GetValueAsBool("lastfm:test", "announce", true); chkScrobble.Checked = xmlreader.GetValueAsBool("lastfm:test", "scrobble", true); chkDiferentVersions.Checked = xmlreader.GetValueAsBool("lastfm:test", "allowDiffVersions", true); } if (string.IsNullOrEmpty(MusicDatabase.Instance.GetLastFMSK())) return; LastFMUser user; try { user = LastFMLibrary.GetUserInfo(MusicDatabase.Instance.GetLastFMUser()); } catch (Exception ex) { Log.Error("Error getting user info for: {0}", MusicDatabase.Instance.GetLastFMUser()); Log.Error(ex); return; } if (user == null || string.IsNullOrEmpty(user.UserImgURL)) return; pbLastFMUser.ImageLocation = user.UserImgURL; }
private void Init() { try { _deviceClass = HidGuid; _doubleClickTime = GetDoubleClickTime(); _deviceBuffer = new byte[256]; _deviceWatcher = new DeviceWatcher(); _deviceWatcher.Create(); _deviceWatcher.Class = _deviceClass; _deviceWatcher.DeviceArrival += new DeviceEventHandler(OnDeviceArrival); _deviceWatcher.DeviceRemoval += new DeviceEventHandler(OnDeviceRemoval); _deviceWatcher.SettingsChanged += new SettingsChanged(OnSettingsChanged); _deviceWatcher.RegisterDeviceArrival(); // Read if we use Master or Wave volume using (Settings reader = new MPSettings()) { isDigital = reader.GetValueAsBool("volume", "digital", false); } Open(); } catch (Exception e) { Log.Info("Remote.Init: {0}", e.Message); } }
public override void LoadSettings() { using (Settings xmlreader = new MPSettings()) { pixelRatioCheckBox.Checked = xmlreader.GetValueAsBool("dvdplayer", "pixelratiocorrection", false); aspectRatioComboBox.Text = xmlreader.GetValueAsString("dvdplayer", "armode", "Follow stream"); displayModeComboBox.Text = xmlreader.GetValueAsString("dvdplayer", "displaymode", "Default"); // // Load all available aspect ratio // defaultZoomModeComboBox.Items.Clear(); foreach (Geometry.Type item in Enum.GetValues(typeof (Geometry.Type))) { defaultZoomModeComboBox.Items.Add(Util.Utils.GetAspectRatio(item)); } // // Set default aspect ratio // string defaultAspectRatio = xmlreader.GetValueAsString("dvdplayer", "defaultar", defaultZoomModeComboBox.Items[0].ToString()); foreach (Geometry.Type item in Enum.GetValues(typeof (Geometry.Type))) { string currentAspectRatio = Util.Utils.GetAspectRatio(item); if (defaultAspectRatio == currentAspectRatio) { defaultZoomModeComboBox.SelectedItem = currentAspectRatio; break; } } } }
public void ReLoad() { //System.Diagnostics.Debugger.Launch(); try { bool connectionValid = SetupDatabaseConnection(); if (connectionValid) { Log.Info("get channels from database"); SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof(Channel)); sb.AddConstraint(Operator.Equals, "isTv", 1); sb.AddOrderByField(true, "sortOrder"); SqlStatement stmt = sb.GetStatement(true); channels = ObjectFactory.GetCollection(typeof(Channel), stmt.Execute()); Log.Info("found:{0} tv channels", channels.Count); TvNotifyManager.OnNotifiesChanged(); m_groups.Clear(); TvBusinessLayer layer = new TvBusinessLayer(); RadioChannelGroup allRadioChannelsGroup = layer.GetRadioChannelGroupByName(TvConstants.RadioGroupNames.AllChannels); IList <Channel> radioChannels = layer.GetAllRadioChannels(); if (radioChannels != null) { if (radioChannels.Count > allRadioChannelsGroup.ReferringRadioGroupMap().Count) { foreach (Channel radioChannel in radioChannels) { layer.AddChannelToRadioGroup(radioChannel, allRadioChannelsGroup); } } } Log.Info("Done."); Log.Info("get all groups from database"); sb = new SqlBuilder(StatementType.Select, typeof(ChannelGroup)); sb.AddOrderByField(true, "groupName"); stmt = sb.GetStatement(true); IList <ChannelGroup> groups = ObjectFactory.GetCollection <ChannelGroup>(stmt.Execute()); IList <GroupMap> allgroupMaps = GroupMap.ListAll(); bool hideAllChannelsGroup = false; using ( Settings xmlreader = new MPSettings()) { hideAllChannelsGroup = xmlreader.GetValueAsBool("mytv", "hideAllChannelsGroup", false); } foreach (ChannelGroup group in groups) { if (group.GroupName == TvConstants.TvGroupNames.AllChannels) { foreach (Channel channel in channels) { if (channel.IsTv == false) { continue; } bool groupContainsChannel = false; foreach (GroupMap map in allgroupMaps) { if (map.IdGroup != group.IdGroup) { continue; } if (map.IdChannel == channel.IdChannel) { groupContainsChannel = true; break; } } if (!groupContainsChannel) { layer.AddChannelToGroup(channel, TvConstants.TvGroupNames.AllChannels); } } break; } } groups = ChannelGroup.ListAll(); foreach (ChannelGroup group in groups) { //group.GroupMaps.ApplySort(new GroupMap.Comparer(), false); if (hideAllChannelsGroup && group.GroupName.Equals(TvConstants.TvGroupNames.AllChannels) && groups.Count > 1) { continue; } m_groups.Add(group); } Log.Info("loaded {0} tv groups", m_groups.Count); //TVHome.Connected = true; } } catch (Exception ex) { Log.Error("TVHome: Error in Reload"); Log.Error(ex); //TVHome.Connected = false; } }
/// <summary> /// Do we have all required fields filled /// </summary> /// <returns></returns> private bool AllFilledIn() { int MaximumShares = 250; //Do we have 1 or more music,picture,video shares? using (Settings xmlreader = new MPSettings()) { string playlistFolder = xmlreader.GetValueAsString("music", "playlists", ""); if (playlistFolder == string.Empty) { MessageBox.Show("No music playlist folder specified", "MediaPortal Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } playlistFolder = xmlreader.GetValueAsString("movies", "playlists", ""); if (playlistFolder == string.Empty) { MessageBox.Show("No video playlist folder specified", "MediaPortal Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } bool added = false; for (int index = 0; index < MaximumShares; index++) { string sharePath = String.Format("sharepath{0}", index); string sharePathData = xmlreader.GetValueAsString("music", sharePath, ""); if (!Util.Utils.IsDVD(sharePathData) && sharePathData != string.Empty) { added = true; break; } } if (!added) { MessageBox.Show("No music folders specified", "MediaPortal Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } added = false; for (int index = 0; index < MaximumShares; index++) { string sharePath = String.Format("sharepath{0}", index); string shareNameData = xmlreader.GetValueAsString("movies", sharePath, ""); if (!Util.Utils.IsDVD(shareNameData) && shareNameData != string.Empty) { added = true; break; } } if (!added) { MessageBox.Show("No video folders specified", "MediaPortal Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } added = false; for (int index = 0; index < MaximumShares; index++) { string sharePath = String.Format("sharepath{0}", index); string shareNameData = xmlreader.GetValueAsString("pictures", sharePath, ""); if (!Util.Utils.IsDVD(shareNameData) && shareNameData != string.Empty) { added = true; break; } } if (!added) { MessageBox.Show("No pictures folders specified", "MediaPortal Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } // Check hostname for tv server (empty hostname is invalid) if (UseTvServer) { string hostName = xmlreader.GetValueAsString("tvservice", "hostname", ""); if (string.IsNullOrEmpty(hostName)) { // Show message box DialogResult result = MessageBox.Show("There is a problem with the hostname specified in the \"TV/Radio\" section. " + "It will not be saved." + Environment.NewLine + Environment.NewLine + "Do you want to review it before exiting?", "MediaPortal Settings", MessageBoxButtons.YesNo, MessageBoxIcon.Question); // If user wants to review hostname select "TV/Radio" section and return false if (result == DialogResult.Yes) { // Loop through the tree to find the "TV/Radio" node and select it foreach (TreeNode parentNode in sectionTree.Nodes) { if (parentNode.Text == "TV/Radio") { sectionTree.SelectedNode = parentNode; parentNode.EnsureVisible(); return(false); } } return(false); } } } } return(true); }
private void OnStartup() { // start the splashscreen string version = ConfigurationManager.AppSettings["version"]; splashScreen.Version = version; splashScreen.Run(); Log.Info("SettingsForm constructor"); // Required for Windows Form Designer support InitializeComponent(); this.linkLabel1.Links.Add(0, linkLabel1.Text.Length, "http://www.team-mediaportal.com/donate.html"); // Build options tree if (splashScreen != null) { splashScreen.SetInformation("Loading language..."); } string strLanguage; using (Settings xmlreader = new MPSettings()) { strLanguage = xmlreader.GetValueAsString("gui", "language", "English"); hintShowCount = xmlreader.GetValueAsInt("general", "ConfigModeHintCount", 0); if (splashScreen != null) { splashScreen.SetInformation("Loading config options..."); } CheckModeHintDisplay(hintShowCount); // The initial hint allows to choose a mode so we need to ask before loading that setting advancedMode = xmlreader.GetValueAsBool("general", "AdvancedConfigMode", false); } toolStripButtonSwitchAdvanced.Text = AdvancedMode ? "Switch to standard mode" : "Switch to expert mode"; toolStripButtonSwitchAdvanced.Checked = AdvancedMode; GUILocalizeStrings.Load(strLanguage); // Register Bass.Net BassRegistration.BassRegistration.Register(); Log.Info("add project section"); if (splashScreen != null) { splashScreen.SetInformation("Adding project section..."); } Project project = new Project(); AddSection(new ConfigPage(null, project, false)); AddTabGeneral(); AddTabGui(); AddTabMovies(); AddTabBD(); AddTabDvd(); AddTabTelevision(); AddTabMusic(); AddTabPictures(); AddTabRemote(); AddTabFilters(); AddTabPlugins(); AddTabThirdPartyChecks(); // reset the last used state ToggleSectionVisibility(advancedMode); // Select first item in the section tree if (sectionTree.Nodes.Count > 0) { sectionTree.SelectedNode = sectionTree.Nodes[0]; } if (splashScreen != null) { splashScreen.Stop(1000); splashScreen = null; BackgroundWorker FrontWorker = new BackgroundWorker(); FrontWorker.DoWork += new DoWorkEventHandler(Worker_BringConfigToForeground); FrontWorker.RunWorkerAsync(); } Log.Info("settingsform constructor done"); GUIGraphicsContext.Skin = Config.GetFile(Config.Dir.Skin, "Default", string.Empty); Log.Info("SKIN : " + GUIGraphicsContext.Skin); }
/// <summary> /// Loads weather settings from MediaPortal.xml /// </summary> public override void LoadSettings() { using (Settings xmlreader = new MPSettings()) { int loadWind = xmlreader.GetValueAsInt("weather", "speed", 4); switch (loadWind) { case 0: selectedWindUnit = WindUnit.Kmh; windSpeedComboBox.Text = "kilometers / hour"; break; case 1: selectedWindUnit = WindUnit.mph; windSpeedComboBox.Text = "miles / hour"; break; case 2: selectedWindUnit = WindUnit.ms; windSpeedComboBox.Text = "meters / second"; break; case 3: selectedWindUnit = WindUnit.Kn; windSpeedComboBox.Text = "Knots"; break; case 4: selectedWindUnit = WindUnit.Bft; windSpeedComboBox.Text = "Beaufort"; break; default: selectedWindUnit = WindUnit.Bft; windSpeedComboBox.Text = "Beaufort"; break; } // Get temperature measurement type string temperature = xmlreader.GetValueAsString("weather", "temperature", "C"); if (temperature.Equals("C")) { temperatureComboBox.Text = "Celsius"; } else if (temperature.Equals("F")) { temperatureComboBox.Text = "Fahrenheit"; } // Get refresh interval setting intervalTextBox.Text = Convert.ToString(xmlreader.GetValueAsInt("weather", "refresh", 60)); // Get number of cities and city information for (int index = 0; index < MaximumCities; index++) { string cityName = String.Format("city{0}", index); string cityCode = String.Format("code{0}", index); string citySat = String.Format("sat{0}", index); string cityTemp = String.Format("temp{0}", index); string cityUV = String.Format("uv{0}", index); string cityWinds = String.Format("winds{0}", index); string cityHumid = String.Format("humid{0}", index); string cityPrecip = String.Format("precip{0}", index); //Read city information from index string cityNameData = xmlreader.GetValueAsString("weather", cityName, ""); string cityCodeData = xmlreader.GetValueAsString("weather", cityCode, ""); string citySatData = xmlreader.GetValueAsString("weather", citySat, ""); string cityTempData = xmlreader.GetValueAsString("weather", cityTemp, ""); string cityUVData = xmlreader.GetValueAsString("weather", cityUV, ""); string cityWindsData = xmlreader.GetValueAsString("weather", cityWinds, ""); string cityHumidData = xmlreader.GetValueAsString("weather", cityHumid, ""); string cityPrecipData = xmlreader.GetValueAsString("weather", cityPrecip, ""); if (cityNameData.Length > 0 && cityCodeData.Length > 0) { citiesListView.Items.Add( new ListViewItem(new string[] { cityNameData, cityCodeData, citySatData, cityTempData, cityUVData, cityWindsData, cityHumidData, cityPrecipData })); } } } }
public override void SaveSettings() { using (Settings xmlwriter = new MPSettings()) { if (windSpeedComboBox.Text.Equals("kilometers / hour")) { selectedWindUnit = WindUnit.Kmh; } else if (windSpeedComboBox.Text.Equals("miles / hour")) { selectedWindUnit = WindUnit.mph; } else if (windSpeedComboBox.Text.Equals("meters / second")) { selectedWindUnit = WindUnit.ms; } else if (windSpeedComboBox.Text.Equals("Knots")) { selectedWindUnit = WindUnit.Kn; } else if (windSpeedComboBox.Text.Equals("Beaufort")) { selectedWindUnit = WindUnit.Bft; } // Write the speed units xmlwriter.SetValue("weather", "speed", (int)selectedWindUnit); // Define the temperature measurement string temperature = string.Empty; if (temperatureComboBox.Text.Equals("Celsius")) { temperature = "C"; } else if (temperatureComboBox.Text.Equals("Fahrenheit")) { temperature = "F"; } xmlwriter.SetValue("weather", "temperature", temperature); // Define the interval time between weather updates xmlwriter.SetValue("weather", "refresh", intervalTextBox.Text); // Save city information for (int index = 0; index < MaximumCities; index++) { string cityName = String.Format("city{0}", index); string cityCode = String.Format("code{0}", index); string citySat = String.Format("sat{0}", index); string cityTemp = String.Format("temp{0}", index); string cityUV = String.Format("uv{0}", index); string cityWinds = String.Format("winds{0}", index); string cityHumid = String.Format("humid{0}", index); string cityPrecip = String.Format("precip{0}", index); string cityNameData = string.Empty; string cityCodeData = string.Empty; string citySatData = string.Empty; string cityTempData = string.Empty; string cityUVData = string.Empty; string cityWindsData = string.Empty; string cityHumidData = string.Empty; string cityPrecipData = string.Empty; if (citiesListView.Items != null && citiesListView.Items.Count > index) { cityNameData = citiesListView.Items[index].SubItems[0].Text; cityCodeData = citiesListView.Items[index].SubItems[1].Text; citySatData = citiesListView.Items[index].SubItems[2].Text; cityTempData = citiesListView.Items[index].SubItems[3].Text; cityUVData = citiesListView.Items[index].SubItems[4].Text; cityWindsData = citiesListView.Items[index].SubItems[5].Text; cityHumidData = citiesListView.Items[index].SubItems[6].Text; cityPrecipData = citiesListView.Items[index].SubItems[7].Text; } xmlwriter.SetValue("weather", cityName, cityNameData); xmlwriter.SetValue("weather", cityCode, cityCodeData); xmlwriter.SetValue("weather", citySat, citySatData); xmlwriter.SetValue("weather", cityTemp, cityTempData); xmlwriter.SetValue("weather", cityUV, cityUVData); xmlwriter.SetValue("weather", cityWinds, cityWindsData); xmlwriter.SetValue("weather", cityHumid, cityHumidData); xmlwriter.SetValue("weather", cityPrecip, cityPrecipData); } } }
/// <summary> /// Loads the movie player settings /// </summary> public override void LoadSettings() { if (!_init) { return; } using (Settings xmlreader = new MPSettings()) { autoDecoderSettings.Checked = xmlreader.GetValueAsBool("movieplayer", "autodecodersettings", false); ForceSourceSplitter.Checked = xmlreader.GetValueAsBool("movieplayer", "forcesourcesplitter", false); mpCheckBoxTS.Checked = xmlreader.GetValueAsBool("movieplayer", "usemoviecodects", false); UpdateDecoderSettings(); audioRendererComboBox.SelectedItem = xmlreader.GetValueAsString("movieplayer", "audiorenderer", "Default DirectSound Device"); // Set Source Splitter check for first init to true. string CheckSourceSplitter = xmlreader.GetValueAsString("movieplayer", "forcesourcesplitter", ""); // Set codecs string videoCodec = xmlreader.GetValueAsString("movieplayer", "mpeg2videocodec", ""); string h264videoCodec = xmlreader.GetValueAsString("movieplayer", "h264videocodec", ""); string vc1ivideoCodec = xmlreader.GetValueAsString("movieplayer", "vc1ivideocodec", ""); string vc1videoCodec = xmlreader.GetValueAsString("movieplayer", "vc1videocodec", ""); string xvidvideoCodec = xmlreader.GetValueAsString("movieplayer", "xvidvideocodec", ""); string audioCodec = xmlreader.GetValueAsString("movieplayer", "mpeg2audiocodec", ""); string aacaudioCodec = xmlreader.GetValueAsString("movieplayer", "aacaudiocodec", ""); string splitterFilter = xmlreader.GetValueAsString("movieplayer", "splitterfilter", ""); string splitterFileFilter = xmlreader.GetValueAsString("movieplayer", "splitterfilefilter", ""); settingLAVSlitter = xmlreader.GetValueAsBool("movieplayer", "settinglavplitter", false); if (videoCodec == string.Empty) { ArrayList availableVideoFilters = FilterHelper.GetFilters(MediaType.Video, MediaSubTypeEx.MPEG2); videoCodec = SetCodecBox(availableVideoFilters, "LAV Video Decoder", "DScaler Mpeg2 Video Decoder", ""); } if (h264videoCodec == string.Empty) { ArrayList availableH264VideoFilters = FilterHelper.GetFilters(MediaType.Video, MediaSubType.H264); h264videoCodec = SetCodecBox(availableH264VideoFilters, "LAV Video Decoder", "CoreAVC Video Decoder", ""); } if (vc1videoCodec == string.Empty) { ArrayList availableVC1VideoFilters = FilterHelper.GetFilters(MediaType.Video, MediaSubType.VC1); vc1videoCodec = SetCodecBox(availableVC1VideoFilters, "LAV Video Decoder", "", ""); } if (vc1ivideoCodec == string.Empty) { ArrayList availableVC1VideoFilters = FilterHelper.GetFilters(MediaType.Video, MediaSubType.VC1); vc1ivideoCodec = SetCodecBox(availableVC1VideoFilters, "LAV Video Decoder", "", ""); } if (xvidvideoCodec == string.Empty) { ArrayList availableXVIDVideoFilters = FilterHelper.GetFilters(MediaType.Video, MediaSubType.XVID); xvidvideoCodec = SetCodecBox(availableXVIDVideoFilters, "LAV Video Decoder", "DivX Decoder Filter", ""); } if (audioCodec == string.Empty) { ArrayList availableAudioFilters = FilterHelper.GetFilters(MediaType.Audio, MediaSubType.Mpeg2Audio); audioCodec = SetCodecBox(availableAudioFilters, "LAV Audio Decoder", "DScaler Audio Decoder", "ffdshow Audio Decoder"); } if (aacaudioCodec == string.Empty) { ArrayList availableAACAudioFilters = FilterHelper.GetFilters(MediaType.Audio, MediaSubType.AAC); aacaudioCodec = SetCodecBox(availableAACAudioFilters, "LAV Audio Decoder", "MONOGRAM ACC Decoder", "ffdshow Audio Decoder"); } if (splitterFilter == string.Empty) { ArrayList availableSourcesFilters = FilterHelper.GetFilterSource(); splitterFilter = SetCodecBox(availableSourcesFilters, "LAV Splitter Source", "", ""); } if (splitterFileFilter == string.Empty) { ArrayList availableFileSyncFilters = FilterHelper.GetFilters(MediaType.Stream, MediaSubType.Null); splitterFileFilter = SetCodecBox(availableFileSyncFilters, "LAV Splitter", "", ""); } if (CheckSourceSplitter == string.Empty && (splitterFilter == "LAV Splitter Source" || splitterFileFilter == "LAV Splitter")) { ForceSourceSplitter.Checked = true; } // Enable WMV WMA codec for LAV suite (setting will be change only on first run and if lav is set as default splitter) if (!settingLAVSlitter && (splitterFilter == "LAV Splitter Source" || splitterFileFilter == "LAV Splitter")) { EnableWmvWmaLAVSettings(@"Software\\LAV\\Splitter\\Formats", "asf"); EnableWmvWmaLAVSettings(@"Software\\LAV\\Audio\\Formats", "wma"); EnableWmvWmaLAVSettings(@"Software\\LAV\\Audio\\Formats", "wmalossless"); settingLAVSlitter = true; } audioCodecComboBox.Text = audioCodec; videoCodecComboBox.Text = videoCodec; h264videoCodecComboBox.Text = h264videoCodec; vc1ivideoCodecComboBox.Text = vc1ivideoCodec; vc1videoCodecComboBox.Text = vc1videoCodec; xvidvideoCodecComboBox.Text = xvidvideoCodec; aacAudioCodecComboBox.Text = aacaudioCodec; SplitterComboBox.Text = splitterFilter; SplitterFileComboBox.Text = splitterFileFilter; CheckBoxValid(audioCodecComboBox); CheckBoxValid(videoCodecComboBox); CheckBoxValid(h264videoCodecComboBox); CheckBoxValid(vc1videoCodecComboBox); CheckBoxValid(vc1ivideoCodecComboBox); CheckBoxValid(xvidvideoCodecComboBox); CheckBoxValid(aacAudioCodecComboBox); CheckBoxValid(audioRendererComboBox); CheckBoxValid(SplitterComboBox); CheckBoxValid(SplitterFileComboBox); } }
public static void SetRefreshRateBasedOnFpsThread() { try { if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.madVR && !GUIGraphicsContext.ForcedRefreshRate3D) { using (Settings xmlreader = new MPSettings()) { if (!xmlreader.GetValueAsBool("general", "useInternalDRC", false)) { return; } } } double currentRR = 0; if (GUIGraphicsContext.DX9Device != null && !GUIGraphicsContext.DX9Device.Disposed) { if ((GUIGraphicsContext.DX9Device.DeviceCaps.AdapterOrdinal == -1) || (Manager.Adapters.Count <= GUIGraphicsContext.DX9Device.DeviceCaps.AdapterOrdinal) || (Manager.Adapters.Count > Screen.AllScreens.Length)) { Log.Info("RefreshRateChanger.SetRefreshRateBasedOnFPS: adapter number out of bounds"); } else { currentRR = Manager.Adapters[GUIGraphicsContext.DX9Device.DeviceCaps.AdapterOrdinal].CurrentDisplayMode.RefreshRate; } _refreshrateChangeCurrentRR = currentRR; bool deviceReset; bool forceRefreshRate; using (Settings xmlreader = new MPSettings()) { if (!xmlreader.GetValueAsBool("general", "autochangerefreshrate", false)) { if (GUIGraphicsContext.VideoRenderer != GUIGraphicsContext.VideoRendererType.madVR || !GUIGraphicsContext.ForcedRefreshRate3D) { Log.Info("RefreshRateChanger.SetRefreshRateBasedOnFPS: 'auto refreshrate changer' disabled"); return; } } forceRefreshRate = xmlreader.GetValueAsBool("general", "force_refresh_rate", false); deviceReset = xmlreader.GetValueAsBool("general", "devicereset", false); } double newRR; string newExtCmd; string newRRDescription; FindExtCmdfromSettings(_workerFps, out newRR, out newExtCmd, out newRRDescription); if (newRR > 0 && (currentRR != newRR || forceRefreshRate) || (GUIGraphicsContext.ForcedRefreshRate3D && !GUIGraphicsContext.ForcedRefreshRate3DDone)) { Log.Info("RefreshRateChanger.SetRefreshRateBasedOnFPS: current refreshrate is {0}hz - changing it to {1}hz", currentRR, newRR); // Add a delay for HDR if (!g_Player.Playing && GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.madVR) { Log.Debug("RefreshRateChanger.SetRefreshRateBasedOnFPS delayed start when using madVR"); Thread.Sleep(10000); } if (String.IsNullOrEmpty(newExtCmd)) { Log.Info( "RefreshRateChanger.SetRefreshRateBasedOnFPS: using internal win32 method for changing refreshrate. current is {0}hz, desired is {1}", currentRR, newRR); Log.Info("RefreshRateChanger AdapterOrdinal value is {0}", (uint)GUIGraphicsContext.DX9Device.DeviceCaps.AdapterOrdinal); Win32.CycleRefreshRate((uint)GUIGraphicsContext.DX9Device.DeviceCaps.AdapterOrdinal, newRR); NotifyRefreshRateChanged(newRRDescription, false); } else if (RunExternalJob(newExtCmd, _workerStrFile, _workerType, deviceReset) && newRR != currentRR) { Win32.FixDwm(); NotifyRefreshRateChanged(newRRDescription, false); } if (GUIGraphicsContext.Vmr9Active && GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.EVR) { Log.Info( "RefreshRateChanger.SetRefreshRateBasedOnFPS: dynamic refresh rate change - notify video renderer"); VMR9Util.g_vmr9.UpdateEVRDisplayFPS(); } } else { if (newRR == 0) { Log.Info( "RefreshRateChanger.SetRefreshRateBasedOnFPS: could not find a matching refreshrate based on {0} fps (check config)", _workerFps); } else { Log.Info( "RefreshRateChanger.SetRefreshRateBasedOnFPS: no refreshrate change required. current is {0}hz, desired is {1}", currentRR, newRR); } } Log.Info("RefreshRateChanger.SwitchFocus"); Util.Utils.SwitchFocus(); } } catch (Exception ex) { // RefreshRate failed Log.Error("RefreshRate failed: {0}", ex.Message); } }
public override void LoadSettings() { using (Settings xmlreader = new MPSettings()) { // Player Settings // Get first the sound device, so that it is available, when updating the combo _soundDevice = xmlreader.GetValueAsString("audioplayer", "sounddevice", "None"); _soundDeviceID = xmlreader.GetValueAsString("audioplayer", "sounddeviceid", ""); string strAudioPlayer = xmlreader.GetValueAsString("audioplayer", "playerId", "0"); int audioPlayer = (int)AudioPlayer.Bass; // Default to BASS Player try { audioPlayer = Convert.ToInt16(strAudioPlayer); } catch (Exception) // We end up here in the conversion Phase, where we have still a string ioncluded { } audioPlayerComboBox.SelectedIndex = audioPlayer; #region General Bass Player Settings // Remove the Event Handler, so that the settings for Crossfading a preserved GaplessPlaybackChkBox.CheckedChanged -= GaplessPlaybackChkBox_CheckedChanged; int crossFadeMS = xmlreader.GetValueAsInt("audioplayer", "crossfade", 4000); if (crossFadeMS < 0) { crossFadeMS = 4000; } else if (crossFadeMS > trackBarCrossfade.Maximum) { crossFadeMS = trackBarCrossfade.Maximum; } trackBarCrossfade.Value = crossFadeMS; int bufferingMS = xmlreader.GetValueAsInt("audioplayer", "buffering", 500); if (bufferingMS < trackBarBuffering.Minimum) { bufferingMS = trackBarBuffering.Minimum; } else if (bufferingMS > trackBarBuffering.Maximum) { bufferingMS = trackBarBuffering.Maximum; } trackBarBuffering.Value = bufferingMS; EnableReplayGainChkBox.Checked = xmlreader.GetValueAsBool("audioplayer", "enableReplayGain", false); EnableAlbumReplayGainChkBox.Checked = xmlreader.GetValueAsBool("audioplayer", "enableAlbumReplayGain", false); GaplessPlaybackChkBox.Checked = xmlreader.GetValueAsBool("audioplayer", "gaplessPlayback", false); UseSkipStepsCheckBox.Checked = xmlreader.GetValueAsBool("audioplayer", "useSkipSteps", false); FadeOnStartStopChkbox.Checked = xmlreader.GetValueAsBool("audioplayer", "fadeOnStartStop", true); StreamOutputLevelNud.Value = (decimal)xmlreader.GetValueAsInt("audioplayer", "streamOutputLevel", 100); cbUpmixMono.SelectedIndex = xmlreader.GetValueAsInt("audioplayer", "upMixMono", 0); cbUpmixStereo.SelectedIndex = xmlreader.GetValueAsInt("audioplayer", "upMixStereo", 0); cbUpmixQuadro.SelectedIndex = xmlreader.GetValueAsInt("audioplayer", "upMixQuadro", 0); cbUpmixFiveDotOne.SelectedIndex = xmlreader.GetValueAsInt("audioplayer", "upMixFiveDotOne", 0); chkEnableResumeSupport.Checked = xmlreader.GetValueAsBool("audioplayer", "enableResume", false); tbResumeAfter.Text = xmlreader.GetValueAsString("audioplayer", "resumeAfter", "0"); cbResumeSelect.Text = xmlreader.GetValueAsString("audioplayer", "resumeSelect", ""); tbResumeSearchValue.Text = xmlreader.GetValueAsString("audioplayer", "resumeSearch", ""); // Re-add the previously removed Event Handler GaplessPlaybackChkBox.CheckedChanged += GaplessPlaybackChkBox_CheckedChanged; #endregion #region BASS ASIO hScrollBarBalance.Value = xmlreader.GetValueAsInt("audioplayer", "asiobalance", 0); #endregion #region BASS WASAPI WasapiExclusiveModeCkBox.Checked = xmlreader.GetValueAsBool("audioplayer", "wasapiExclusive", true); WasApiSpeakersCombo.SelectedIndex = xmlreader.GetValueAsInt("audioplayer", "wasApiSpeakers", 1); #endregion #region Playlist Settings string playListFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal); playListFolder += @"\My Playlists"; playlistFolderTextBox.Text = xmlreader.GetValueAsString("music", "playlists", playListFolder); if (string.Compare(playlistFolderTextBox.Text, playListFolder) == 0) { if (Directory.Exists(playListFolder) == false) { try { Directory.CreateDirectory(playListFolder); } catch (Exception) { } } } repeatPlaylistCheckBox.Checked = xmlreader.GetValueAsBool("musicfiles", "repeat", false); autoShuffleCheckBox.Checked = xmlreader.GetValueAsBool("musicfiles", "autoshuffle", false); SavePlaylistOnExitChkBox.Checked = xmlreader.GetValueAsBool("musicfiles", "savePlaylistOnExit", true); ResumePlaylistChkBox.Checked = xmlreader.GetValueAsBool("musicfiles", "resumePlaylistOnMusicEnter", true); PlaylistCurrentCheckBox.Checked = xmlreader.GetValueAsBool("musicfiles", "playlistIsCurrent", true); PlayListUTF8CheckBox.Checked = xmlreader.GetValueAsBool("musicfiles", "savePlaylistUTF8", false); String strSelectOption = xmlreader.GetValueAsString("musicfiles", "selectOption", "play"); cmbSelectOption.Text = strSelectOption == "play" ? "Play" : "Queue"; chkAddAllTracks.Checked = xmlreader.GetValueAsBool("musicfiles", "addall", true); #endregion #region Misc Settings string playNowJumpTo = xmlreader.GetValueAsString("music", "playnowjumpto", JumpToValue0); switch (playNowJumpTo) { case JumpToValue0: PlayNowJumpToCmbBox.Text = JumpToOptions[0]; break; case JumpToValue1: PlayNowJumpToCmbBox.Text = JumpToOptions[1]; break; case JumpToValue2: PlayNowJumpToCmbBox.Text = JumpToOptions[2]; break; case JumpToValue3: PlayNowJumpToCmbBox.Text = JumpToOptions[3]; break; case JumpToValue4: PlayNowJumpToCmbBox.Text = JumpToOptions[4]; break; case JumpToValue5: PlayNowJumpToCmbBox.Text = JumpToOptions[5]; break; case JumpToValue6: PlayNowJumpToCmbBox.Text = JumpToOptions[6]; break; default: PlayNowJumpToCmbBox.Text = JumpToOptions[0]; break; } chkDisableSimilarTrackLookups.Checked = !(xmlreader.GetValueAsBool("musicmisc", "lookupSimilarTracks", true)); string vuMeter = xmlreader.GetValueAsString("musicmisc", "vumeter", "none"); switch (vuMeter) { case VUMeterValue0: radioButtonVUNone.Checked = true; break; case VUMeterValue1: radioButtonVUAnalog.Checked = true; break; case VUMeterValue2: radioButtonVULed.Checked = true; break; default: radioButtonVUNone.Checked = true; break; } #endregion } }
protected void LoadSettings() { try { MusicDatabase mdb = MusicDatabase.Instance; List <string> scrobbleusers = new List <string>(); string tmpuser = ""; string tmppass = ""; groupBoxProfile.Visible = false; using (Settings xmlreader = new MPSettings()) { tmpuser = xmlreader.GetValueAsString("audioscrobbler", "user", ""); checkBoxEnableNowPlaying.Checked = xmlreader.GetValueAsBool("audioscrobbler", "EnableNowPlaying", true); scrobbleusers = mdb.GetAllScrobbleUsers(); // no users in database if (scrobbleusers.Count == 0) { tabControlLiveFeeds.Enabled = false; tabControlSettings.TabPages.RemoveAt(1); tabControlSettings.TabPages.RemoveAt(1); tabControlSettings.TabPages.RemoveAt(1); labelNoUser.Visible = true; } // only load settings if a user is present else { int selected = 0; int count = 0; foreach (string scrobbler in scrobbleusers) { if (!comboBoxUserName.Items.Contains(scrobbler)) { comboBoxUserName.Items.Add(scrobbler); } if (scrobbler == tmpuser) { selected = count; } count++; } comboBoxUserName.SelectedIndex = selected; buttonDelUser.Enabled = true; tmppass = mdb.AddScrobbleUserPassword(Convert.ToString(mdb.AddScrobbleUser(_currentUser)), ""); EncryptDecrypt Crypter = new EncryptDecrypt(); if (tmppass != string.Empty) { try { EncryptDecrypt DCrypter = new EncryptDecrypt(); maskedTextBoxASPassword.Text = DCrypter.Decrypt(tmppass); } catch (Exception) { //Log.Info("Audioscrobbler: Password decryption failed {0}", ex.Message); } } int tmpNMode = 1; int tmpRand = 77; int tmpArtists = 2; int tmpPreferTracks = 2; int tmpOfflineMode = 0; string tmpUserID = Convert.ToString(mdb.AddScrobbleUser(_currentUser)); checkBoxLogVerbose.Checked = (mdb.AddScrobbleUserSettings(tmpUserID, "iDebugLog", -1) == 1) ? true : false; tmpRand = mdb.AddScrobbleUserSettings(tmpUserID, "iRandomness", -1); checkBoxEnableSubmits.Checked = (mdb.AddScrobbleUserSettings(tmpUserID, "iSubmitOn", -1) == 1) ? true : false; checkBoxScrobbleDefault.Checked = (mdb.AddScrobbleUserSettings(tmpUserID, "iScrobbleDefault", -1) == 1) ? true : false; tmpArtists = mdb.AddScrobbleUserSettings(tmpUserID, "iAddArtists", -1); //numericUpDownTracksPerArtist.Value = mdb.AddScrobbleUserSettings(tmpUserID, "iAddTracks", -1); tmpNMode = mdb.AddScrobbleUserSettings(tmpUserID, "iNeighbourMode", -1); tmpOfflineMode = mdb.AddScrobbleUserSettings(tmpUserID, "iOfflineMode", -1); tmpPreferTracks = mdb.AddScrobbleUserSettings(tmpUserID, "iPreferCount", -1); checkBoxReAddArtist.Checked = (mdb.AddScrobbleUserSettings(tmpUserID, "iRememberStartArtist", -1) == 1) ? true : false; numericUpDownSimilarArtist.Value = (tmpArtists > 0) ? tmpArtists : 2; trackBarRandomness.Value = (tmpRand >= 25) ? tmpRand : 25; trackBarConsiderCount.Value = (tmpPreferTracks >= 0) ? tmpPreferTracks : 2; comboBoxOfflineMode.SelectedIndex = tmpOfflineMode; lastFmLookup = AudioscrobblerUtils.Instance; switch (tmpNMode) { case 3: lastFmLookup.CurrentNeighbourMode = lastFMFeed.topartists; comboBoxNeighbourMode.SelectedIndex = 0; comboBoxNModeSelect.SelectedIndex = 0; break; case 1: lastFmLookup.CurrentNeighbourMode = lastFMFeed.weeklyartistchart; comboBoxNeighbourMode.SelectedIndex = 1; comboBoxNModeSelect.SelectedIndex = 1; break; case 0: lastFmLookup.CurrentNeighbourMode = lastFMFeed.recenttracks; comboBoxNeighbourMode.SelectedIndex = 2; comboBoxNModeSelect.SelectedIndex = 2; break; default: lastFmLookup.CurrentNeighbourMode = lastFMFeed.weeklyartistchart; comboBoxNeighbourMode.SelectedIndex = 1; comboBoxNModeSelect.SelectedIndex = 1; break; } LoadProfileDetails(tmpuser); } } } catch (Exception ex) { Log.Error("Audioscrobbler settings could not be loaded: {0}", ex.Message); } }
protected void SaveSettings() { MusicDatabase mdb = MusicDatabase.Instance; int usedebuglog = 0; int submitsenabled = 1; int scrobbledefault = 1; int randomness = 77; int artisttoadd = 3; int trackstoadd = 1; int neighbourmode = 1; int offlinemode = 0; int prefercount = 2; int rememberstartartist = 1; if (comboBoxUserName.Text != string.Empty) { using (Settings xmlwriter = new MPSettings()) { xmlwriter.SetValue("audioscrobbler", "user", comboBoxUserName.Text); xmlwriter.SetValueAsBool("audioscrobbler", "EnableNowPlaying", checkBoxEnableNowPlaying.Checked); string tmpPass = ""; string tmpUserID = ""; try { EncryptDecrypt Crypter = new EncryptDecrypt(); tmpPass = Crypter.Encrypt(maskedTextBoxASPassword.Text); } catch (Exception) { //Log.Info("Audioscrobbler: Password encryption failed {0}", ex.Message); } // checks and adds the user if necessary + updates the password; mdb.AddScrobbleUserPassword(Convert.ToString(mdb.AddScrobbleUser(comboBoxUserName.Text)), tmpPass); if (checkBoxLogVerbose != null) { usedebuglog = checkBoxLogVerbose.Checked ? 1 : 0; } if (checkBoxEnableSubmits != null) { submitsenabled = checkBoxEnableSubmits.Checked ? 1 : 0; } if (checkBoxScrobbleDefault != null) { scrobbledefault = checkBoxScrobbleDefault.Checked ? 1 : 0; } if (trackBarRandomness != null) { randomness = trackBarRandomness.Value; } if (numericUpDownSimilarArtist != null) { artisttoadd = (int)numericUpDownSimilarArtist.Value; } //if (numericUpDownTracksPerArtist != null) // trackstoadd = (int)numericUpDownTracksPerArtist.Value; if (lastFmLookup != null) { neighbourmode = (int)lastFmLookup.CurrentNeighbourMode; } else { Log.Info("DEBUG *** lastFMLookup was null. neighbourmode: {0}", Convert.ToString(neighbourmode)); } if (comboBoxOfflineMode != null) { offlinemode = comboBoxOfflineMode.SelectedIndex; } if (trackBarConsiderCount != null) { prefercount = trackBarConsiderCount.Value; } if (checkBoxReAddArtist != null) { rememberstartartist = checkBoxReAddArtist.Checked ? 1 : 0; } tmpUserID = Convert.ToString(mdb.AddScrobbleUser(comboBoxUserName.Text)); mdb.AddScrobbleUserSettings(tmpUserID, "iDebugLog", usedebuglog); mdb.AddScrobbleUserSettings(tmpUserID, "iRandomness", randomness); mdb.AddScrobbleUserSettings(tmpUserID, "iSubmitOn", submitsenabled); mdb.AddScrobbleUserSettings(tmpUserID, "iScrobbleDefault", scrobbledefault); mdb.AddScrobbleUserSettings(tmpUserID, "iAddArtists", artisttoadd); mdb.AddScrobbleUserSettings(tmpUserID, "iAddTracks", trackstoadd); mdb.AddScrobbleUserSettings(tmpUserID, "iNeighbourMode", neighbourmode); mdb.AddScrobbleUserSettings(tmpUserID, "iOfflineMode", offlinemode); mdb.AddScrobbleUserSettings(tmpUserID, "iPreferCount", prefercount); mdb.AddScrobbleUserSettings(tmpUserID, "iRememberStartArtist", rememberstartartist); //} } } }
// change screen refresh rate based on media framerate public static void AdaptRefreshRate(string strFile, MediaType type) { if (_refreshrateChangePending) { return; } bool isTV = Util.Utils.IsLiveTv(strFile); bool isDVD = Util.Utils.IsDVD(strFile); bool isVideo = Util.Utils.IsVideo(strFile); bool isRTSP = Util.Utils.IsRTSP(strFile); //rtsp users for live TV and recordings. if (!isTV && !isDVD && !isVideo && !isRTSP) { return; } bool enabled = false; NumberFormatInfo provider = new NumberFormatInfo(); provider.NumberDecimalSeparator = "."; bool deviceReset = false; bool force_refresh_rate = false; using (Settings xmlreader = new MPSettings()) { enabled = xmlreader.GetValueAsBool("general", "autochangerefreshrate", false) || GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.madVR && GUIGraphicsContext.ForcedRefreshRate3D; if (!enabled) { Log.Info("RefreshRateChanger.AdaptRefreshRate: 'auto refreshrate changer' disabled"); return; } deviceReset = xmlreader.GetValueAsBool("general", "devicereset", false); force_refresh_rate = xmlreader.GetValueAsBool("general", "force_refresh_rate", false); } RefreshRateSetting setting = RetrieveRefreshRateChangerSetting("TV"); if (setting == null) { Log.Error( "RefreshRateChanger.AdaptRefreshRate: TV section not found in mediaportal.xml, please delete file and reconfigure."); return; } List <double> tvFPS = setting.Fps; double fps = -1; if ((isVideo || isDVD) && (!isRTSP && !isTV)) { if (g_Player.MediaInfo != null) { fps = g_Player.MediaInfo.Framerate; } else { StackTrace st = new StackTrace(true); StackFrame sf = st.GetFrame(0); Log.Error("RefreshRateChanger.AdaptRefreshRate: g_Player.MediaInfo was null. file: {0} st: {1}", strFile, sf.GetMethod().Name); return; } } else if (isTV || isRTSP) { if (tvFPS.Count > 0) { fps = tvFPS[0]; } } if (fps < 1) { Log.Info("RefreshRateChanger.AdaptRefreshRate: unable to guess framerate on file {0}", strFile); } else { Log.Info("RefreshRateChanger.AdaptRefreshRate: framerate on file {0} is {1}", strFile, fps); } SetRefreshRateBasedOnFPS(fps, strFile, type); }
// defaults the refreshrate public static void AdaptRefreshRate() { if (_refreshrateChangePending || _refreshrateChangeCurrentRR == 0) { return; } string defaultKeyHZ = ""; double defaultHZ = 0; bool enabled = false; NumberFormatInfo provider = new NumberFormatInfo(); provider.NumberDecimalSeparator = "."; double defaultFPS = 0; using (Settings xmlreader = new MPSettings()) { enabled = xmlreader.GetValueAsBool("general", "autochangerefreshrate", false); if (!enabled) { if (GUIGraphicsContext.VideoRenderer != GUIGraphicsContext.VideoRendererType.madVR || !GUIGraphicsContext.ForcedRefreshRate3D) { Log.Info("RefreshRateChanger.AdaptRefreshRate: 'auto refreshrate changer' disabled"); return; } } bool useDefaultHz = xmlreader.GetValueAsBool("general", "use_default_hz", false); if (!useDefaultHz) { if (GUIGraphicsContext.VideoRenderer != GUIGraphicsContext.VideoRendererType.madVR || !GUIGraphicsContext.ForcedRefreshRate3D) { Log.Info( "RefreshRateChanger.AdaptRefreshRate: 'auto refreshrate changer' not going back to default refreshrate"); return; } } defaultKeyHZ = xmlreader.GetValueAsString("general", "default_hz", ""); if (defaultKeyHZ.Length > 0) { double.TryParse(defaultKeyHZ, NumberStyles.AllowDecimalPoint, provider, out defaultHZ); } foreach (RefreshRateSetting setting in _refreshRateSettings) { if (setting.Hz == defaultHZ) { if (setting.Fps.Count > 0) { defaultFPS = setting.Fps[0]; } } } } SetRefreshRateBasedOnFPS(defaultFPS, "", MediaType.Unknown); ResetRefreshRateState(); }
protected void SaveSettings(string section) { if (AddOpticalDiskDrives) { AddStaticShares(DriveType.DVD, "DVD"); } using (Settings xmlwriter = new MPSettings()) { string defaultShare = string.Empty; for (int index = 0; index < MaximumShares; index++) { string shareName = String.Format("sharename{0}", index); string sharePath = String.Format("sharepath{0}", index); string sharePin = String.Format("pincode{0}", index); string shareType = String.Format("sharetype{0}", index); string shareServer = String.Format("shareserver{0}", index); string shareLogin = String.Format("sharelogin{0}", index); string sharePwd = String.Format("sharepassword{0}", index); string sharePort = String.Format("shareport{0}", index); string shareRemotePath = String.Format("shareremotepath{0}", index); string shareViewPath = String.Format("shareview{0}", index); xmlwriter.RemoveEntry(section, shareName); xmlwriter.RemoveEntry(section, sharePath); xmlwriter.RemoveEntry(section, sharePin); xmlwriter.RemoveEntry(section, shareType); xmlwriter.RemoveEntry(section, shareServer); xmlwriter.RemoveEntry(section, shareLogin); xmlwriter.RemoveEntry(section, sharePwd); xmlwriter.RemoveEntry(section, sharePort); xmlwriter.RemoveEntry(section, shareRemotePath); xmlwriter.RemoveEntry(section, shareViewPath); if (section == "music" || section == "movies") { string shareScan = String.Format("sharescan{0}", index); xmlwriter.RemoveEntry(section, shareScan); } if (section == "movies") { string thumbs = String.Format("videothumbscreate{0}", index); xmlwriter.RemoveEntry(section, thumbs); string movieFolder = String.Format("eachfolderismovie{0}", index); xmlwriter.RemoveEntry(section, movieFolder); } string shareNameData = string.Empty; string sharePathData = string.Empty; string sharePinData = string.Empty; bool shareTypeData = false; string shareServerData = string.Empty; string shareLoginData = string.Empty; string sharePwdData = string.Empty; int sharePortData = 21; string shareRemotePathData = string.Empty; int shareLayout = (int)MediaPortal.GUI.Library.GUIFacadeControl.Layout.List; bool shareScanData = false; //ThumbsCreate (default true) bool thumbsCreate = true; bool folderIsMovie = false; if (CurrentShares != null && CurrentShares.Count > index) { ShareData shareData = CurrentShares[index].Tag as ShareData; if (shareData != null && !String.IsNullOrEmpty(shareData.Name)) { shareNameData = shareData.Name; sharePathData = shareData.Folder; sharePinData = shareData.PinCode; shareTypeData = shareData.IsRemote; shareServerData = shareData.Server; shareLoginData = shareData.LoginName; sharePwdData = shareData.PassWord; sharePortData = shareData.Port; shareRemotePathData = shareData.RemoteFolder; shareLayout = (int)shareData.DefaultLayout; shareScanData = shareData.ScanShare; // ThumbsCreate thumbsCreate = shareData.CreateThumbs; folderIsMovie = shareData.EachFolderIsMovie; if (CurrentShares[index] == DefaultShare) { defaultShare = shareNameData; } xmlwriter.SetValue(section, shareName, shareNameData); xmlwriter.SetValue(section, sharePath, sharePathData); xmlwriter.SetValue(section, sharePin, Util.Utils.EncryptPin(sharePinData)); xmlwriter.SetValueAsBool(section, shareType, shareTypeData); xmlwriter.SetValue(section, shareServer, shareServerData); xmlwriter.SetValue(section, shareLogin, shareLoginData); xmlwriter.SetValue(section, sharePwd, sharePwdData); xmlwriter.SetValue(section, sharePort, sharePortData.ToString()); xmlwriter.SetValue(section, shareRemotePath, shareRemotePathData); xmlwriter.SetValue(section, shareViewPath, shareLayout); if (section == "music" || section == "movies") { string shareScan = String.Format("sharescan{0}", index); xmlwriter.SetValueAsBool(section, shareScan, shareScanData); } //ThumbsCreate if (section == "movies") { string thumbs = String.Format("videothumbscreate{0}", index); xmlwriter.SetValueAsBool(section, thumbs, thumbsCreate); string folderMovie = String.Format("eachfolderismovie{0}", index); xmlwriter.SetValueAsBool(section, folderMovie, folderIsMovie); } } } } xmlwriter.SetValue(section, "default", defaultShare); xmlwriter.SetValueAsBool(section, "rememberlastfolder", RememberLastFolder); xmlwriter.SetValueAsBool(section, "AddOpticalDiskDrives", AddOpticalDiskDrives); xmlwriter.SetValueAsBool(section, "SwitchRemovableDrives", SwitchRemovableDrives); } }
public override void AllocResources() { try { //lock (RenderImageLock) { Dispose(); using (Settings xmlreader = new MPSettings()) { _hidePngAnimations = (xmlreader.GetValueAsBool("general", "hidepnganimations", false)); } if (_filenames == null) { _filenames = new ArrayList(); foreach (string filename in _textureNames.Split(';')) { if (filename.IndexOfAny(new char[] { '?', '*' }) != -1) { foreach (string match in Directory.GetFiles(GUIGraphicsContext.GetThemedSkinFile(@"\media\" + filename))) { _filenames.Add(Path.GetFileName(match)); } } else { _filenames.Add(filename.Trim()); } } } _images = new GUIImage[_filenames.Count]; int w = 0; int h = 0; if (_images != null) { for (int index = 0; index < _images.Length; index++) { _imageId++; _images[index] = new GUIImage(ParentID, _imageId + index, 0, 0, Width, Height, (string)_filenames[index], 0); _images[index].ParentControl = this; _images[index].ColourDiffuse = ColourDiffuse; _images[index].DimColor = DimColor; _images[index].KeepAspectRatio = _keepAspectRatio; _images[index].Filtering = Filtering; _images[index].RepeatBehavior = _repeatBehavior; _images[index].DiffuseFileName = _diffuseFileName; _images[index].MaskFileName = _maskFileName; _images[index].OverlayFileName = _overlayFileName; _images[index].FlipX = _flipX; _images[index].FlipY = _flipY; _images[index].SetBorder(_strBorder, _borderPosition, _borderTextureRepeat, _borderTextureRotate, _borderTextureFileName, _borderColorKey, _borderHasCorners, _borderCornerTextureRotate); _images[index].TileFill = _tileFill; _images[index].AllocResources(); //_images[index].ScaleToScreenResolution(); -> causes too big images in fullscreen if (_images.Length > index) { w = Math.Max(w, _images[index].Width); } if (_images.Length > index) { h = Math.Max(h, _images[index].Height); } if (_images.Length > index) { _renderWidth = Math.Max(_renderWidth, _images[index].RenderWidth); } if (_images.Length > index) { _renderHeight = Math.Max(_renderHeight, _images[index].RenderHeight); } if (_images.Length > index) { _textureWidth = Math.Max(_textureWidth, _images[index].TextureWidth); } if (_images.Length > index) { _textureHeight = Math.Max(_textureHeight, _images[index].TextureHeight); } } } int x = _positionX; int y = _positionY; if (_horizontalAlignment == HorizontalAlignment.Center) { x = x - (w / 2); } else if (_horizontalAlignment == HorizontalAlignment.Right) { x = x - w; } if (_verticalAlignment == VerticalAlignment.Center) { y = y - (h / 2); } else if (_verticalAlignment == VerticalAlignment.Bottom) { y = y - h; } for (int index = 0; index < _images.Length; index++) { _images[index].SetPosition(x, y); } } } catch (Exception e) { // catch } }
public VolumeHandler(int[] volumeTable) { if (OSInfo.OSInfo.Win10OrLater()) { if (_MMdeviceEnumerator == null) { _MMdeviceEnumerator = new MMDeviceEnumerator(); } var mMdeviceList = _MMdeviceEnumerator.EnumAudioEndpoints(DataFlow.Render, DeviceState.Active); if (mMdeviceList.Count > 0) { var mMdevice = _MMdeviceEnumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia); if (mMdevice != null) { using (Settings reader = new MPSettings()) { int levelStyle = reader.GetValueAsInt("volume", "startupstyle", 0); if (levelStyle == 0) { _startupVolume = Math.Max(0, Math.Min(65535, reader.GetValueAsInt("volume", "lastknown", 52428))); } if (levelStyle == 1) { } if (levelStyle == 2) { _startupVolume = Math.Max(0, Math.Min(65535, reader.GetValueAsInt("volume", "startuplevel", 52428))); } IsDigital = reader.GetValueAsBool("volume", "digital", false); _showVolumeOSD = reader.GetValueAsBool("volume", "defaultVolumeOSD", true); hideWindowsOSD = reader.GetValueAsBool("volume", "hideWindowsOSD", false); } try { _volumeTable = volumeTable; _mixer10 = new Mixer.Mixer10(); _mixer10.Open(0, IsDigital, volumeTable); } catch (Exception ex) { Log.Error("VolumeHandler: Mixer exception during init {0}", ex); } if (OSInfo.OSInfo.Win8OrLater() && hideWindowsOSD) { try { bool tempShowVolumeOSD = _showVolumeOSD; _showVolumeOSD = true; VolumeOSD = new HideVolumeOSD.HideVolumeOSDLib(IsMuted); VolumeOSD.HideOSD(); _showVolumeOSD = tempShowVolumeOSD; } catch { } } } } else { _volumeTable = volumeTable; } } else { if (GUIGraphicsContext.DeviceAudioConnected > 0) { using (Settings reader = new MPSettings()) { int levelStyle = reader.GetValueAsInt("volume", "startupstyle", 0); if (levelStyle == 0) { _startupVolume = Math.Max(0, Math.Min(65535, reader.GetValueAsInt("volume", "lastknown", 52428))); } if (levelStyle == 1) { } if (levelStyle == 2) { _startupVolume = Math.Max(0, Math.Min(65535, reader.GetValueAsInt("volume", "startuplevel", 52428))); } IsDigital = reader.GetValueAsBool("volume", "digital", false); _showVolumeOSD = reader.GetValueAsBool("volume", "defaultVolumeOSD", true); hideWindowsOSD = reader.GetValueAsBool("volume", "hideWindowsOSD", false); } try { _mixer = new Mixer.Mixer(); _mixer.Open(0, IsDigital); _volumeTable = volumeTable; _mixer.ControlChanged += mixer_ControlChanged; } catch (Exception ex) { Log.Error("VolumeHandler: Mixer exception when init {0}", ex); } if (OSInfo.OSInfo.Win8OrLater() && hideWindowsOSD) { try { bool tempShowVolumeOSD = _showVolumeOSD; _showVolumeOSD = true; VolumeOSD = new HideVolumeOSD.HideVolumeOSDLib(IsMuted); VolumeOSD.HideOSD(); _showVolumeOSD = tempShowVolumeOSD; } catch { } } } else { _volumeTable = volumeTable; } } }
/// <summary> /// Thread to scan the Shares /// </summary> private void FolderScanThread() { _scanRunning = true; ArrayList shares = new ArrayList(); for (int index = 0; index < sharesListBox.CheckedIndices.Count; index++) { string path = sharesListBox.Items[(int)sharesListBox.CheckedIndices[index]].ToString(); if (Directory.Exists(path)) { try { string driveName = path.Substring(0, 1); if (path.StartsWith(@"\\")) { // we have the path in unc notation driveName = path; } ulong FreeBytesAvailable = Util.Utils.GetFreeDiskSpace(driveName); if (FreeBytesAvailable > 0) { ulong DiskSpace = FreeBytesAvailable / 1048576; if (DiskSpace > 100) // > 100MB left for creation of thumbs, etc { Log.Info("MusicDatabase: adding share {0} for scanning - available disk space: {1} MB", path, DiskSpace.ToString()); shares.Add(path); } else { Log.Warn("MusicDatabase: NOT scanning share {0} because of low disk space: {1} MB", path, DiskSpace.ToString()); } } } catch (Exception) { // Drive not ready, etc } } } MediaPortal.Music.Database.MusicDatabase.DatabaseReorgChanged += new MusicDBReorgEventHandler(SetStatus); groupBox1.Enabled = false; groupBox2.Enabled = true; // Now create a Settings Object with the Settings checked to pass to the Import MusicDatabaseSettings setting = new MusicDatabaseSettings(); setting.CreateMissingFolderThumb = checkBoxCreateFolderThumb.Checked; setting.ExtractEmbeddedCoverArt = buildThumbsCheckBox.Checked; setting.StripArtistPrefixes = checkBoxStripArtistPrefix.Checked; setting.TreatFolderAsAlbum = folderAsAlbumCheckBox.Checked; setting.UseFolderThumbs = checkBoxUseFolderThumb.Checked; setting.UseAllImages = checkBoxAllImages.Checked; setting.CreateArtistPreviews = checkBoxCreateArtist.Checked; setting.CreateGenrePreviews = checkBoxCreateGenre.Checked; setting.UseLastImportDate = checkBoxUpdateSinceLastImport.Checked; setting.ExcludeHiddenFiles = false; setting.DateAddedValue = comboBoxDateAdded.SelectedIndex; try { m_dbs.MusicDatabaseReorg(shares, setting); } catch (Exception ex) { Log.Error("Folder Scan: Exception during processing: ", ex.Message); _scanRunning = false; } using (Settings xmlreader = new MPSettings()) { checkBoxUpdateSinceLastImport.Text = String.Format("Only update new / changed files after {0}", xmlreader.GetValueAsString("musicfiles", "lastImport", "1900-01-01 00:00:00")); } _scanRunning = false; groupBox1.Enabled = true; groupBox2.Enabled = false; }
private void InsertDefaultValues() { string nameBackup = null; if (RefreshRateData(lcRefreshRatesList.ListItems[_defaultHzIndex]).Name != null) { nameBackup = RefreshRateData(lcRefreshRatesList.ListItems[_defaultHzIndex]).Name; } lcRefreshRatesList.Clear(); _defaultHz.Clear(); Settings xmlreader = new MPSettings(); //first time mp config is run, no refreshrate settings available, create the default ones. string[] p = new String[4]; p[0] = "CINEMA"; p[1] = "23.976"; // fps p[2] = "23"; //hz p[3] = ""; //action GUIListItem item = new GUIListItem(); RefreshRateData refreshRateData = new RefreshRateData(p[0], p[1], p[2], p[3]); item.Label = p[0]; item.AlbumInfoTag = refreshRateData; item.OnItemSelected += OnItemSelected; lcRefreshRatesList.Add(item); _defaultHz.Add(p[0]); p = new String[4]; p[0] = "CINEMA24"; p[1] = "24"; // fps p[2] = "24"; //hz p[3] = ""; //action item = new GUIListItem(); refreshRateData = new RefreshRateData(p[0], p[1], p[2], p[3]); item.Label = p[0]; item.AlbumInfoTag = refreshRateData; item.OnItemSelected += OnItemSelected; lcRefreshRatesList.Add(item); _defaultHz.Add(p[0]); p = new String[4]; p[0] = "PAL"; p[1] = "25"; // fps p[2] = "50"; //hz p[3] = ""; //action item = new GUIListItem(); refreshRateData = new RefreshRateData(p[0], p[1], p[2], p[3]); item.Label = p[0]; item.AlbumInfoTag = refreshRateData; item.OnItemSelected += OnItemSelected; lcRefreshRatesList.Add(item); _defaultHz.Add(p[0]); p = new String[4]; p[0] = "PALHD"; p[1] = "50"; // fps p[2] = "50"; //hz p[3] = ""; //action item = new GUIListItem(); refreshRateData = new RefreshRateData(p[0], p[1], p[2], p[3]); item.Label = p[0]; item.AlbumInfoTag = refreshRateData; item.OnItemSelected += OnItemSelected; lcRefreshRatesList.Add(item); _defaultHz.Add(p[0]); p = new String[4]; p[0] = "NTSC"; p[1] = "29.97"; // fps p[2] = "59"; //hz p[3] = ""; //action item = new GUIListItem(); refreshRateData = new RefreshRateData(p[0], p[1], p[2], p[3]); item.Label = p[0]; item.AlbumInfoTag = refreshRateData; item.OnItemSelected += OnItemSelected; lcRefreshRatesList.Add(item); _defaultHz.Add(p[0]); p = new String[4]; p[0] = "NTSCHD"; p[1] = "59.94"; // fps p[2] = "59"; //hz p[3] = ""; //action item = new GUIListItem(); refreshRateData = new RefreshRateData(p[0], p[1], p[2], p[3]); item.Label = p[0]; item.AlbumInfoTag = refreshRateData; item.OnItemSelected += OnItemSelected; lcRefreshRatesList.Add(item); _defaultHz.Add(p[0]); p = new String[4]; p[0] = "ATSC"; p[1] = "30"; // fps p[2] = "60"; //hz p[3] = ""; //action item = new GUIListItem(); refreshRateData = new RefreshRateData(p[0], p[1], p[2], p[3]); item.Label = p[0]; item.AlbumInfoTag = refreshRateData; item.OnItemSelected += OnItemSelected; lcRefreshRatesList.Add(item); _defaultHz.Add(p[0]); p = new String[4]; p[0] = "ATSCHD"; p[1] = "60"; // fps p[2] = "60"; //hz p[3] = ""; //action item = new GUIListItem(); refreshRateData = new RefreshRateData(p[0], p[1], p[2], p[3]); item.Label = p[0]; item.AlbumInfoTag = refreshRateData; item.OnItemSelected += OnItemSelected; lcRefreshRatesList.Add(item); _defaultHz.Add(p[0]); //tv section is not editable, it's static. string tvExtCmd = xmlreader.GetValueAsString("general", "refreshrateTV_ext", ""); string tvName = xmlreader.GetValueAsString("general", "refreshrateTV_name", "PAL"); string tvFPS = xmlreader.GetValueAsString("general", "tv_fps", "25"); string tvHz = xmlreader.GetValueAsString("general", "tv_hz", "50"); String[] parameters = new String[4]; parameters = new String[4]; parameters[0] = "TV"; parameters[1] = tvFPS; // fps parameters[2] = tvHz; //hz parameters[3] = tvExtCmd; //action item = new GUIListItem(); refreshRateData = new RefreshRateData(parameters[0], parameters[1], parameters[2], parameters[3]); item.Label = parameters[0]; item.AlbumInfoTag = refreshRateData; item.OnItemSelected += OnItemSelected; lcRefreshRatesList.Add(item); _defaultHz.Add(parameters[0]); // Select Default Hz value for (int i = 1; i < 100; i++) { string sDefaultHzName = RefreshRateData(lcRefreshRatesList.ListItems[i]).Name; string rate = RefreshRateData(lcRefreshRatesList.ListItems[i]).Refreshrate; if (rate == _sDefaultHzValue && sDefaultHzName == _sDefaultHzNameValue || (sDefaultHzName == nameBackup)) { _defaultHzIndex = i; SetProperties(); break; } } }
protected void LoadSettings(string section, string defaultSharePath) { selectedSection = section; using (Settings xmlreader = new MPSettings()) { string defaultShare = xmlreader.GetValueAsString(section, "default", ""); RememberLastFolder = xmlreader.GetValueAsBool(section, "rememberlastfolder", false); AddOpticalDiskDrives = xmlreader.GetValueAsBool(section, "AddOpticalDiskDrives", true); SwitchRemovableDrives = xmlreader.GetValueAsBool(section, "SwitchRemovableDrives", true); for (int index = 0; index < MaximumShares; index++) { string shareName = String.Format("sharename{0}", index); string sharePath = String.Format("sharepath{0}", index); string sharePin = String.Format("pincode{0}", index); string shareType = String.Format("sharetype{0}", index); string shareServer = String.Format("shareserver{0}", index); string shareLogin = String.Format("sharelogin{0}", index); string sharePwd = String.Format("sharepassword{0}", index); string sharePort = String.Format("shareport{0}", index); string shareRemotePath = String.Format("shareremotepath{0}", index); string shareViewPath = String.Format("shareview{0}", index); string shareNameData = xmlreader.GetValueAsString(section, shareName, ""); string sharePathData = xmlreader.GetValueAsString(section, sharePath, ""); string sharePinData = Util.Utils.DecryptPin(xmlreader.GetValueAsString(section, sharePin, "")); // provide default shares if (index == 0 && shareNameData == string.Empty) { shareNameData = VirtualDirectory.GetShareNameDefault(defaultSharePath); sharePathData = defaultSharePath; sharePinData = string.Empty; AddStaticShares(DriveType.DVD, "DVD"); } bool shareTypeData = xmlreader.GetValueAsBool(section, shareType, false); string shareServerData = xmlreader.GetValueAsString(section, shareServer, ""); string shareLoginData = xmlreader.GetValueAsString(section, shareLogin, ""); string sharePwdData = xmlreader.GetValueAsString(section, sharePwd, ""); int sharePortData = xmlreader.GetValueAsInt(section, sharePort, 21); string shareRemotePathData = xmlreader.GetValueAsString(section, shareRemotePath, "/"); int shareLayout = xmlreader.GetValueAsInt(section, shareViewPath, (int)MediaPortal.GUI.Library.GUIFacadeControl.Layout.List); // For Music Shares, we can indicate, if we want to scan them every time bool shareScanData = false; if (section == "music" || section == "movies") { string shareScan = String.Format("sharescan{0}", index); shareScanData = xmlreader.GetValueAsBool(section, shareScan, true); } // For Movies Shares, we can indicate, if we want to create thumbs bool thumbs = true; bool folderIsMovie = false; if (section == "movies") { string thumbsCreate = String.Format("videothumbscreate{0}", index); thumbs = xmlreader.GetValueAsBool(section, thumbsCreate, true); string eachFolderIsMovie = String.Format("eachfolderismovie{0}", index); folderIsMovie = xmlreader.GetValueAsBool(section, eachFolderIsMovie, false); } if (!String.IsNullOrEmpty(shareNameData)) { ShareData newShare = new ShareData(shareNameData, sharePathData, sharePinData, thumbs); newShare.IsRemote = shareTypeData; newShare.Server = shareServerData; newShare.LoginName = shareLoginData; newShare.PassWord = sharePwdData; newShare.Port = sharePortData; newShare.RemoteFolder = shareRemotePathData; newShare.DefaultLayout = (Layout)shareLayout; if (section == "music" || section == "movies") { newShare.ScanShare = shareScanData; } // ThumbsCreate if (section == "movies") { newShare.CreateThumbs = thumbs; newShare.EachFolderIsMovie = folderIsMovie; } AddShare(newShare, shareNameData.Equals(defaultShare)); } } if (AddOpticalDiskDrives) { AddStaticShares(DriveType.DVD, "DVD"); } if (section == "movies") { sharesListView.Columns[2].Width = 210; if (!sharesListView.Columns.Contains(columnHeader4)) { sharesListView.Columns.Add(columnHeader4); } sharesListView.Columns[3].Width = 60; } else { sharesListView.Columns[2].Width = 270; if (sharesListView.Columns.Contains(columnHeader4)) { sharesListView.Columns.Remove(columnHeader4); } } } }
private void InsertDefaultValues() { lcRefreshRatesList.Clear(); _defaultHz.Clear(); Settings xmlreader = new MPSettings(); //first time mp config is run, no refreshrate settings available, create the default ones. string[] p = new String[4]; p[0] = "CINEMA"; p[1] = "23.976;24"; // fps p[2] = "24"; //hz p[3] = ""; //action GUIListItem item = new GUIListItem(); RefreshRateData refreshRateData = new RefreshRateData(p[0], p[1], p[2], p[3]); item.Label = p[0]; item.AlbumInfoTag = refreshRateData; item.OnItemSelected += OnItemSelected; lcRefreshRatesList.Add(item); _defaultHz.Add(p[0]); p = new String[4]; p[0] = "PAL"; p[1] = "25"; // fps p[2] = "50"; //hz p[3] = ""; //action item = new GUIListItem(); refreshRateData = new RefreshRateData(p[0], p[1], p[2], p[3]); item.Label = p[0]; item.AlbumInfoTag = refreshRateData; item.OnItemSelected += OnItemSelected; lcRefreshRatesList.Add(item); _defaultHz.Add(p[0]); p = new String[4]; p[0] = "HDTV"; p[1] = "50"; // fps p[2] = "50"; //hz p[3] = ""; //action item = new GUIListItem(); refreshRateData = new RefreshRateData(p[0], p[1], p[2], p[3]); item.Label = p[0]; item.AlbumInfoTag = refreshRateData; item.OnItemSelected += OnItemSelected; lcRefreshRatesList.Add(item); _defaultHz.Add(p[0]); p = new String[4]; p[0] = "NTSC"; p[1] = "29.97;30"; // fps p[2] = "60"; //hz p[3] = ""; //action item = new GUIListItem(); refreshRateData = new RefreshRateData(p[0], p[1], p[2], p[3]); item.Label = p[0]; item.AlbumInfoTag = refreshRateData; item.OnItemSelected += OnItemSelected; lcRefreshRatesList.Add(item); _defaultHz.Add(p[0]); //tv section is not editable, it's static. string tvExtCmd = xmlreader.GetValueAsString("general", "refreshrateTV_ext", ""); string tvName = xmlreader.GetValueAsString("general", "refreshrateTV_name", "PAL"); string tvFPS = xmlreader.GetValueAsString("general", "tv_fps", "25"); string tvHz = xmlreader.GetValueAsString("general", "tv_hz", "50"); String[] parameters = new String[4]; parameters = new String[4]; parameters[0] = "TV"; parameters[1] = tvFPS; // fps parameters[2] = tvHz; //hz parameters[3] = tvExtCmd; //action item = new GUIListItem(); refreshRateData = new RefreshRateData(parameters[0], parameters[1], parameters[2], parameters[3]); item.Label = parameters[0]; item.AlbumInfoTag = refreshRateData; item.OnItemSelected += OnItemSelected; lcRefreshRatesList.Add(item); _defaultHz.Add(parameters[0]); }
/// <summary> /// Create a volume handler. /// </summary> /// <returns>A newly created volume handler.</returns> private static VolumeHandler Create() { if (OSInfo.OSInfo.Win10OrLater()) { if (_MMdeviceEnumerator == null) { _MMdeviceEnumerator = new MMDeviceEnumerator(); } var mMdeviceList = _MMdeviceEnumerator.EnumAudioEndpoints(DataFlow.Render, DeviceState.Active); if (mMdeviceList.Count > 0) { var mMdevice = _MMdeviceEnumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia); if (mMdevice != null) { using (Settings reader = new MPSettings()) { _volumeStyle = reader.GetValueAsInt("volume", "handler", 1); switch (_volumeStyle) { // classic volume table case 0: return(new VolumeHandler(new[] { 0, 6553, 13106, 19659, 26212, 32765, 39318, 45871, 52424, 58977, 65535 })); // windows default from registry case 1: return(new VolumeHandler()); // logarithmic case 2: return(new VolumeHandler(new[] { 0, 1039, 1234, 1467, 1744, 2072, 2463, 2927, 3479, 4135, 4914, 5841, 6942, 8250, 9806, 11654, 13851, 16462, 19565, 23253, 27636, 32845, 39037, 46395, 55141, 65535 })); // custom user setting case 3: return(new VolumeHandlerCustom()); // defaults to vista safe "0, 4095, 8191, 12287, 16383, 20479, 24575, 28671, 32767, 36863, 40959, 45055, 49151, 53247, 57343, 61439, 65535" // Vista recommended values case 4: return(new VolumeHandler(new[] { 0, 4095, 8191, 12287, 16383, 20479, 24575, 28671, 32767, 36863, 40959, 45055, 49151, 53247, 57343, 61439, 65535 })); // Windows 10 case 5: return(new VolumeHandler(new[] { 0, 1310, 2620, 3930, 5240, 6550, 7860, 9170, 10480, 11790, 13100, 14410, 15720, 17030, 18340, 19650, 20960, 22270, 23580, 24890, 26200, 27510, 28820, 30130, 31440, 32750, 34060, 35370, 36680, 37990, 39300, 40610, 41920, 43230, 44540, 45850, 47160, 48470, 49780, 51090, 52400, 53710, 55020, 56330, 57640, 58950, 60260, 61570, 62880, 64190, 65535 })); default: return(new VolumeHandlerCustom()); } } } } } else { if (GUIGraphicsContext.DeviceAudioConnected > 0) { using (Settings reader = new MPSettings()) { int volumeStyle = reader.GetValueAsInt("volume", "handler", 1); switch (volumeStyle) { // classic volume table case 0: return(new VolumeHandler(new[] { 0, 6553, 13106, 19659, 26212, 32765, 39318, 45871, 52424, 58977, 65535 })); // windows default from registry case 1: return(new VolumeHandler()); // logarithmic case 2: return(new VolumeHandler(new[] { 0, 1039, 1234, 1467, 1744, 2072, 2463, 2927, 3479, 4135, 4914, 5841, 6942, 8250, 9806, 11654, 13851, 16462, 19565, 23253, 27636, 32845, 39037, 46395, 55141, 65535 })); // custom user setting case 3: return(new VolumeHandlerCustom()); // defaults to vista safe "0, 4095, 8191, 12287, 16383, 20479, 24575, 28671, 32767, 36863, 40959, 45055, 49151, 53247, 57343, 61439, 65535" // Vista recommended values case 4: return(new VolumeHandler(new[] { 0, 4095, 8191, 12287, 16383, 20479, 24575, 28671, 32767, 36863, 40959, 45055, 49151, 53247, 57343, 61439, 65535 })); // Windows 10 case 5: return(new VolumeHandler(new[] { 0, 1310, 2620, 3930, 5240, 6550, 7860, 9170, 10480, 11790, 13100, 14410, 15720, 17030, 18340, 19650, 20960, 22270, 23580, 24890, 26200, 27510, 28820, 30130, 31440, 32750, 34060, 35370, 36680, 37990, 39300, 40610, 41920, 43230, 44540, 45850, 47160, 48470, 49780, 51090, 52400, 53710, 55020, 56330, 57640, 58950, 60260, 61570, 62880, 64190, 65535 })); default: return(new VolumeHandlerCustom()); } } } } return(new VolumeHandlerCustom()); }
private void mpButton1_Click(object sender, EventArgs e) { String macAddress; byte[] hwAddress; WakeOnLanManager wakeOnLanManager = new WakeOnLanManager(); IPAddress ipAddress = null; string hostName = Util.Utils.GetServerNameFromUNCPath(folderTextBox.Text); if (string.IsNullOrEmpty(hostName)) { MessageBox.Show("Wrong unc path " + folderTextBox.Text, "MediaPortal Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Log.Debug("Wrong unc path {0}", folderTextBox.Text); return; } using (Profile.Settings xmlreader = new MPSettings()) { macAddress = xmlreader.GetValueAsString("macAddress", hostName, null); } if (wakeOnLanManager.Ping(hostName, 100) && !string.IsNullOrEmpty(macAddress)) { MessageBox.Show("WakeUpServer: The " + hostName + "server already started and mac address is learnt!", "MediaPortal Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Log.Debug("WakeUpServer: The {0} server already started and mac address is learnt!", hostName); return; } // Check if we already have a valid IP address stored, // otherwise try to resolve the IP address if (!IPAddress.TryParse(hostName, out ipAddress)) { // Get IP address of the server try { IPAddress[] ips; ips = Dns.GetHostAddresses(hostName); Log.Debug("WakeUpServer: WOL - GetHostAddresses({0}) returns:", hostName); foreach (IPAddress ip in ips) { Log.Debug(" {0}", ip); ipAddress = ip; // Check for valid IP address if (ipAddress != null) { // Update the MAC address if possible hwAddress = wakeOnLanManager.GetHardwareAddress(ipAddress); if (wakeOnLanManager.IsValidEthernetAddress(hwAddress)) { Log.Debug("WakeUpServer: WOL - Valid auto MAC address: {0:x}:{1:x}:{2:x}:{3:x}:{4:x}:{5:x}" , hwAddress[0], hwAddress[1], hwAddress[2], hwAddress[3], hwAddress[4], hwAddress[5]); // Store MAC address macAddress = BitConverter.ToString(hwAddress).Replace("-", ":"); Log.Debug("WakeUpServer: WOL - Store MAC address: {0}", macAddress); using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.MPSettings()) { xmlwriter.SetValue("macAddress", hostName, macAddress); } MessageBox.Show("Stored MAC address: " + macAddress, "MediaPortal Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show("WakeUpServer: WOL - Not a valid IPv4 address: " + ipAddress, "MediaPortal Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Log.Debug("WakeUpServer: WOL - Not a valid IPv4 address: {0}", ipAddress); } } } } catch (Exception ex) { Log.Error("WakeUpServer: WOL - Failed GetHostAddress - {0}", ex.Message); } } }
public MediaInfoWrapper(string strFile) { if (!MediaInfoExist()) { return; } using (Settings xmlreader = new MPSettings()) { _DVDenabled = xmlreader.GetValueAsBool("dvdplayer", "mediainfoused", false); _ParseSpeed = xmlreader.GetValueAsString("debug", "MediaInfoParsespeed", "0.3"); // fix delay introduced after 0.7.26: http://sourceforge.net/tracker/?func=detail&aid=3013548&group_id=86862&atid=581181 } bool isTV = Util.Utils.IsLiveTv(strFile); bool isRadio = Util.Utils.IsLiveRadio(strFile); bool isRTSP = Util.Utils.IsRTSP(strFile); //rtsp for live TV and recordings. bool isDVD = Util.Utils.IsDVD(strFile); bool isVideo = Util.Utils.IsVideo(strFile); bool isAVStream = Util.Utils.IsAVStream(strFile); //other AV streams //currently disabled for all tv/radio/streaming video if (isTV || isRadio || isRTSP || isAVStream) { Log.Debug("MediaInfoWrapper: isTv:{0}, isRadio:{1}, isRTSP:{2}, isAVStream:{3}", isTV, isRadio, isRTSP, isAVStream); Log.Debug("MediaInfoWrapper: disabled for this content"); return; } //currently mediainfo is only used for local video related material (if enabled) if ((!isVideo && !isDVD) || (isDVD && !_DVDenabled)) { Log.Debug("MediaInfoWrapper: isVideo:{0}, isDVD:{1}[enabled:{2}]", isVideo, isDVD, _DVDenabled); Log.Debug("MediaInfoWrapper: disabled for this content"); return; } try { _mI = new MediaInfo(); _mI.Option("ParseSpeed", _ParseSpeed); if (Util.VirtualDirectory.IsImageFile(System.IO.Path.GetExtension(strFile))) { strFile = Util.DaemonTools.GetVirtualDrive() + @"\VIDEO_TS\VIDEO_TS.IFO"; } if (strFile.ToLower().EndsWith(".ifo")) { string path = Path.GetDirectoryName(strFile); string mainTitle = GetLargestFileInDirectory(path, "VTS_*1.VOB"); string titleSearch = Path.GetFileName(mainTitle); titleSearch = titleSearch.Substring(0, titleSearch.LastIndexOf('_')) + "*.VOB"; string[] vobs = Directory.GetFiles(path, titleSearch, SearchOption.TopDirectoryOnly); foreach (string vob in vobs) { int vobDuration = 0; _mI.Open(vob); int.TryParse(_mI.Get(StreamKind.General, 0, "Duration"), out vobDuration); _mI.Close(); _videoDuration += vobDuration; } // get all other info from main title's 1st vob strFile = mainTitle; } _mI.Open(strFile); NumberFormatInfo providerNumber = new NumberFormatInfo(); providerNumber.NumberDecimalSeparator = "."; //Video double.TryParse(_mI.Get(StreamKind.Video, 0, "FrameRate"), NumberStyles.AllowDecimalPoint, providerNumber, out _framerate); int.TryParse(_mI.Get(StreamKind.Video, 0, "Width"), out _width); int.TryParse(_mI.Get(StreamKind.Video, 0, "Height"), out _height); _aspectRatio = _mI.Get(StreamKind.Video, 0, "Display AspectRatio") == "4:3" ? "fullscreen" : "widescreen"; _videoCodec = GetFullCodecName(StreamKind.Video); _scanType = _mI.Get(StreamKind.Video, 0, "ScanType").ToLower(); _isInterlaced = _scanType.Contains("interlaced"); _videoResolution = _height < 720 ? "SD" : "HD"; if ((_width == 1280 || _height == 720) && !_isInterlaced) { _videoResolution = "720P"; } if ((_width == 1920 || _height == 1080) && !_isInterlaced) { _videoResolution = "1080P"; } if ((_width == 1920 || _height == 1080) && _isInterlaced) { _videoResolution = "1080I"; } if (_videoDuration == 0) { int.TryParse(_mI.Get(StreamKind.Video, 0, "Duration"), out _videoDuration); } //Audio int iAudioStreams = _mI.Count_Get(StreamKind.Audio); for (int i = 0; i < iAudioStreams; i++) { int intValue; string sChannels = _mI.Get(StreamKind.Audio, i, "Channel(s)").Split(new char[] { '/' })[0].Trim(); if (int.TryParse(sChannels, out intValue) && intValue > _audioChannels) { int.TryParse(_mI.Get(StreamKind.Audio, i, "SamplingRate"), out _audioRate); _audioChannels = intValue; _audioCodec = GetFullCodecName(StreamKind.Audio, i); } } switch (_audioChannels) { case 8: _audioChannelsFriendly = "7.1"; break; case 7: _audioChannelsFriendly = "6.1"; break; case 6: _audioChannelsFriendly = "5.1"; break; case 2: _audioChannelsFriendly = "stereo"; break; case 1: _audioChannelsFriendly = "mono"; break; default: _audioChannelsFriendly = _audioChannels.ToString(); break; } //Detection _hasAudio = _mI.Count_Get(StreamKind.Audio) > 0; _hasVideo = _mI.Count_Get(StreamKind.Video) > 0; //Subtitles _numsubtitles = _mI.Count_Get(StreamKind.Text); if (checkHasExternalSubtitles(strFile)) { _hasSubtitles = true; } else { _hasSubtitles = _numsubtitles > 0; } Log.Info("MediaInfoWrapper.MediaInfoWrapper: DLL Version : {0}", _mI.Option("Info_Version")); Log.Info("MediaInfoWrapper.MediaInfoWrapper: Inspecting media : {0}", strFile); Log.Info("MediaInfoWrapper.MediaInfoWrapper: Parse speed : {0}", _ParseSpeed); //Video Log.Info("MediaInfoWrapper.MediaInfoWrapper: FrameRate : {0}", _framerate); Log.Info("MediaInfoWrapper.MediaInfoWrapper: Width : {0}", _width); Log.Info("MediaInfoWrapper.MediaInfoWrapper: Height : {0}", _height); Log.Info("MediaInfoWrapper.MediaInfoWrapper: AspectRatio : {0}", _aspectRatio); Log.Info("MediaInfoWrapper.MediaInfoWrapper: VideoCodec : {0} [ \"{1}.png\" ]", _videoCodec, Util.Utils.MakeFileName(_videoCodec).ToLower()); Log.Info("MediaInfoWrapper.MediaInfoWrapper: Scan type : {0}", _scanType); Log.Info("MediaInfoWrapper.MediaInfoWrapper: IsInterlaced : {0}", _isInterlaced); Log.Info("MediaInfoWrapper.MediaInfoWrapper: VideoResolution : {0}", _videoResolution); Log.Info("MediaInfoWrapper.MediaInfoWrapper: VideoDuration : {0}", _videoDuration); //Audio Log.Info("MediaInfoWrapper.MediaInfoWrapper: AudioRate : {0}", _audioRate); Log.Info("MediaInfoWrapper.MediaInfoWrapper: AudioChannels : {0} [ \"{1}.png\" ]", _audioChannels, _audioChannelsFriendly); Log.Info("MediaInfoWrapper.MediaInfoWrapper: AudioCodec : {0} [ \"{1}.png\" ]", _audioCodec, Util.Utils.MakeFileName(_audioCodec).ToLower()); //Detection Log.Info("MediaInfoWrapper.MediaInfoWrapper: HasAudio : {0}", _hasAudio); Log.Info("MediaInfoWrapper.MediaInfoWrapper: HasVideo : {0}", _hasVideo); //Subtitles Log.Info("MediaInfoWrapper.MediaInfoWrapper: HasSubtitles : {0}", _hasSubtitles); Log.Info("MediaInfoWrapper.MediaInfoWrapper: NumSubtitles : {0}", _numsubtitles); } catch (Exception) { Log.Error( "MediaInfoWrapper.MediaInfoWrapper: Error occurred while scanning media: '{0}'", strFile); } finally { if (_mI != null) { _mI.Close(); } } }
public static void AddPreferredFilters(IGraphBuilder graphBuilder, IBaseFilter sourceFilter) { using (Settings xmlreader = new MPSettings()) { bool autodecodersettings = xmlreader.GetValueAsBool("movieplayer", "autodecodersettings", false); if (!autodecodersettings) // the user has not chosen automatic graph building by merits { // bool vc1ICodec,vc1Codec,xvidCodec = false; - will come later bool aacCodec = false; bool h264Codec = false; // check the output pins of the splitter for known media types IEnumPins pinEnum = null; if (sourceFilter.EnumPins(out pinEnum) == 0) { int fetched = 0; IPin[] pins = new IPin[1]; while (pinEnum.Next(1, pins, out fetched) == 0 && fetched > 0) { IPin pin = pins[0]; PinDirection pinDirection; if (pin.QueryDirection(out pinDirection) == 0 && pinDirection == PinDirection.Output) { IEnumMediaTypes enumMediaTypesVideo = null; if (pin.EnumMediaTypes(out enumMediaTypesVideo) == 0) { AMMediaType[] mediaTypes = new AMMediaType[1]; int typesFetched; while (enumMediaTypesVideo.Next(1, mediaTypes, out typesFetched) == 0 && typesFetched > 0) { if (mediaTypes[0].majorType == MediaType.Video && (mediaTypes[0].subType == MediaSubType.H264 || mediaTypes[0].subType == MEDIASUBTYPE_AVC1)) { Log.Instance.Info("found H264 video on output pin"); h264Codec = true; } else if (mediaTypes[0].majorType == MediaType.Audio && mediaTypes[0].subType == MediaSubType.LATMAAC) { Log.Instance.Info("found AAC audio on output pin"); aacCodec = true; } } DirectShowUtil.ReleaseComObject(enumMediaTypesVideo); } } DirectShowUtil.ReleaseComObject(pin); } DirectShowUtil.ReleaseComObject(pinEnum); } // add filters for found media types to the graph as configured in MP if (h264Codec) { DirectShowUtil.ReleaseComObject( DirectShowUtil.AddFilterToGraph(graphBuilder, xmlreader.GetValueAsString("movieplayer", "h264videocodec", ""))); } else { DirectShowUtil.ReleaseComObject( DirectShowUtil.AddFilterToGraph(graphBuilder, xmlreader.GetValueAsString("movieplayer", "mpeg2videocodec", ""))); } if (aacCodec) { DirectShowUtil.ReleaseComObject( DirectShowUtil.AddFilterToGraph(graphBuilder, xmlreader.GetValueAsString("movieplayer", "aacaudiocodec", ""))); } else { DirectShowUtil.ReleaseComObject( DirectShowUtil.AddFilterToGraph(graphBuilder, xmlreader.GetValueAsString("movieplayer", "mpeg2audiocodec", ""))); } } } }
public static void SetRefreshRateBasedOnFPS(double fps, string strFile, MediaType type) { int currentScreenNr = GUIGraphicsContext.currentScreenNumber; double currentRR = 0; if ((currentScreenNr == -1) || (Manager.Adapters.Count <= currentScreenNr)) { Log.Info( "RefreshRateChanger.SetRefreshRateBasedOnFPS: could not aquire current screen number, or current screen number bigger than number of adapters available."); } else { currentRR = Manager.Adapters[currentScreenNr].CurrentDisplayMode.RefreshRate; } _refreshrateChangeCurrentRR = currentRR; bool enabled = false; bool deviceReset = false; bool force_refresh_rate = false; using (Settings xmlreader = new MPSettings()) { enabled = xmlreader.GetValueAsBool("general", "autochangerefreshrate", false); if (!enabled) { Log.Info("RefreshRateChanger.SetRefreshRateBasedOnFPS: 'auto refreshrate changer' disabled"); return; } force_refresh_rate = xmlreader.GetValueAsBool("general", "force_refresh_rate", false); deviceReset = xmlreader.GetValueAsBool("general", "devicereset", false); } double newRR = 0; string newExtCmd = ""; string newRRDescription = ""; FindExtCmdfromSettings(fps, currentRR, deviceReset, out newRR, out newExtCmd, out newRRDescription); if (newRR > 0 && (currentRR != newRR || force_refresh_rate)) //run external command in order to change refresh rate. { Log.Info("RefreshRateChanger.SetRefreshRateBasedOnFPS: current refreshrate is {0}hz - changing it to {1}hz", currentRR, newRR); if (newExtCmd.Length == 0) { Log.Info( "RefreshRateChanger.SetRefreshRateBasedOnFPS: using internal win32 method for changing refreshrate. current is {0}hz, desired is {1}", currentRR, newRR); Win32.CycleRefreshRate((uint)currentScreenNr, newRR); NotifyRefreshRateChanged(newRRDescription, (strFile.Length > 0)); } else if (RunExternalJob(newExtCmd, strFile, type, deviceReset) && newRR != currentRR) { Win32.FixDwm(); NotifyRefreshRateChanged(newRRDescription, (strFile.Length > 0)); } if (GUIGraphicsContext.Vmr9Active) { Log.Info("RefreshRateChanger.SetRefreshRateBasedOnFPS: dynamic refresh rate change - notify video renderer"); VMR9Util.g_vmr9.UpdateEVRDisplayFPS(); } } else { if (newRR == 0) { Log.Info( "RefreshRateChanger.SetRefreshRateBasedOnFPS: could not find a matching refreshrate based on {0} fps (check config)", fps); } else { Log.Info( "RefreshRateChanger.SetRefreshRateBasedOnFPS: no refreshrate change required. current is {0}hz, desired is {1}", currentRR, newRR); } } }
public bool LoadSubtitles(IGraphBuilder graphBuilder, string filename) { LoadSettings(); MpcSubtitles.SetDefaultStyle(ref this.defStyle, this.overrideASSStyle); if (selectionOff) { MpcSubtitles.SetShowForcedOnly(false); } else { MpcSubtitles.SetShowForcedOnly(!this.autoShow); } //remove DirectVobSub DirectVobSubUtil.RemoveFromGraph(graphBuilder); { //remove InternalScriptRenderer as it takes subtitle pin IBaseFilter isr = null; DirectShowUtil.FindFilterByClassID(graphBuilder, ClassId.InternalScriptRenderer, out isr); if (isr != null) { graphBuilder.RemoveFilter(isr); DirectShowUtil.ReleaseComObject(isr); } } FFDShowEngine.DisableFFDShowSubtitles(graphBuilder); Size size = new Size(GUIGraphicsContext.Width, GUIGraphicsContext.Height); // Get Default Language from MP Setting and parse it to MPC-HC Engine (needed for forced track) string defaultLanguageCulture = "EN"; string localizedCINameSub = "EN"; int lcidCI = 0; using (Settings xmlreader = new MPSettings()) { try { if (g_Player.IsVideo && (g_Player.CurrentFile.ToUpperInvariant().Contains(@"\BDMV\INDEX.BDMV"))) { localizedCINameSub = (xmlreader.GetValueAsString("bdplayer", "subtitlelanguage", "English")); foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.NeutralCultures)) { if (ci.EnglishName == localizedCINameSub) { lcidCI = ci.TextInfo.LCID;; } } Log.Info("MpcEngine: Subtitle Blu-ray Player CultureInfo {0}", localizedCINameSub); } else { CultureInfo ci = new CultureInfo(xmlreader.GetValueAsString("subtitles", "language", defaultLanguageCulture)); lcidCI = ci.TextInfo.LCID; Log.Info("MpcEngine: Subtitle VideoPlayer CultureInfo {0}", ci); } } catch (Exception ex) { CultureInfo ci = new CultureInfo(defaultLanguageCulture); lcidCI = ci.TextInfo.LCID; Log.Error( "MpcEngine: SelectSubtitleLanguage - unable to build CultureInfo, make sure MediaPortal.xml is not corrupted! - {0}", ex); } } return(MpcSubtitles.LoadSubtitles( DirectShowUtil.GetUnmanagedDevice(GUIGraphicsContext.DX9Device), size, filename, graphBuilder, subPaths, lcidCI)); }
/// <summary> /// Do we have all required fields filled /// </summary> /// <returns></returns> private bool AllFilledIn() { int MaximumShares = 250; //Do we have 1 or more music,picture,video shares? using (Settings xmlreader = new MPSettings()) { string playlistFolder = xmlreader.GetValueAsString("music", "playlists", ""); if (playlistFolder == string.Empty) { MessageBox.Show("No music playlist folder specified", "MediaPortal Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } playlistFolder = xmlreader.GetValueAsString("movies", "playlists", ""); if (playlistFolder == string.Empty) { MessageBox.Show("No video playlist folder specified", "MediaPortal Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } bool added = false; for (int index = 0; index < MaximumShares; index++) { string sharePath = String.Format("sharepath{0}", index); string sharePathData = xmlreader.GetValueAsString("music", sharePath, ""); if (!Util.Utils.IsDVD(sharePathData) && sharePathData != string.Empty) { added = true; break; } } if (!added) { MessageBox.Show("No music folders specified", "MediaPortal Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } added = false; for (int index = 0; index < MaximumShares; index++) { string sharePath = String.Format("sharepath{0}", index); string shareNameData = xmlreader.GetValueAsString("movies", sharePath, ""); if (!Util.Utils.IsDVD(shareNameData) && shareNameData != string.Empty) { added = true; break; } } if (!added) { MessageBox.Show("No video folders specified", "MediaPortal Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } added = false; for (int index = 0; index < MaximumShares; index++) { string sharePath = String.Format("sharepath{0}", index); string shareNameData = xmlreader.GetValueAsString("pictures", sharePath, ""); if (!Util.Utils.IsDVD(shareNameData) && shareNameData != string.Empty) { added = true; break; } } if (!added) { MessageBox.Show("No pictures folders specified", "MediaPortal Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } // is last.fm enabled but audioscrobbler is not? bool audioScrobblerOn = xmlreader.GetValueAsBool("plugins", "Audioscrobbler", false); bool lastFmOn = xmlreader.GetValueAsBool("plugins", "Last.fm Radio", false); if (lastFmOn && !audioScrobblerOn) { MessageBox.Show("Please configure the Audioscrobbler plugin to use Last.fm radio", "MediaPortal Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (audioScrobblerOn) { // Does Audioscrobbler have a user but no password (due to DB upgrades, restores, etc) string asuser = xmlreader.GetValueAsString("audioscrobbler", "user", ""); if (!string.IsNullOrEmpty(asuser)) { Music.Database.MusicDatabase mdb = Music.Database.MusicDatabase.Instance; string AsPass = mdb.AddScrobbleUserPassword(Convert.ToString(mdb.AddScrobbleUser(asuser)), ""); if (string.IsNullOrEmpty(AsPass)) { MessageBox.Show("No password specified for current Audioscrobbler user", "MediaPortal Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } } } return(true); }
public override void SaveSettings() { using (Settings xmlwriter = new MPSettings()) { #region Player Settings xmlwriter.SetValue("audioplayer", "playerId", audioPlayerComboBox.SelectedIndex); xmlwriter.SetValue("audioplayer", "sounddevice", (soundDeviceComboBox.SelectedItem as SoundDeviceItem).Name); xmlwriter.SetValue("audioplayer", "sounddeviceid", (soundDeviceComboBox.SelectedItem as SoundDeviceItem).ID); xmlwriter.SetValue("audioplayer", "crossfade", trackBarCrossfade.Value); xmlwriter.SetValue("audioplayer", "buffering", trackBarBuffering.Value); xmlwriter.SetValueAsBool("audioplayer", "useSkipSteps", UseSkipStepsCheckBox.Checked); xmlwriter.SetValueAsBool("audioplayer", "fadeOnStartStop", FadeOnStartStopChkbox.Checked); xmlwriter.SetValueAsBool("audioplayer", "gaplessPlayback", GaplessPlaybackChkBox.Checked); xmlwriter.SetValueAsBool("audioplayer", "enableReplayGain", EnableReplayGainChkBox.Checked); xmlwriter.SetValueAsBool("audioplayer", "enableAlbumReplayGain", EnableAlbumReplayGainChkBox.Checked); xmlwriter.SetValue("audioplayer", "streamOutputLevel", StreamOutputLevelNud.Value); xmlwriter.SetValue("audioplayer", "asiobalance", hScrollBarBalance.Value); xmlwriter.SetValueAsBool("audioplayer", "wasapiExclusive", WasapiExclusiveModeCkBox.Checked); xmlwriter.SetValue("audioplayer", "wasApiSpeakers", WasApiSpeakersCombo.SelectedIndex); xmlwriter.SetValue("audioplayer", "upMixMono", cbUpmixMono.SelectedIndex); xmlwriter.SetValue("audioplayer", "upMixStereo", cbUpmixStereo.SelectedIndex); xmlwriter.SetValue("audioplayer", "upMixQuadro", cbUpmixQuadro.SelectedIndex); xmlwriter.SetValue("audioplayer", "upMixFiveDotOne", cbUpmixFiveDotOne.SelectedIndex); xmlwriter.SetValueAsBool("audioplayer", "enableResume", chkEnableResumeSupport.Checked); xmlwriter.SetValue("audioplayer", "resumeAfter", tbResumeAfter.Text); xmlwriter.SetValue("audioplayer", "resumeSelect", cbResumeSelect.Text); xmlwriter.SetValue("audioplayer", "resumeSearch", tbResumeSearchValue.Text); #endregion #region Playlist Settings xmlwriter.SetValue("music", "playlists", playlistFolderTextBox.Text); xmlwriter.SetValueAsBool("musicfiles", "repeat", repeatPlaylistCheckBox.Checked); xmlwriter.SetValueAsBool("musicfiles", "autoshuffle", autoShuffleCheckBox.Checked); xmlwriter.SetValueAsBool("musicfiles", "savePlaylistOnExit", SavePlaylistOnExitChkBox.Checked); xmlwriter.SetValueAsBool("musicfiles", "resumePlaylistOnMusicEnter", ResumePlaylistChkBox.Checked); xmlwriter.SetValueAsBool("musicfiles", "playlistIsCurrent", PlaylistCurrentCheckBox.Checked); xmlwriter.SetValueAsBool("musicfiles", "savePlaylistUTF8", PlayListUTF8CheckBox.Checked); //Play behaviour xmlwriter.SetValue("musicfiles", "selectOption", cmbSelectOption.Text.ToLowerInvariant()); xmlwriter.SetValueAsBool("musicfiles", "addall", chkAddAllTracks.Checked); #endregion #region Misc Settings string playNowJumpTo = string.Empty; switch (PlayNowJumpToCmbBox.Text) { case JumpToOption0: playNowJumpTo = JumpToValue0; break; case JumpToOption1: playNowJumpTo = JumpToValue1; break; case JumpToOption2: playNowJumpTo = JumpToValue2; break; case JumpToOption3: playNowJumpTo = JumpToValue3; break; case JumpToOption4: playNowJumpTo = JumpToValue4; break; case JumpToOption5: playNowJumpTo = JumpToValue5; break; case JumpToOption6: playNowJumpTo = JumpToValue6; break; default: playNowJumpTo = JumpToValue0; break; } xmlwriter.SetValue("music", "playnowjumpto", playNowJumpTo); xmlwriter.SetValueAsBool("musicmisc", "lookupSimilarTracks", !chkDisableSimilarTrackLookups.Checked); string vuMeter = VUMeterValue0; if (radioButtonVUAnalog.Checked) { vuMeter = VUMeterValue1; } else if (radioButtonVULed.Checked) { vuMeter = VUMeterValue2; } xmlwriter.SetValue("musicmisc", "vumeter", vuMeter); #endregion } }
/// <summary> /// If the url to be played can be buffered before starting playback, this function /// starts building a graph by adding the preferred video and audio render to it. /// This needs to be called on the MpMain Thread. /// </summary> /// <returns>true, if the url can be buffered (a graph was started), false if it can't be and null if an error occured building the graph</returns> public bool?PrepareGraph() { string sourceFilterName = GetSourceFilterName(m_strCurrentFile); if (!string.IsNullOrEmpty(sourceFilterName)) { graphBuilder = (IGraphBuilder) new FilterGraph(); _rotEntry = new DsROTEntry((IFilterGraph)graphBuilder); basicVideo = graphBuilder as IBasicVideo2; Vmr9 = new VMR9Util(); Vmr9.AddVMR9(graphBuilder); Vmr9.Enable(false); // set VMR9 back to NOT Active -> otherwise GUI is not refreshed while graph is building GUIGraphicsContext.Vmr9Active = false; // add the audio renderer using (Settings settings = new MPSettings()) { string audiorenderer = settings.GetValueAsString("movieplayer", "audiorenderer", "Default DirectSound Device"); DirectShowUtil.AddAudioRendererToGraph(graphBuilder, audiorenderer, false); } // set fields for playback mediaCtrl = (IMediaControl)graphBuilder; mediaEvt = (IMediaEventEx)graphBuilder; mediaSeek = (IMediaSeeking)graphBuilder; mediaPos = (IMediaPosition)graphBuilder; basicAudio = (IBasicAudio)graphBuilder; videoWin = (IVideoWindow)graphBuilder; // add the source filter IBaseFilter sourceFilter = null; try { if (sourceFilterName == OnlineVideos.MPUrlSourceFilter.Downloader.FilterName) { sourceFilter = FilterFromFile.LoadFilterFromDll("MPUrlSourceSplitter\\MPUrlSourceSplitter.ax", new Guid(OnlineVideos.MPUrlSourceFilter.Downloader.FilterCLSID), true); if (sourceFilter != null) { Marshal.ThrowExceptionForHR(graphBuilder.AddFilter(sourceFilter, OnlineVideos.MPUrlSourceFilter.Downloader.FilterName)); } } if (sourceFilter == null) { sourceFilter = DirectShowUtil.AddFilterToGraph(graphBuilder, sourceFilterName); } } catch (Exception ex) { Log.Instance.Warn("Error adding '{0}' filter to graph: {1}", sourceFilterName, ex.Message); return(null); } finally { if (sourceFilter != null) { DirectShowUtil.ReleaseComObject(sourceFilter, 2000); } } return(true); } else { return(false); } }
private void LoadSettings() { using (Settings xmlreader = new MPSettings()) { btnEnableDynamicRefreshRate.Selected = xmlreader.GetValueAsBool("general", "autochangerefreshrate", false); btnNotify.Selected = xmlreader.GetValueAsBool("general", "notify_on_refreshrate", false); btnUseDefaultRefreshRate.Selected = xmlreader.GetValueAsBool("general", "use_default_hz", false); btnUseDeviceReset.Selected = xmlreader.GetValueAsBool("general", "devicereset", false); btnForceRefreshRateChange.Selected = xmlreader.GetValueAsBool("general", "force_refresh_rate", false); _sDefaultHz = xmlreader.GetValueAsString("general", "default_hz", ""); _sDefaultHzName = xmlreader.GetValueAsString("general", "default_hz_name", ""); String[] p = null; _defaultHzIndex = -1; _defaultHz.Clear(); for (int i = 1; i < 100; i++) { string extCmd = xmlreader.GetValueAsString("general", "refreshrate0" + Convert.ToString(i) + "_ext", ""); string name = xmlreader.GetValueAsString("general", "refreshrate0" + Convert.ToString(i) + "_name", ""); if (string.IsNullOrEmpty(name)) { continue; } string fps = xmlreader.GetValueAsString("general", name + "_fps", ""); string hz = xmlreader.GetValueAsString("general", name + "_hz", ""); p = new String[4]; p[0] = name; p[1] = fps; // fps p[2] = hz; //hz p[3] = extCmd; //action RefreshRateData refreshRateData = new RefreshRateData(name, fps, hz, extCmd); GUIListItem item = new GUIListItem(); item.Label = p[0]; item.AlbumInfoTag = refreshRateData; item.OnItemSelected += OnItemSelected; lcRefreshRatesList.Add(item); _defaultHz.Add(p[0]); if (_sDefaultHz == hz && _sDefaultHzName != null && _sDefaultHzName == name) { _defaultHzIndex = i - 1; } } // Select Default Hz value if (_defaultHzIndex == -1) { if (string.IsNullOrEmpty(_sDefaultHz)) { _sDefaultHz = _sDefaultHzValue; } for (int i = 1; i < 100; i++) { string name = RefreshRateData(lcRefreshRatesList.ListItems[i]).Name; string rate = RefreshRateData(lcRefreshRatesList.ListItems[i]).Refreshrate; if (rate == _sDefaultHz && _sDefaultHzNameValue == name) { _sDefaultHzName = RefreshRateData(lcRefreshRatesList.ListItems[i]).Name; _defaultHzIndex = i; SetProperties(); break; } } } if (lcRefreshRatesList.Count == 0) { InsertDefaultValues(); } lcRefreshRatesList.SelectedListItemIndex = 0; } }
public void PackSkinGraphics(string skinName) { Cleanup(); if (LoadPackedSkin(skinName)) { return; } _packedTextures = new List <PackedTexture>(); List <string> files = new List <string>(); using (Settings xmlreader = new MPSettings()) { if (xmlreader.GetValueAsBool("debug", "packSkinGfx", true)) { string[] skinFiles = Directory.GetFiles(String.Format(@"{0}\media", skinName), "*.png"); files.AddRange(skinFiles); } // workaround for uncommon rendering implementation of volume osd - it won't show up without packedtextures else { string[] skinFiles = Directory.GetFiles(String.Format(@"{0}\media", skinName), "volume*.png"); string[] forcedCacheFiles = Directory.GetFiles(String.Format(@"{0}\media", skinName), "cached*.png"); files.Add(String.Format(@"{0}\media\Thumb_Mask.png", skinName)); files.AddRange(skinFiles); files.AddRange(forcedCacheFiles); } if (xmlreader.GetValueAsBool("debug", "packLogoGfx", true)) { string[] tvLogos = Directory.GetFiles(Config.GetSubFolder(Config.Dir.Thumbs, @"tv\logos"), "*.png", SearchOption.AllDirectories); string[] radioLogos = Directory.GetFiles(Config.GetSubFolder(Config.Dir.Thumbs, "Radio"), "*.png", SearchOption.AllDirectories); files.AddRange(tvLogos); files.AddRange(radioLogos); } if (xmlreader.GetValueAsBool("debug", "packPluginGfx", true)) { string[] weatherFiles = Directory.GetFiles(String.Format(@"{0}\media\weather", skinName), "*.png"); string[] tetrisFiles = Directory.GetFiles(String.Format(@"{0}\media\tetris", skinName), "*.png"); files.AddRange(weatherFiles); files.AddRange(tetrisFiles); } } // Determine maximum texture dimensions try { Caps d3dcaps = GUIGraphicsContext.DX9Device.DeviceCaps; _maxTextureWidth = d3dcaps.MaxTextureWidth; _maxTextureHeight = d3dcaps.MaxTextureHeight; Log.Info("TexturePacker: D3D device does support {0}x{1} textures", _maxTextureWidth, _maxTextureHeight); } catch (Exception) { _maxTextureWidth = 2048; _maxTextureHeight = 2048; } if (_maxTextureWidth > MAXTEXTUREDIMENSION) { _maxTextureWidth = MAXTEXTUREDIMENSION; } if (_maxTextureHeight > MAXTEXTUREDIMENSION) { _maxTextureHeight = MAXTEXTUREDIMENSION; } Log.Info("TexturePacker: using {0}x{1} as packed textures limit", _maxTextureWidth, _maxTextureHeight); Log.Info("TexturePacker: using {0}x{1} as single texture limit", _maxTextureWidth / 2, _maxTextureHeight / 2); while (true) { bool ImagesLeft = false; PackedTexture bigOne = new PackedTexture(); bigOne.root = new PackedTextureNode(); bigOne.texture = null; bigOne.textureNo = -1; using (Bitmap rootImage = new Bitmap(_maxTextureWidth, _maxTextureHeight)) { bigOne.root.Rect = new Rectangle(0, 0, _maxTextureWidth, _maxTextureHeight); for (int i = 0; i < files.Count; ++i) { if (files[i] == null) { continue; } files[i] = files[i].ToLowerInvariant(); if (files[i] != string.Empty) { // Ignore files not needed for MP if (files[i].IndexOf("preview.") >= 0) { files[i] = string.Empty; continue; } bool dontAdd; if (AddBitmap(bigOne.root, rootImage, files[i], out dontAdd)) { files[i] = string.Empty; } else { if (dontAdd) { files[i] = string.Empty; } else { ImagesLeft = true; } } } } if (!Directory.Exists(GUIGraphicsContext.SkinCacheFolder)) { Directory.CreateDirectory(GUIGraphicsContext.SkinCacheFolder); } string fileName = String.Format(@"{0}\packedgfx2{1}.png", GUIGraphicsContext.SkinCacheFolder, _packedTextures.Count); rootImage.Save(fileName, ImageFormat.Png); Log.Debug("TexturePacker: Cache root {0} filled", fileName); } _packedTextures.Add(bigOne); if (!ImagesLeft) { break; } } SavePackedSkin(skinName); }