From 0c6e486eb060e8ed60552c7b719bd649e4f503ca Mon Sep 17 00:00:00 2001 From: stax76 Date: Sun, 5 Jun 2022 06:40:42 +0200 Subject: [PATCH] #435 Fix mpv options not working in case of existing same line comments --- docs/Changelog.md | 1 + src/Misc/Player.cs | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index f4547fb..ab15d51 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -17,6 +17,7 @@ is created with defaults for osc and console. - Support mpv idle property, see manual for remarks. - Fix external audio and subtitle files not shown in all use cases. +- Fix mpv options not working in case of existing same line comments. - Fix crash choosing Matroska edition in the menu. - Fix auto-play and auto-load-folder not working with user scripts. - Fix slow startup using `osd-scale-by-window=no`. diff --git a/src/Misc/Player.cs b/src/Misc/Player.cs index da5e99d..947da64 100644 --- a/src/Misc/Player.cs +++ b/src/Misc/Player.cs @@ -359,7 +359,17 @@ namespace mpvnet if (File.Exists(ConfPath)) foreach (var i in File.ReadAllLines(ConfPath)) if (i.Contains("=") && !i.TrimStart().StartsWith("#")) - _Conf[i.Substring(0, i.IndexOf("=")).Trim()] = i.Substring(i.IndexOf("=") + 1).Trim(); + { + string key = i.Substring(0, i.IndexOf("=")).Trim(); + string value = i.Substring(i.IndexOf("=") + 1).Trim(); + + if (value.Contains("#") && !value.StartsWith("#") && + !value.StartsWith("'#") && !value.StartsWith("\"#")) + + value = value.Substring(0, value.IndexOf("#")).Trim(); + + _Conf[key] = value; + } foreach (var i in _Conf) ProcessProperty(i.Key, i.Value);