1
1
using System . IO ;
2
+ using System . Windows . Shell ;
2
3
using FlyleafLib ;
3
4
using FlyleafLib . MediaPlayer ;
4
5
using LLPlayer . Extensions ;
@@ -20,6 +21,25 @@ public MainWindowVM(FlyleafManager fl)
20
21
21
22
public string Title { get ; set => Set ( ref field , value ) ; } = App . Name ;
22
23
24
+ #region Progress in TaskBar
25
+ public double TaskBarProgressValue
26
+ {
27
+ get ;
28
+ set
29
+ {
30
+ double v = value ;
31
+ if ( v < 0.01 )
32
+ {
33
+ // Set to 1% because it is not displayed.
34
+ v = 0.01 ;
35
+ }
36
+ Set ( ref field , v ) ;
37
+ }
38
+ }
39
+
40
+ public TaskbarItemProgressState TaskBarProgressState { get ; set => Set ( ref field , value ) ; }
41
+ #endregion
42
+
23
43
// ReSharper disable NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract
24
44
public DelegateCommand CmdOnLoaded => field ??= new ( ( ) =>
25
45
{
@@ -44,12 +64,43 @@ public MainWindowVM(FlyleafManager fl)
44
64
45
65
FL . Player . PropertyChanged += ( sender , args ) =>
46
66
{
67
+ if ( args . PropertyName == nameof ( FL . Player . CurTime ) )
68
+ {
69
+ double prevValue = TaskBarProgressValue ;
70
+ double newValue = ( double ) FL . Player . CurTime / FL . Player . Duration ;
71
+
72
+ if ( Math . Abs ( newValue - prevValue ) >= 0.01 ) // prevent frequent update
73
+ {
74
+ TaskBarProgressValue = newValue ;
75
+ }
76
+ }
47
77
if ( args . PropertyName == nameof ( FL . Player . Status ) )
48
78
{
49
- if ( FL . Player . Status == Status . Stopped )
79
+ switch ( FL . Player . Status )
50
80
{
51
- // reset
52
- Title = App . Name ;
81
+ case Status . Stopped :
82
+ // reset
83
+ Title = App . Name ;
84
+ TaskBarProgressState = TaskbarItemProgressState . None ;
85
+ TaskBarProgressValue = 0 ;
86
+ break ;
87
+ case Status . Playing :
88
+ TaskBarProgressState = TaskbarItemProgressState . Normal ;
89
+ break ;
90
+ case Status . Opening :
91
+ TaskBarProgressState = TaskbarItemProgressState . Indeterminate ;
92
+ TaskBarProgressValue = 0 ;
93
+ break ;
94
+ case Status . Paused :
95
+ TaskBarProgressState = TaskbarItemProgressState . Paused ;
96
+ break ;
97
+ case Status . Ended :
98
+ TaskBarProgressState = TaskbarItemProgressState . Paused ;
99
+ TaskBarProgressValue = 1 ;
100
+ break ;
101
+ case Status . Failed :
102
+ TaskBarProgressState = TaskbarItemProgressState . Error ;
103
+ break ;
53
104
}
54
105
}
55
106
} ;
@@ -67,6 +118,8 @@ public MainWindowVM(FlyleafManager fl)
67
118
name = FL . Player . Playlist . Selected . Title ;
68
119
}
69
120
Title = $ "{ name } - { App . Name } ";
121
+ TaskBarProgressValue = 0 ;
122
+ TaskBarProgressState = TaskbarItemProgressState . Normal ;
70
123
} ;
71
124
72
125
if ( App . CmdUrl != null )
0 commit comments