diff --git a/FoxTunes.Scripting.JS/Resources/utils.js b/FoxTunes.Scripting.JS/Resources/utils.js
index aec2bea5c..ed74664bc 100644
--- a/FoxTunes.Scripting.JS/Resources/utils.js
+++ b/FoxTunes.Scripting.JS/Resources/utils.js
@@ -104,4 +104,32 @@ function content(value) {
return JSON.parse(value.data);
}
return value.data;
-}
\ No newline at end of file
+}
+
+function bitrate(sampleRate, depth, channels) {
+ sampleRate = parseInt(sampleRate ?? "44100");
+ depth = parseInt(depth ?? "16");
+ channels = parseInt(channels ?? "2");
+ return parseInt((sampleRate * depth * channels) / 1000) + " kbps";
+}
+
+function samplerate(sampleRate) {
+ return (sampleRate ?? 44100) + " Hz";
+}
+
+function channeldescription(channels) {
+ switch (parseInt(channels ?? 2))
+ {
+ case 1:
+ return "mono";
+ case 2:
+ return "stereo";
+ case 4:
+ return "quad";
+ case 6:
+ return "5.1";
+ case 8:
+ return "7.1";
+ }
+ return channels + " channels";
+}
diff --git a/FoxTunes.UI.Windows.Layout/Resources/Main_5.xml b/FoxTunes.UI.Windows.Layout/Resources/Main_5.xml
index e1ce3624f..5250671e0 100644
--- a/FoxTunes.UI.Windows.Layout/Resources/Main_5.xml
+++ b/FoxTunes.UI.Windows.Layout/Resources/Main_5.xml
@@ -1,102 +1,110 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/FoxTunes.UI.Windows.MiniPlayer/Behaviours/MiniPlayerBehaviourConfiguration.cs b/FoxTunes.UI.Windows.MiniPlayer/Behaviours/MiniPlayerBehaviourConfiguration.cs
index 2fbb30157..cfacbce0c 100644
--- a/FoxTunes.UI.Windows.MiniPlayer/Behaviours/MiniPlayerBehaviourConfiguration.cs
+++ b/FoxTunes.UI.Windows.MiniPlayer/Behaviours/MiniPlayerBehaviourConfiguration.cs
@@ -20,10 +20,6 @@ public static class MiniPlayerBehaviourConfiguration
public static IEnumerable GetConfigurationSections()
{
yield return new ConfigurationSection(SECTION, Strings.MiniPlayerBehaviourConfiguration_Section)
- .WithElement(
- new TextConfigurationElement(NOW_PLAYING_SCRIPT_ELEMENT, Strings.MiniPlayerBehaviourConfiguration_NowPlayingScript, path: Strings.MiniPlayerBehaviourConfiguration_Advanced)
- .WithValue(Resources.NowPlaying)
- .WithFlags(ConfigurationElementFlags.MultiLine | ConfigurationElementFlags.Script))
.WithElement(
new TextConfigurationElement(PLAYLIST_SCRIPT_ELEMENT, Strings.MiniPlayerBehaviourConfiguration_PlaylistScript, path: Strings.MiniPlayerBehaviourConfiguration_Advanced)
.WithValue(Resources.Playlist)
diff --git a/FoxTunes.UI.Windows.MiniPlayer/NowPlaying.xaml.cs b/FoxTunes.UI.Windows.MiniPlayer/NowPlaying.xaml.cs
index 17b52a370..e3ffb8305 100644
--- a/FoxTunes.UI.Windows.MiniPlayer/NowPlaying.xaml.cs
+++ b/FoxTunes.UI.Windows.MiniPlayer/NowPlaying.xaml.cs
@@ -1,4 +1,5 @@
-using System.Windows.Controls;
+using System.Collections.Generic;
+using System.Threading.Tasks;
namespace FoxTunes
{
@@ -8,9 +9,32 @@ namespace FoxTunes
[UIComponent("CFF16494-CB86-4483-99C7-07E496FE894A", role: UIComponentRole.Info)]
public partial class NowPlaying : ConfigurableUIComponentBase
{
+ public const string CATEGORY = "C0803688-E230-4DFF-AFCB-931B3AA5BE6D";
+
public NowPlaying()
{
this.InitializeComponent();
}
+
+ public override IEnumerable InvocationCategories
+ {
+ get
+ {
+ yield return CATEGORY;
+ }
+ }
+
+ public override IEnumerable GetConfigurationSections()
+ {
+ return NowPlayingConfiguration.GetConfigurationSections();
+ }
+
+ protected override Task ShowSettings()
+ {
+ return this.ShowSettings(
+ Strings.NowPlaying_Name,
+ NowPlayingConfiguration.SECTION
+ );
+ }
}
}
diff --git a/FoxTunes.UI.Windows.MiniPlayer/NowPlayingConfiguration.cs b/FoxTunes.UI.Windows.MiniPlayer/NowPlayingConfiguration.cs
index b15f5d57f..7e50c57a2 100644
--- a/FoxTunes.UI.Windows.MiniPlayer/NowPlayingConfiguration.cs
+++ b/FoxTunes.UI.Windows.MiniPlayer/NowPlayingConfiguration.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
+using System.Collections.Generic;
namespace FoxTunes
{
@@ -10,5 +7,15 @@ public static class NowPlayingConfiguration
public const string SECTION = "A9F63A1C-16F8-4F68-8E49-3C4C62172FFA";
public const string NOW_PLAYING_SCRIPT_ELEMENT = "BBBB78F3-B32F-4A8C-B566-9A8B39A896C7";
+
+ public static IEnumerable GetConfigurationSections()
+ {
+ yield return new ConfigurationSection(SECTION, Strings.NowPlaying_Name)
+ .WithElement(
+ new TextConfigurationElement(NOW_PLAYING_SCRIPT_ELEMENT, Strings.MiniPlayerBehaviourConfiguration_NowPlayingScript, path: Strings.MiniPlayerBehaviourConfiguration_Advanced)
+ .WithValue(Resources.NowPlaying)
+ .WithFlags(ConfigurationElementFlags.MultiLine | ConfigurationElementFlags.Script)
+ );
+ }
}
}
diff --git a/FoxTunes.UI.Windows.MiniPlayer/ViewModel/NowPlaying.cs b/FoxTunes.UI.Windows.MiniPlayer/ViewModel/NowPlaying.cs
index 0cac8419d..7c3b80eb0 100644
--- a/FoxTunes.UI.Windows.MiniPlayer/ViewModel/NowPlaying.cs
+++ b/FoxTunes.UI.Windows.MiniPlayer/ViewModel/NowPlaying.cs
@@ -6,7 +6,7 @@
namespace FoxTunes.ViewModel
{
- public class NowPlaying : ViewModelBase
+ public class NowPlaying : ViewModelBase, IConfigurationTarget
{
public IPlaybackManager PlaybackManager { get; private set; }
@@ -14,7 +14,47 @@ public class NowPlaying : ViewModelBase
public IScriptingContext ScriptingContext { get; private set; }
- public IConfiguration Configuration { get; private set; }
+ private IConfiguration _Configuration { get; set; }
+
+ public IConfiguration Configuration
+ {
+ get
+ {
+ return this._Configuration;
+ }
+ set
+ {
+ this._Configuration = value;
+ this.OnConfigurationChanged();
+ }
+ }
+
+ protected virtual void OnConfigurationChanged()
+ {
+ if (this.Configuration != null)
+ {
+ this.Configuration.GetElement(
+ NowPlayingConfiguration.SECTION,
+ NowPlayingConfiguration.NOW_PLAYING_SCRIPT_ELEMENT
+ ).ConnectValue(async value => await this.SetScript(value).ConfigureAwait(false));
+ this.MarqueeInterval = this.Configuration.GetElement(
+ WindowsUserInterfaceConfiguration.SECTION,
+ WindowsUserInterfaceConfiguration.MARQUEE_INTERVAL_ELEMENT
+ );
+ this.MarqueeStep = this.Configuration.GetElement(
+ WindowsUserInterfaceConfiguration.SECTION,
+ WindowsUserInterfaceConfiguration.MARQUEE_STEP_ELEMENT
+ );
+ this.Dispatch(this.Refresh);
+ }
+ if (this.ConfigurationChanged != null)
+ {
+ this.ConfigurationChanged(this, EventArgs.Empty);
+ }
+ this.OnPropertyChanged("Configuration");
+ }
+
+ public event EventHandler ConfigurationChanged;
private IntegerConfigurationElement _MarqueeInterval { get; set; }
@@ -181,20 +221,6 @@ protected override void InitializeComponent(ICore core)
this.PlaybackManager.CurrentStreamChanged += this.OnCurrentStreamChanged;
this.ScriptingRuntime = core.Components.ScriptingRuntime;
this.ScriptingContext = this.ScriptingRuntime.CreateContext();
- this.Configuration = core.Components.Configuration;
- this.Configuration.GetElement(
- MiniPlayerBehaviourConfiguration.SECTION,
- MiniPlayerBehaviourConfiguration.NOW_PLAYING_SCRIPT_ELEMENT
- ).ConnectValue(async value => await this.SetScript(value).ConfigureAwait(false));
- this.MarqueeInterval = this.Configuration.GetElement(
- WindowsUserInterfaceConfiguration.SECTION,
- WindowsUserInterfaceConfiguration.MARQUEE_INTERVAL_ELEMENT
- );
- this.MarqueeStep = this.Configuration.GetElement(
- WindowsUserInterfaceConfiguration.SECTION,
- WindowsUserInterfaceConfiguration.MARQUEE_STEP_ELEMENT
- );
- this.Dispatch(this.Refresh);
base.InitializeComponent(core);
}