lunify.js
Version:
A basic api wrapper for the spotify api covering the oauth routes.
41 lines • 1.76 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PlayerDevice = void 0;
class PlayerDevice {
constructor(client, user, data) {
var _a;
this.client = client;
this.user = user;
this.id = data.id;
this.active = data.is_active;
this.privateSession = data.is_private_session;
this.restricted = data.is_restricted;
this.name = data.name;
this.type = data.type;
this.volume = (_a = data.volume_percent) !== null && _a !== void 0 ? _a : 100;
this.supportsVolume = data.supports_volume;
}
/**
* Transfer the current playback to this device
* @returns Whenever the refresh was successfull or not
*/
transferPlaybackTo() {
return __awaiter(this, void 0, void 0, function* () {
if (this.active)
return false;
yield this.user.player.devices.transferPlaybackTo(this.id);
return true;
});
}
}
exports.PlayerDevice = PlayerDevice;
//# sourceMappingURL=Device.js.map