Skip to content

Commit 75ad388

Browse files
committed
Persistent volume between media changes
Performance improvements Version upgraded to 1.7.2.2
1 parent 08342ec commit 75ad388

File tree

6 files changed

+36
-9
lines changed

6 files changed

+36
-9
lines changed

QuickViewFile/Controls/VideoPlayerControl.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,21 @@
3939
</StatusBar.ItemsPanel>
4040
<StatusBarItem Grid.Column="0">
4141
<Button Name="PlayButton" Command="MediaCommands.Play" Focusable="False">
42-
<TextBlock Text="⏵︎" FontSize="16" FontWeight="Bold" />
42+
<TextBlock Text="⏵︎" FontSize="12" FontWeight="Bold" />
4343
</Button>
4444
</StatusBarItem>
4545
<StatusBarItem Grid.Column="1">
4646
<Button Name="PauseButton" Command="MediaCommands.Pause" Focusable="False">
47-
<TextBlock Text="❚❚" FontSize="16" FontWeight="Bold" />
47+
<TextBlock Text="❚❚" FontSize="12" FontWeight="Bold" />
4848
</Button>
4949
</StatusBarItem>
5050
<StatusBarItem Grid.Column="2">
5151
<Button Name="StopButton" Command="MediaCommands.Stop" Focusable="False">
52-
<TextBlock Text="" FontSize="16" FontWeight="Bold" />
52+
<TextBlock Text="" FontSize="12" FontWeight="Bold" />
5353
</Button>
5454
</StatusBarItem>
5555
<StatusBarItem Grid.Column="3">
56-
<TextBlock Name="lblProgressStatus" FontSize="16" FontWeight="Bold">00:00:00</TextBlock>
56+
<TextBlock Name="lblProgressStatus" FontSize="12" FontWeight="Bold">00:00:00</TextBlock>
5757
</StatusBarItem>
5858
<StatusBarItem Grid.Column="4">
5959
<TextBlock Name="fullTime" FontSize="16" FontWeight="Bold">00:00:00</TextBlock>

QuickViewFile/Controls/VideoPlayerControl.xaml.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
using System.Windows;
1+
using QuickViewFile.Helpers;
2+
using QuickViewFile.Models;
3+
using System.Windows;
24
using System.Windows.Controls;
35
using System.Windows.Controls.Primitives;
46
using System.Windows.Input;
7+
using System.Windows.Media.Effects;
58
using System.Windows.Threading;
69

710
namespace QuickViewFile.Controls
@@ -55,9 +58,16 @@ public void StartPlaying(string filePath)
5558
videoInWindowPlayer.Play();
5659
isVideoPaused = false;
5760
mediaPlayerIsPlaying = true;
58-
videoInWindowPlayer.Volume = 1;
59-
//videoInWindowPlayer.Height = _config.VideoHeigth;
60-
//videoInWindowPlayer.RenderSize = new Size(_config.VideoWidth, _config.VideoHeigth);
61+
double initialVolume = ConfigHelper.GetVolume();
62+
if (initialVolume < 0 || initialVolume > 1)
63+
{
64+
initialVolume = 0.5;
65+
}
66+
else
67+
{
68+
videoInWindowPlayer.Volume = initialVolume;
69+
}
70+
6171
}
6272

6373
private void timer_Tick(object sender, EventArgs e)
@@ -142,6 +152,7 @@ private void sliProgress_ValueChanged(object sender, RoutedPropertyChangedEventA
142152
private void Grid_MouseWheel(object sender, MouseWheelEventArgs e)
143153
{
144154
videoInWindowPlayer.Volume += (e.Delta > 0) ? 0.1 : -0.1;
155+
ConfigHelper.SetVolume(videoInWindowPlayer.Volume);
145156
}
146157

147158
private void PlayOrPauseMedia()
@@ -189,10 +200,12 @@ public void HandleKey(Key key)
189200
else if (key == Key.Add)
190201
{
191202
videoInWindowPlayer.Volume += 0.1;
203+
ConfigHelper.SetVolume(videoInWindowPlayer.Volume);
192204
}
193205
else if (key == Key.Subtract)
194206
{
195207
videoInWindowPlayer.Volume -= 0.1;
208+
ConfigHelper.SetVolume(videoInWindowPlayer.Volume);
196209
}
197210
else if (key == Key.Left)
198211
{

QuickViewFile/Helpers/ConfigHelper.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public static void SaveConfig(ConfigModel config)
4949
key.SetValue(nameof(ConfigModel.ShadowDepth), config.ShadowDepth);
5050
key.SetValue(nameof(ConfigModel.ShadowOpacity), config.ShadowOpacity);
5151
key.SetValue(nameof(ConfigModel.ShadowBlur), config.ShadowBlur);
52+
key.SetValue(nameof(ConfigModel.Volume), config.Volume);
5253
}
5354
catch (Exception ex)
5455
{
@@ -97,6 +98,7 @@ public static ConfigModel LoadConfig()
9798
config.ShadowDepth = double.Parse((string)key.GetValue(nameof(ConfigModel.ShadowDepth).ToString(), config.ShadowDepth));
9899
config.ShadowOpacity = double.Parse((string)key.GetValue(nameof(ConfigModel.ShadowOpacity).ToString(), config.ShadowOpacity));
99100
config.ShadowBlur = double.Parse((string)key.GetValue(nameof(ConfigModel.ShadowBlur).ToString(), config.ShadowBlur));
101+
config.Volume = double.Parse((string)key.GetValue(nameof(ConfigModel.Volume).ToString(), config.Volume));
100102
}
101103
catch (Exception ex)
102104
{
@@ -114,6 +116,16 @@ public static ConfigModel LoadConfig()
114116
return config;
115117
}
116118

119+
public static void SetVolume(double volume)
120+
{
121+
loadedConfig.Volume = volume;
122+
SaveConfig(loadedConfig);
123+
}
124+
125+
public static double GetVolume()
126+
{
127+
return loadedConfig.Volume;
128+
}
117129

118130
public static ConfigParsedModel LoadParsedConfig()
119131
{

QuickViewFile/MainWindow.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public MainWindow()
2222
{
2323
try
2424
{
25+
RenderOptions.SetCachingHint(this, CachingHint.Cache);
2526
_config = ConfigHelper.loadedConfig;
2627
RenderOptions.ProcessRenderMode = _config.RenderMode == 0 ? System.Windows.Interop.RenderMode.Default : System.Windows.Interop.RenderMode.SoftwareOnly;
2728
RenderOptions.SetEdgeMode(this, _config.EdgeMode == 1 ? EdgeMode.Aliased : EdgeMode.Unspecified);

QuickViewFile/Models/ConfigModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ public class ConfigModel
3131
public double ShadowDepth { get; set; } = 2;
3232
public double ShadowOpacity { get; set; } = 1;
3333
public double ShadowBlur { get; set; } = 25;
34+
public double Volume { get; set; } = 1;
3435
}
3536
}

QuickViewFile/QuickViewFile.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Nullable>enable</Nullable>
77
<ImplicitUsings>enable</ImplicitUsings>
88
<UseWPF>true</UseWPF>
9-
<Version>1.7.2.1</Version>
9+
<Version>1.7.2.2</Version>
1010
<ApplicationIcon>QuickViewFile.ico</ApplicationIcon>
1111
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
1212
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>

0 commit comments

Comments
 (0)