1
1
import { Injectable , Inject , Optional } from '@angular/core' ;
2
2
import { Http , Headers , Response , Request } from '@angular/http'
3
+ import { HttpModule } from '@angular/http' ;
3
4
import { Observable } from 'rxjs/Observable' ;
4
5
import 'rxjs/Rx' ;
5
6
@@ -638,7 +639,8 @@ export class SpotifyService {
638
639
authWindow . close ( ) ;
639
640
}
640
641
authCompleted = true ;
641
-
642
+ console . log ( 'storage changed' ) ;
643
+ console . log ( e ) ;
642
644
this . config . authToken = e . newValue ;
643
645
window . removeEventListener ( 'storage' , storageChanged , false ) ;
644
646
@@ -653,6 +655,49 @@ export class SpotifyService {
653
655
654
656
//#endregion
655
657
658
+ //#region Player
659
+ startPlayback ( ) {
660
+ return this . api ( {
661
+ method : 'put' ,
662
+ url : `/me/player/play` ,
663
+ headers : this . getHeaders ( )
664
+ } ) . map ( res => res . json ( ) ) ;
665
+ }
666
+
667
+ pausePlayback ( ) {
668
+ return this . api ( {
669
+ method : 'put' ,
670
+ url : `/me/player/pause` ,
671
+ headers : this . getHeaders ( )
672
+ } ) . map ( res => res . json ( ) ) ;
673
+ }
674
+
675
+ getPlayStatus ( ) {
676
+ return this . api ( {
677
+ method : 'get' ,
678
+ url : `/me/player` ,
679
+ headers : this . getHeaders ( )
680
+ } ) . map ( res => res . json ( ) ) ;
681
+ }
682
+
683
+ getDeviceInfo ( ) {
684
+ return this . api ( {
685
+ method : 'get' ,
686
+ url : `/me/player/devices` ,
687
+ headers : this . getHeaders ( )
688
+ } ) . map ( res => res . json ( ) ) ;
689
+ }
690
+
691
+ getCurrentPlaying ( ) {
692
+ return this . api ( {
693
+ method : 'get' ,
694
+ url : `/me/player/currently-playing` ,
695
+ headers : this . getHeaders ( )
696
+ } ) . map ( res => res . json ( ) ) ;
697
+ }
698
+
699
+ //#endregion
700
+
656
701
//#region utils
657
702
658
703
private toQueryString ( obj : Object ) : string {
0 commit comments