File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,12 @@ export default {
167167 play ( uri ?: string ) {
168168 return ensureAuthenticated ( )
169169 . then ( ensurePlayer )
170+ . tap ( ( ) => log . debug ( `spotify.play(${ uri } )` ) )
171+ . then ( ( ) => {
172+ if ( uri ) {
173+ player . setExpectedURI ( uri ) ;
174+ }
175+ } )
170176 . then ( ( ) => ( uri ? [ uri ] : undefined ) )
171177 . then ( uris => spotify . play ( { uris } ) )
172178 . then ( ( ) => player . waitForPlayback ( uri ) )
Original file line number Diff line number Diff line change @@ -46,6 +46,19 @@ export default {
4646 . then ( el => el . getText ( ) ) ;
4747 } ,
4848
49+ setExpectedURI ( id : string ) {
50+ if ( ! driver ) {
51+ return Promise . reject ( new Error ( "No driver" ) ) ;
52+ }
53+
54+ let d : Driver = driver ;
55+ // Get the device ID
56+ return Promise . resolve ( )
57+ . then ( ( ) => d . findElement ( By . id ( "expectedURI" ) ) )
58+ . tap ( e => e . clear ( ) )
59+ . tap ( e => e . sendKeys ( id ) ) ;
60+ } ,
61+
4962 getStatus ( ) {
5063 if ( ! driver ) {
5164 return Promise . reject ( new Error ( "No driver" ) ) ;
Original file line number Diff line number Diff line change 77 < title > Spotify Web Player (loading)</ title >
88 </ head >
99 < body >
10+ < input type ="text " id ="expectedURI " />
11+
1012 < span id ="device_id "> </ span >
1113 < span id ="device_state "> loading</ span >
1214
4850 const track = state . track_window . current_track ;
4951
5052 if ( ! state . paused ) {
53+ if ( track . uri != expectedURI . value ) {
54+ console . log (
55+ `MISMATCHED TRACKS -- Expected ${ expectedURI . value } , got ${ track . id } `
56+ ) ;
57+ player . pause ( ) . then ( ( ) => player . seek ( 0 ) ) ;
58+ }
5159 document . getElementById ( "device_state" ) . innerText = "playing" ;
5260 } else {
5361 document . getElementById ( "device_state" ) . innerText = "paused" ;
You can’t perform that action at this time.
0 commit comments