File tree 4 files changed +63
-0
lines changed
4 files changed +63
-0
lines changed Original file line number Diff line number Diff line change @@ -1678,6 +1678,19 @@ describe('Basic tests', function () {
1678
1678
expect ( that . requests [ 0 ] . url ) . toBe ( 'https://api.spotify.com/v1/me/player' ) ;
1679
1679
} ) ;
1680
1680
1681
+ it ( 'should queue' , function ( ) {
1682
+ var callback = sinon . spy ( ) ;
1683
+ var api = new SpotifyWebApi ( ) ;
1684
+ api . queue ( 'spotify:track:1301WleyT98MSxVHPZCA6M' , callback ) ;
1685
+ that . requests [ 0 ] . respond ( 204 ) ;
1686
+ expect ( that . requests [ 0 ] . method ) . toBe ( 'POST' ) ;
1687
+ expect ( callback . calledWith ( null , '' ) ) . toBeTruthy ( ) ;
1688
+ expect ( that . requests . length ) . toBe ( 1 ) ;
1689
+ expect ( that . requests [ 0 ] . url ) . toBe (
1690
+ 'https://api.spotify.com/v1/me/player/queue?uri=spotify%3Atrack%3A1301WleyT98MSxVHPZCA6M'
1691
+ ) ;
1692
+ } ) ;
1693
+
1681
1694
it ( 'should play' , function ( ) {
1682
1695
var callback = sinon . spy ( ) ;
1683
1696
var api = new SpotifyWebApi ( ) ;
Original file line number Diff line number Diff line change @@ -1649,6 +1649,30 @@ var SpotifyWebApi = (function () {
1649
1649
return _checkParamsAndPerformRequest ( requestData , newOptions , callback ) ;
1650
1650
} ;
1651
1651
1652
+ /**
1653
+ * Add an item to the end of the user’s current playback queue.
1654
+ * See [Add an Item to the User's Playback Queue](https://developer.spotify.com/documentation/web-api/reference/player/add-to-queue/) on
1655
+ * the Spotify Developer site for more information about the endpoint.
1656
+ * @param {string } uri The uri of the item to add to the queue. Must be a track or an episode uri.
1657
+ * @param {Object } options A JSON object with options that can be passed.
1658
+ * @param {function(Object,Object) } callback An optional callback that receives 2 parameters. The first
1659
+ * one is the error object (null if no error), and the second is the value if the request succeeded.
1660
+ * @return {Object } Null if a callback is provided, a `Promise` object otherwise
1661
+ */
1662
+ Constr . prototype . queue = function ( uri , options , callback ) {
1663
+ options = options || { } ;
1664
+ var params =
1665
+ 'device_id' in options
1666
+ ? { uri : uri , device_id : options . device_id }
1667
+ : { uri : uri } ;
1668
+ var requestData = {
1669
+ type : 'POST' ,
1670
+ url : _baseUri + '/me/player/queue' ,
1671
+ params : params
1672
+ } ;
1673
+ return _checkParamsAndPerformRequest ( requestData , options , callback ) ;
1674
+ } ;
1675
+
1652
1676
/**
1653
1677
* Pause playback on the user’s account.
1654
1678
* See [Pause a User’s Playback](https://developer.spotify.com/web-api/pause-a-users-playback/) on
Original file line number Diff line number Diff line change @@ -111,6 +111,10 @@ declare namespace SpotifyApi {
111
111
play ?: boolean ;
112
112
}
113
113
114
+ interface QueueParameterObject {
115
+ device_id ?: string ;
116
+ }
117
+
114
118
interface TrackRelinkingParameterObject {
115
119
market ?: string ;
116
120
}
Original file line number Diff line number Diff line change @@ -1395,6 +1395,28 @@ declare namespace SpotifyWebApi {
1395
1395
callback : VoidResultsCallback
1396
1396
) : void ;
1397
1397
1398
+ /**
1399
+ * Add an item to the end of the user’s current playback queue.
1400
+ * See [Add an Item to the User's Playback Queue](https://developer.spotify.com/documentation/web-api/reference/player/add-to-queue/) on
1401
+ * the Spotify Developer site for more information about the endpoint.
1402
+ *
1403
+ * @param {string } uri The uri of the item to add to the queue. Must be a track or an episode uri.
1404
+ * @param {Object } options A JSON object with options that can be passed.
1405
+ * @param {function(Object,Object) } callback An optional callback that receives 2 parameters. The first
1406
+ * one is the error object (null if no error), and the second is the value if the request succeeded.
1407
+ * @return {Object } Null if a callback is provided, a `Promise` object otherwise
1408
+ */
1409
+ queue (
1410
+ uri : string ,
1411
+ options ?: SpotifyApi . QueueParameterObject
1412
+ ) : Promise < void > ;
1413
+ getMyCurrentPlayingTrack (
1414
+ uri : string ,
1415
+ options : SpotifyApi . QueueParameterObject ,
1416
+ callback : VoidResultsCallback
1417
+ ) : void ;
1418
+ queue ( uri : string , callback : VoidResultsCallback ) : void ;
1419
+
1398
1420
/**
1399
1421
* Start a new context or resume current playback on the user’s active device.
1400
1422
* See [Start/Resume a User’s Playback](https://developer.spotify.com/web-api/start-a-users-playback/) on
You can’t perform that action at this time.
0 commit comments