@@ -62,7 +62,7 @@ public bool IsRunning
62
62
get { return this . spotifyWindow ? . IsValid ?? false ; }
63
63
}
64
64
65
- public ISong CurrentSong { get ; private set ; }
65
+ public ISpotifyTrack CurrentTrack { get ; private set ; }
66
66
67
67
public bool IsPlaying { get ; private set ; }
68
68
@@ -80,7 +80,7 @@ public bool IsRunning
80
80
81
81
public event EventHandler < SpotifyStateEventArgs > Connected ;
82
82
83
- public event EventHandler < SpotifyTrackChangedEventArgs > SongChanged ;
83
+ public event EventHandler < SpotifyTrackChangedEventArgs > TrackChanged ;
84
84
85
85
public event EventHandler < SpotifyPlayStateChangedEventArgs > PlayStateChanged ;
86
86
@@ -555,23 +555,23 @@ private void BeginInitializeWebAPI()
555
555
logger . Debug ( "Begin Spotify WebAPI initialization" ) ;
556
556
}
557
557
558
- private async Task < bool > UpdateSongInfoUsingWebApi ( )
558
+ private async Task < bool > UpdateTrackInfoUsingWebApi ( )
559
559
{
560
560
if ( this . Web ? . API == null )
561
561
return false ;
562
562
563
563
// Pre-emptively waiting a little bit to let the remote Spotify server update its own information
564
- await Task . Delay ( TimeSpan . FromMilliseconds ( 25 ) ) . ConfigureAwait ( false ) ;
564
+ await Task . Delay ( TimeSpan . FromMilliseconds ( 50 ) ) . ConfigureAwait ( false ) ;
565
565
var currentlyPlayingObject = await this . Web . API . GetCurrentlyPlayingTrackAsync ( ) . ConfigureAwait ( false ) ;
566
566
if ( currentlyPlayingObject ? . Track == null || ! currentlyPlayingObject . Track . IsValid ( ) )
567
567
return false ;
568
568
569
- ISong newSong = currentlyPlayingObject . Track ;
570
- if ( newSong != null && ! Song . Equal ( this . CurrentSong , newSong ) )
569
+ ISpotifyTrack newTrack = currentlyPlayingObject . Track ;
570
+ if ( ! SpotifyTrack . Equal ( this . CurrentTrack , newTrack ) )
571
571
{
572
- ISong oldSong = this . CurrentSong ;
573
- this . CurrentSong = newSong ;
574
- await this . OnSongChanged ( oldSong ) . ConfigureAwait ( false ) ;
572
+ ISpotifyTrack oldTrack = this . CurrentTrack ;
573
+ this . CurrentTrack = newTrack ;
574
+ await this . OnTrackChanged ( oldTrack ) . ConfigureAwait ( false ) ;
575
575
}
576
576
577
577
await this . OnPlayStateChanged ( currentlyPlayingObject . IsPlaying ) . ConfigureAwait ( false ) ;
@@ -680,12 +680,12 @@ private async void OnWebAPIInitializationSucceeded()
680
680
var currentlyPlayingObject = await this . Web . API . GetCurrentlyPlayingTrackAsync ( ) . ConfigureAwait ( false ) ;
681
681
if ( currentlyPlayingObject ? . Track != null && currentlyPlayingObject . Track . IsValid ( ) )
682
682
{
683
- this . CurrentSong = currentlyPlayingObject . Track ;
683
+ this . CurrentTrack = currentlyPlayingObject . Track ;
684
684
this . IsPlaying = currentlyPlayingObject . IsPlaying ;
685
685
}
686
686
687
687
this . IsWebApiRunning = true ;
688
- this . WebAPIInitializationSucceeded ? . Invoke ( this , new SpotifyStateEventArgs ( this . CurrentSong , this . IsPlaying , this . CurrentSong ? . Length ?? 0.0 , 1.0 ) ) ;
688
+ this . WebAPIInitializationSucceeded ? . Invoke ( this , new SpotifyStateEventArgs ( this . CurrentTrack , this . IsPlaying , this . CurrentTrack ? . Length ?? 0.0 , 1.0 ) ) ;
689
689
}
690
690
691
691
private void OnWebAPIInitializationFailed ( SpotifyWebAPIInitializationFailedReason reason )
@@ -708,7 +708,7 @@ private async Task OnSpotifyConnected(SpotifyStateEventArgs e)
708
708
{
709
709
StringBuilder sb = new StringBuilder ( ) ;
710
710
sb . Append ( $ "Spotify Connected. Status = {{{Environment.NewLine}")
711
- . Append ( $ " CurrentSong: { ( e . CurrentSong != null ? $ "\" { e . CurrentSong } \" " : "null" ) } ,{ Environment . NewLine } ")
711
+ . Append ( $ " CurrentSong: { ( e . CurrentTrack != null ? $ "\" { e . CurrentTrack } \" " : "null" ) } ,{ Environment . NewLine } ")
712
712
. Append ( $ " Playing: { e . Playing } ,{ Environment . NewLine } ")
713
713
. Append ( $ " TrackTime: { e . TrackTime } ,{ Environment . NewLine } ")
714
714
. Append ( $ " Volume: { e . Volume } { Environment . NewLine } ")
@@ -717,7 +717,7 @@ private async Task OnSpotifyConnected(SpotifyStateEventArgs e)
717
717
}
718
718
719
719
this . IsPlaying = e . Playing ;
720
- this . CurrentSong = e . CurrentSong ;
720
+ this . CurrentTrack = e . CurrentTrack ;
721
721
722
722
this . Connected ? . Invoke ( this , e ) ;
723
723
@@ -732,14 +732,14 @@ private async Task OnSpotifyConnected(SpotifyStateEventArgs e)
732
732
{
733
733
await this . Broadcaster . StartAsync ( ) . ConfigureAwait ( false ) ;
734
734
await this . Broadcaster . BroadcastPlayState ( e . Playing ) . ConfigureAwait ( false ) ;
735
- await this . Broadcaster . BroadcastCurrentSong ( e . CurrentSong ) . ConfigureAwait ( false ) ;
735
+ await this . Broadcaster . BroadcastCurrentTrack ( e . CurrentTrack ) . ConfigureAwait ( false ) ;
736
736
}
737
737
}
738
738
739
- private async Task OnSongChanged ( ISong previousSong )
739
+ private async Task OnTrackChanged ( ISpotifyTrack previousTrack )
740
740
{
741
- this . SongChanged ? . Invoke ( this , new SpotifyTrackChangedEventArgs ( previousSong , this . CurrentSong ) ) ;
742
- await this . Broadcaster . BroadcastCurrentSong ( this . CurrentSong ) . ConfigureAwait ( false ) ;
741
+ this . TrackChanged ? . Invoke ( this , new SpotifyTrackChangedEventArgs ( previousTrack , this . CurrentTrack ) ) ;
742
+ await this . Broadcaster . BroadcastCurrentTrack ( this . CurrentTrack ) . ConfigureAwait ( false ) ;
743
743
}
744
744
745
745
private async Task OnPlayStateChanged ( bool playing )
@@ -853,7 +853,7 @@ private async void SpotifyWindowTitleWatcher_TitleChanged(object sender, WindowT
853
853
logger . Debug ( $ "Spotify's window title changed: \" { e . NewTitle } \" . Fetching song info...") ;
854
854
855
855
if ( ! ( Settings . Current . EnableSpotifyWebApi && this . IsWebApiRunning &&
856
- await this . UpdateSongInfoUsingWebApi ( ) . ConfigureAwait ( false ) ) )
856
+ await this . UpdateTrackInfoUsingWebApi ( ) . ConfigureAwait ( false ) ) )
857
857
{
858
858
// If the WebAPIs are disabled or they weren't able to retrieve the song info, fallback to
859
859
// the old method based on the title of Spotify's window.
@@ -872,12 +872,12 @@ await this.UpdateSongInfoUsingWebApi().ConfigureAwait(false)))
872
872
873
873
if ( updateSong )
874
874
{
875
- ISong newSong = Song . FromSpotifyWindowTitle ( e . NewTitle ) ;
876
- if ( ! Song . Equal ( this . CurrentSong , newSong ) )
875
+ ISpotifyTrack newSong = Song . FromSpotifyWindowTitle ( e . NewTitle ) ;
876
+ if ( ! SpotifyTrack . Equal ( this . CurrentTrack , newSong ) )
877
877
{
878
- ISong oldSong = this . CurrentSong ;
879
- this . CurrentSong = newSong ;
880
- await this . OnSongChanged ( oldSong ) . ConfigureAwait ( false ) ;
878
+ ISpotifyTrack oldSong = this . CurrentTrack ;
879
+ this . CurrentTrack = newSong ;
880
+ await this . OnTrackChanged ( oldSong ) . ConfigureAwait ( false ) ;
881
881
}
882
882
}
883
883
}
0 commit comments