File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -317,7 +317,7 @@ struct MprisPlayerService {
317
317
repeat : LoopStatus ,
318
318
shuffle : bool ,
319
319
playback_status : PlaybackStatus ,
320
- volume : f64 ,
320
+ volume : u16 ,
321
321
metadata : HashMap < String , zbus:: zvariant:: OwnedValue > ,
322
322
}
323
323
@@ -622,7 +622,7 @@ impl MprisPlayerService {
622
622
// an error.
623
623
#[ zbus( property( emits_changed_signal = "true" ) ) ]
624
624
async fn volume ( & self ) -> Volume {
625
- self . volume
625
+ self . volume as f64 / u16 :: MAX as f64
626
626
}
627
627
628
628
#[ zbus( property) ]
@@ -849,7 +849,7 @@ impl MprisEventHandler {
849
849
repeat : LoopStatus :: None ,
850
850
shuffle : false ,
851
851
playback_status : PlaybackStatus :: Stopped ,
852
- volume : 1.0 ,
852
+ volume : u16 :: MAX ,
853
853
metadata : HashMap :: new ( ) ,
854
854
} ;
855
855
@@ -1166,11 +1166,13 @@ impl MprisTask {
1166
1166
}
1167
1167
} ,
1168
1168
PlayerEvent :: Unavailable { .. } => { }
1169
- PlayerEvent :: VolumeChanged {
1170
- // volume
1171
- ..
1172
- } => {
1173
- // TODO: Handle volume
1169
+ PlayerEvent :: VolumeChanged { volume, .. } => {
1170
+ let iface_ref = self . mpris_player_iface ( ) . await ;
1171
+ let mut iface = iface_ref. get_mut ( ) . await ;
1172
+ if iface. volume != volume {
1173
+ iface. volume = volume;
1174
+ iface. volume_changed ( iface_ref. signal_context ( ) ) . await ?;
1175
+ }
1174
1176
}
1175
1177
PlayerEvent :: Seeked {
1176
1178
track_id,
You can’t perform that action at this time.
0 commit comments