forked from Windsdon/spotify-control
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.js
More file actions
25 lines (23 loc) · 750 Bytes
/
test.js
File metadata and controls
25 lines (23 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const SpotifyControl = require('./index.js');
var spotify = new SpotifyControl({
token: "YOUR_SPOTIFY_TOKEN"
});
spotify.connect().then(client => {
console.log("Started");
spotify.play("spotify:track:4LYt31Tg51qsQqWOaZn4C6", "spotify:artist:5byg90wTxATnhB6kK253DF").then(v => {
console.log("Played");
spotify.startListener(["play", "pause"]).on("event", data => {
console.log(JSON.stringify(data, null, 4));
});
setTimeout(function() {
spotify.pause(true);
}, 3000);
setTimeout(function() {
spotify.pause(false);
}, 6000);
}, err => {
console.error(err);
});
}, err => {
console.error("Failed to start: " + err.message);
})