File tree Expand file tree Collapse file tree 4 files changed +63
-0
lines changed
Expand file tree Collapse file tree 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 () {
16781678 expect ( that . requests [ 0 ] . url ) . toBe ( 'https://api.spotify.com/v1/me/player' ) ;
16791679 } ) ;
16801680
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+
16811694 it ( 'should play' , function ( ) {
16821695 var callback = sinon . spy ( ) ;
16831696 var api = new SpotifyWebApi ( ) ;
Original file line number Diff line number Diff line change @@ -1649,6 +1649,30 @@ var SpotifyWebApi = (function () {
16491649 return _checkParamsAndPerformRequest ( requestData , newOptions , callback ) ;
16501650 } ;
16511651
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+
16521676 /**
16531677 * Pause playback on the user’s account.
16541678 * 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 {
111111 play ?: boolean ;
112112 }
113113
114+ interface QueueParameterObject {
115+ device_id ?: string ;
116+ }
117+
114118 interface TrackRelinkingParameterObject {
115119 market ?: string ;
116120 }
Original file line number Diff line number Diff line change @@ -1395,6 +1395,28 @@ declare namespace SpotifyWebApi {
13951395 callback : VoidResultsCallback
13961396 ) : void ;
13971397
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+
13981420 /**
13991421 * Start a new context or resume current playback on the user’s active device.
14001422 * 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