@@ -5,7 +5,7 @@ use log::{debug, info, warn};
5
5
use thiserror:: Error ;
6
6
use time:: format_description:: well_known:: Iso8601 ;
7
7
use tokio:: sync:: mpsc;
8
- use zbus:: connection;
8
+ use zbus:: { connection, fdo } ;
9
9
10
10
use librespot:: {
11
11
core:: date:: Date ,
@@ -621,16 +621,14 @@ impl MprisPlayerService {
621
621
// Calling Play after this should cause playback to start again from the same position.
622
622
//
623
623
// If `self.can_pause` is `false`, attempting to call this method should have no effect.
624
- async fn pause ( & self ) -> zbus :: fdo:: Result < ( ) > {
624
+ async fn pause ( & self ) -> fdo:: Result < ( ) > {
625
625
debug ! ( "org.mpris.MediaPlayer2.Player::Pause" ) ;
626
626
match ( & self . spirc , & self . metadata . mpris . track_id ) {
627
627
( Some ( spirc) , Some ( _) ) => spirc
628
628
. pause ( )
629
- . map_err ( |err| zbus:: fdo:: Error :: Failed ( format ! ( "{err}" ) ) ) ,
630
- ( Some ( _) , None ) => {
631
- zbus:: fdo:: Result :: Err ( zbus:: fdo:: Error :: Failed ( String :: from ( "No track" ) ) )
632
- }
633
- _ => zbus:: fdo:: Result :: Err ( zbus:: fdo:: Error :: Failed ( String :: from ( "Can't play/pause" ) ) ) ,
629
+ . map_err ( |err| fdo:: Error :: Failed ( format ! ( "{err}" ) ) ) ,
630
+ ( Some ( _) , None ) => fdo:: Result :: Err ( fdo:: Error :: Failed ( String :: from ( "No track" ) ) ) ,
631
+ _ => fdo:: Result :: Err ( fdo:: Error :: Failed ( String :: from ( "Can't play/pause" ) ) ) ,
634
632
}
635
633
}
636
634
@@ -642,16 +640,14 @@ impl MprisPlayerService {
642
640
//
643
641
// If `self.can_pause` is `false`, attempting to call this method should have no effect and
644
642
// raise an error.
645
- async fn play_pause ( & self ) -> zbus :: fdo:: Result < ( ) > {
643
+ async fn play_pause ( & self ) -> fdo:: Result < ( ) > {
646
644
debug ! ( "org.mpris.MediaPlayer2.Player::PlayPause" ) ;
647
645
match ( & self . spirc , & self . metadata . mpris . track_id ) {
648
646
( Some ( spirc) , Some ( _) ) => spirc
649
647
. play_pause ( )
650
- . map_err ( |err| zbus:: fdo:: Error :: Failed ( format ! ( "{err}" ) ) ) ,
651
- ( Some ( _) , None ) => {
652
- zbus:: fdo:: Result :: Err ( zbus:: fdo:: Error :: Failed ( String :: from ( "No track" ) ) )
653
- }
654
- _ => zbus:: fdo:: Result :: Err ( zbus:: fdo:: Error :: Failed ( String :: from ( "Can't play/pause" ) ) ) ,
648
+ . map_err ( |err| fdo:: Error :: Failed ( format ! ( "{err}" ) ) ) ,
649
+ ( Some ( _) , None ) => fdo:: Result :: Err ( fdo:: Error :: Failed ( String :: from ( "No track" ) ) ) ,
650
+ _ => fdo:: Result :: Err ( fdo:: Error :: Failed ( String :: from ( "Can't play/pause" ) ) ) ,
655
651
}
656
652
}
657
653
@@ -681,7 +677,7 @@ impl MprisPlayerService {
681
677
// If there is no track to play, this has no effect.
682
678
//
683
679
// If `self.can_play` is `false`, attempting to call this method should have no effect.
684
- async fn play ( & self ) -> zbus :: fdo:: Result < ( ) > {
680
+ async fn play ( & self ) -> fdo:: Result < ( ) > {
685
681
debug ! ( "org.mpris.MediaPlayer2.Player::Play" ) ;
686
682
if let Some ( spirc) = & self . spirc {
687
683
let _ = spirc. activate ( ) ;
@@ -693,12 +689,10 @@ impl MprisPlayerService {
693
689
spirc. activate ( ) ?;
694
690
spirc. play ( )
695
691
} ) ( ) ;
696
- result. map_err ( |err| zbus:: fdo:: Error :: Failed ( format ! ( "{err}" ) ) )
697
- }
698
- ( Some ( _) , None ) => {
699
- zbus:: fdo:: Result :: Err ( zbus:: fdo:: Error :: Failed ( String :: from ( "No track" ) ) )
692
+ result. map_err ( |err| fdo:: Error :: Failed ( format ! ( "{err}" ) ) )
700
693
}
701
- _ => zbus:: fdo:: Result :: Err ( zbus:: fdo:: Error :: Failed ( String :: from ( "Can't play/pause" ) ) ) ,
694
+ ( Some ( _) , None ) => fdo:: Result :: Err ( fdo:: Error :: Failed ( String :: from ( "No track" ) ) ) ,
695
+ _ => fdo:: Result :: Err ( fdo:: Error :: Failed ( String :: from ( "Can't play/pause" ) ) ) ,
702
696
}
703
697
}
704
698
@@ -785,11 +779,9 @@ impl MprisPlayerService {
785
779
// * `uri`: Uri of the track to load. Its uri scheme should be an element of the
786
780
// `org.mpris.MediaPlayer2.SupportedUriSchemes` property and the mime-type should
787
781
// match one of the elements of the `org.mpris.MediaPlayer2.SupportedMimeTypes`.
788
- async fn open_uri ( & self , uri : & str ) -> zbus :: fdo:: Result < ( ) > {
782
+ async fn open_uri ( & self , uri : & str ) -> fdo:: Result < ( ) > {
789
783
debug ! ( "org.mpris.MediaPlayer2.Player::OpenUri({uri:?})" ) ;
790
- Err ( zbus:: fdo:: Error :: NotSupported (
791
- "OpenUri not supported" . to_owned ( ) ,
792
- ) )
784
+ Err ( fdo:: Error :: NotSupported ( "OpenUri not supported" . to_owned ( ) ) )
793
785
}
794
786
795
787
// The current playback status.
@@ -818,7 +810,7 @@ impl MprisPlayerService {
818
810
}
819
811
820
812
#[ zbus( property) ]
821
- async fn set_loop_status ( & mut self , value : LoopStatus ) -> zbus :: fdo:: Result < ( ) > {
813
+ async fn set_loop_status ( & mut self , value : LoopStatus ) -> fdo:: Result < ( ) > {
822
814
debug ! ( "org.mpris.MediaPlayer2.Player::LoopStatus({value:?})" ) ;
823
815
match value {
824
816
LoopStatus :: None => {
@@ -904,12 +896,9 @@ impl MprisPlayerService {
904
896
#[ zbus( property( emits_changed_signal = "true" ) ) ]
905
897
async fn metadata (
906
898
& self ,
907
- ) -> zbus :: fdo:: Result < std:: collections:: HashMap < String , zbus:: zvariant:: OwnedValue > > {
899
+ ) -> fdo:: Result < std:: collections:: HashMap < String , zbus:: zvariant:: OwnedValue > > {
908
900
debug ! ( "org.mpris.MediaPlayer2.Player::Metadata" ) ;
909
- self . metadata
910
- . clone ( )
911
- . try_into ( )
912
- . map_err ( zbus:: fdo:: Error :: ZBus )
901
+ self . metadata . clone ( ) . try_into ( ) . map_err ( fdo:: Error :: ZBus )
913
902
}
914
903
915
904
// The volume level.
@@ -925,7 +914,7 @@ impl MprisPlayerService {
925
914
}
926
915
927
916
#[ zbus( property) ]
928
- async fn set_volume ( & mut self , value : Volume ) -> zbus :: fdo:: Result < ( ) > {
917
+ async fn set_volume ( & mut self , value : Volume ) -> fdo:: Result < ( ) > {
929
918
debug ! ( "org.mpris.MediaPlayer2.Player::Volume({value})" ) ;
930
919
if let Some ( spirc) = & self . spirc {
931
920
// As of rust 1.45, cast is guaranteed to round to 0 and saturate.
@@ -934,7 +923,7 @@ impl MprisPlayerService {
934
923
let mapped_volume = ( value * ( u16:: MAX as f64 ) ) . round ( ) as u16 ;
935
924
spirc
936
925
. set_volume ( mapped_volume)
937
- . map_err ( |err| zbus :: fdo:: Error :: Failed ( format ! ( "{err}" ) ) ) ?;
926
+ . map_err ( |err| fdo:: Error :: Failed ( format ! ( "{err}" ) ) ) ?;
938
927
}
939
928
Ok ( ( ) )
940
929
}
@@ -949,7 +938,7 @@ impl MprisPlayerService {
949
938
// If the playback progresses in a way that is inconstistant with the `Rate` property, the
950
939
// `Seeked` signal is emited.
951
940
#[ zbus( property( emits_changed_signal = "false" ) ) ]
952
- async fn position ( & self ) -> zbus :: fdo:: Result < TimeInUs > {
941
+ async fn position ( & self ) -> fdo:: Result < TimeInUs > {
953
942
debug ! ( "org.mpris.MediaPlayer2.Player::Position" ) ;
954
943
955
944
self . position
@@ -959,7 +948,7 @@ impl MprisPlayerService {
959
948
. saturating_add ( position. last_update . elapsed ( ) . as_millis ( ) ) ;
960
949
corrected as i64 * 1000
961
950
} )
962
- . ok_or ( zbus :: fdo:: Error :: Failed ( String :: from ( "Got no position" ) ) )
951
+ . ok_or ( fdo:: Error :: Failed ( String :: from ( "Got no position" ) ) )
963
952
}
964
953
965
954
// The minimum value which the `Rate` property can take. Clients should not attempt to set the
0 commit comments