Advertisement
Guest User

Untitled

a guest
Mar 8th, 2018
1,877
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Spotify JS-SDK - v1.5.0-5d24f40 */ ! function(e) {
  2.     function t(r) {
  3.         if (n[r]) return n[r].exports;
  4.         var s = n[r] = {
  5.             i: r,
  6.             l: !1,
  7.             exports: {}
  8.         };
  9.         return e[r].call(s.exports, s, s.exports, t), s.l = !0, s.exports
  10.     }
  11.     var n = {};
  12.     t.m = e, t.c = n, t.d = function(e, n, r) {
  13.         t.o(e, n) || Object.defineProperty(e, n, {
  14.             configurable: !1,
  15.             enumerable: !0,
  16.             get: r
  17.         })
  18.     }, t.n = function(e) {
  19.         var n = e && e.__esModule ? function() {
  20.             return e.default
  21.         } : function() {
  22.             return e
  23.         };
  24.         return t.d(n, "a", n), n
  25.     }, t.o = function(e, t) {
  26.         return Object.prototype.hasOwnProperty.call(e, t)
  27.     }, t.p = "", t(t.s = 2)
  28. }([function(e, t, n) {
  29.     "use strict";
  30.     var r = {
  31.         SPOTIFY_MESSAGE: "SP_MESSAGE",
  32.         ACCOUNT_ERROR: "ACCOUNT_ERROR",
  33.         AUTH_ERROR: "AUTH_ERROR",
  34.         CONNECT: "CONNECT",
  35.         CONNECTED: "CONNECTED",
  36.         CURRENT_STATE: "CURRENT_STATE",
  37.         DISCONNECT: "DISCONNECT",
  38.         EVENT: "EVENT",
  39.         GET_CURRENT_STATE: "GET_CURRENT_STATE",
  40.         GET_TOKEN: "GET_TOKEN",
  41.         GET_VOLUME: "GET_VOLUME",
  42.         INIT: "INIT",
  43.         LOADED: "LOADED",
  44.         NEXT_TRACK: "NEXT_TRACK",
  45.         PAUSE: "PAUSE",
  46.         PLAYBACK_ERROR: "PLAYBACK_ERROR",
  47.         PLAYER_INIT_ERROR: "PLAYER_INIT_ERROR",
  48.         PLAYER_READY: "PLAYER_READY",
  49.         PLAYER_STATE_CHANGED: "PLAYER_STATE_CHANGED",
  50.         PREV_TRACK: "PREV_TRACK",
  51.         RESUME: "RESUME",
  52.         SEEK: "SEEK",
  53.         SET_VOLUME: "SET_VOLUME",
  54.         TOGGLE_PLAY: "TOGGLE_PLAY",
  55.         TOKEN: "TOKEN",
  56.         VOLUME: "VOLUME",
  57.         accountError: function(e) {
  58.             return this._createEventMessage(r.ACCOUNT_ERROR, {
  59.                 message: e
  60.             })
  61.         },
  62.         authError: function(e) {
  63.             return this._createEventMessage(r.AUTH_ERROR, e)
  64.         },
  65.         playbackError: function(e) {
  66.             return this._createEventMessage(r.PLAYBACK_ERROR, e)
  67.         },
  68.         playerReady: function(e) {
  69.             return this._createEventMessage(r.PLAYER_READY, e)
  70.         },
  71.         connect: function() {
  72.             return this._createMessage(r.CONNECT)
  73.         },
  74.         connected: function(e, t) {
  75.             return this._createMessage(r.CONNECTED, {
  76.                 connected: e,
  77.                 ref: t
  78.             })
  79.         },
  80.         disconnect: function() {
  81.             return this._createMessage(r.DISCONNECT)
  82.         },
  83.         init: function(e) {
  84.             return this._createMessage(r.INIT, e)
  85.         },
  86.         playerInitError: function(e) {
  87.             return this._createEventMessage(r.PLAYER_INIT_ERROR, e)
  88.         },
  89.         getToken: function() {
  90.             return this._createMessage(r.GET_TOKEN)
  91.         },
  92.         token: function(e, t) {
  93.             return this._createMessage(r.TOKEN, {
  94.                 token: e,
  95.                 ref: t
  96.             })
  97.         },
  98.         pause: function() {
  99.             return this._createMessage(r.PAUSE)
  100.         },
  101.         resume: function() {
  102.             return this._createMessage(r.RESUME)
  103.         },
  104.         togglePlay: function() {
  105.             return this._createMessage(r.TOGGLE_PLAY)
  106.         },
  107.         seek: function(e) {
  108.             return this._createMessage(r.SEEK, e)
  109.         },
  110.         nextTrack: function(e) {
  111.             return this._createMessage(r.NEXT_TRACK, e)
  112.         },
  113.         previousTrack: function(e) {
  114.             return this._createMessage(r.PREV_TRACK, e)
  115.         },
  116.         getCurrentState: function() {
  117.             return this._createMessage(r.GET_CURRENT_STATE)
  118.         },
  119.         currentState: function(e, t) {
  120.             return this._createMessage(r.CURRENT_STATE, {
  121.                 state: e,
  122.                 ref: t
  123.             })
  124.         },
  125.         playerStateChanged: function(e) {
  126.             return this._createEventMessage(r.PLAYER_STATE_CHANGED, e)
  127.         },
  128.         getVolume: function() {
  129.             return this._createMessage(r.GET_VOLUME)
  130.         },
  131.         volume: function(e, t) {
  132.             return this._createMessage(r.VOLUME, {
  133.                 volume: e,
  134.                 ref: t
  135.             })
  136.         },
  137.         setVolume: function(e) {
  138.             return this._createMessage(r.SET_VOLUME, e)
  139.         },
  140.         embeddedLoaded: function() {
  141.             return this._createMessage(r.LOADED)
  142.         },
  143.         _createEventMessage: function(e, t) {
  144.             return this._createMessage(r.EVENT, {
  145.                 name: e,
  146.                 eventData: t
  147.             })
  148.         },
  149.         _createMessage: function(e, t) {
  150.             return {
  151.                 type: r.SPOTIFY_MESSAGE,
  152.                 body: {
  153.                     topic: e,
  154.                     data: t ? JSON.parse(JSON.stringify(t)) : null
  155.                 }
  156.             }
  157.         }
  158.     };
  159.     e.exports = r
  160. }, function(e, t) {
  161.     var n;
  162.     n = function() {
  163.         return this
  164.     }();
  165.     try {
  166.         n = n || Function("return this")() || (0, eval)("this")
  167.     } catch (e) {
  168.         "object" == typeof window && (n = window)
  169.     }
  170.     e.exports = n
  171. }, function(e, t, n) {
  172.     "use strict";
  173.  
  174.     function r() {
  175.         var e = n(3);
  176.         if (!document.body) throw new Error("Document doesn't have a body");
  177.         if (window.Spotify = {
  178.                 Player: e.setupPlayerEnv(window)
  179.             }, window.onSpotifyWebPlaybackSDKReady) window.onSpotifyWebPlaybackSDKReady();
  180.         else {
  181.             if (!window.onSpotifyPlayerAPIReady) throw new Error("onSpotifyWebPlaybackSDKReady is not defined");
  182.             window.onSpotifyPlayerAPIReady()
  183.         }
  184.     }
  185.     "complete" === document.readyState ? r() : window.addEventListener("load", r)
  186. }, function(e, t, n) {
  187.     "use strict";
  188.     var r = n(4),
  189.         s = n(5),
  190.         o = n(0),
  191.         i = n(6),
  192.         a = function(e, t) {
  193.             var n, a = "https://sdk.scdn.co/embedded/index.html",
  194.                 u = s.defer(),
  195.                 c = new r,
  196.                 _ = t || function(t) {
  197.                     var n = e.document.createElement("iframe");
  198.                     return n.src = t, n.style.setProperty("display", "none", "important"), n.allow = "encrypted-media", e.document.body.appendChild(n), n.contentWindow
  199.                 },
  200.                 h = function(t) {
  201.                     t === o.LOADED && (c.stopListening(e, h), u.resolve())
  202.                 };
  203.             c.listen(e, h), n = _(a);
  204.             var f = function(t) {
  205.                 this._options = this._sanitizeOptions(t), this._handleMessages = this._handleMessages.bind(this), this._messageHandlers = {}, this._eventListeners = {}, this._setupMessageHandlers(), this._connectionRequests = {}, this._getCurrentStateRequests = {}, this._getVolumeRequests = {}, this.isLoaded = u.promise.then(function() {
  206.                     c.listen(e, this._handleMessages), this._sendMessage(o.init(this._options))
  207.                 }.bind(this))
  208.             };
  209.             return f.prototype._sanitizeOptions = function(t) {
  210.                 var n = e && e.location && e.location.hostname || "";
  211.                 return {
  212.                     name: t.name || n,
  213.                     id: i.get(),
  214.                     getOAuthToken: t.getOAuthToken || t.getOauthToken,
  215.                     volume: t.volume || 1
  216.                 }
  217.             }, f.prototype._setupMessageHandlers = function() {
  218.                 this._messageHandlers[o.GET_TOKEN] = this._onGetToken.bind(this), this._messageHandlers[o.EVENT] = this._onEvent.bind(this), this._messageHandlers[o.CONNECTED] = this._onConnected.bind(this), this._messageHandlers[o.CURRENT_STATE] = this._onCurrentState.bind(this), this._messageHandlers[o.VOLUME] = this._onVolume.bind(this)
  219.             }, f.prototype.connect = function() {
  220.                 return this.isLoaded.then(function() {
  221.                     var e = this._sendMessage(o.connect());
  222.                     return this._connectionRequests[e] = s.defer(), this._connectionRequests[e].promise
  223.                 }.bind(this))
  224.             }, f.prototype.on = function(e, t) {
  225.                 if (!e) throw new TypeError("Argument `eventName` is required.");
  226.                 if ("function" != typeof t) throw new TypeError("Argument `listener` must be a function.");
  227.                 return this._eventListeners[e] = this._eventListeners[e] || [], -1 === this._eventListeners[e].indexOf(t) && (this._eventListeners[e].push(t), !0)
  228.             }, f.prototype.addListener = function(e, t) {
  229.                 return this.on(e, t)
  230.             }, f.prototype.removeListener = function(e, t) {
  231.                 if (!e) throw new TypeError("Argument `eventName` is required.");
  232.                 if (1 === arguments.length) return this._eventListeners[e] = [], !0;
  233.                 if ("function" != typeof t) throw new TypeError("Argument `listener` must be a function.");
  234.                 var n = this._eventListeners[e];
  235.                 return !(!n || !n.length) && (this._eventListeners[e] = n.filter(function(e) {
  236.                     return e !== t
  237.                 }), !0)
  238.             }, f.prototype.getCurrentState = function() {
  239.                 return this.isLoaded.then(function() {
  240.                     var e = this._sendMessage(o.getCurrentState());
  241.                     return this._getCurrentStateRequests[e] = s.defer(), this._getCurrentStateRequests[e].promise
  242.                 }.bind(this))
  243.             }, f.prototype.getVolume = function() {
  244.                 return this.isLoaded.then(function() {
  245.                     var e = this._sendMessage(o.getVolume());
  246.                     return this._getVolumeRequests[e] = s.defer(), this._getVolumeRequests[e].promise
  247.                 }.bind(this))
  248.             }, f.prototype.setVolume = function(e) {
  249.                 return this._sendMessageWhenLoaded(o.setVolume(e))
  250.             }, f.prototype.pause = function() {
  251.                 return this._sendMessageWhenLoaded(o.pause())
  252.             }, f.prototype.resume = function() {
  253.                 return this._sendMessageWhenLoaded(o.resume())
  254.             }, f.prototype.togglePlay = function() {
  255.                 return this._sendMessageWhenLoaded(o.togglePlay())
  256.             }, f.prototype.seek = function(e) {
  257.                 return this._sendMessageWhenLoaded(o.seek(e))
  258.             }, f.prototype.previousTrack = function(e) {
  259.                 return this._sendMessageWhenLoaded(o.previousTrack(e))
  260.             }, f.prototype.nextTrack = function(e) {
  261.                 return this._sendMessageWhenLoaded(o.nextTrack(e))
  262.             }, f.prototype.disconnect = function() {
  263.                 return this._sendMessageWhenLoaded(o.disconnect())
  264.             }, f.prototype._getListeners = function() {
  265.                 var e = {};
  266.                 return e[o.ACCOUNT_ERROR] = "account_error", e[o.AUTH_ERROR] = "authentication_error", e[o.PLAYBACK_ERROR] = "playback_error", e[o.PLAYER_INIT_ERROR] = "initialization_error", e[o.PLAYER_READY] = "ready", e[o.PLAYER_STATE_CHANGED] = "player_state_changed",
  267.                     function(t) {
  268.                         return this._eventListeners[e[t]] || []
  269.                     }
  270.             }(), f.prototype._onEvent = function(e) {
  271.                 this._getListeners(e.name).forEach(function(t) {
  272.                     t(e.eventData)
  273.                 })
  274.             }, f.prototype._onGetToken = function(e, t) {
  275.                 var n = this._options.getOAuthToken;
  276.                 if ("function" != typeof n) {
  277.                     var r = "getOAuthToken is not a function";
  278.                     if (this._getListeners(o.PLAYER_INIT_ERROR).length) return void this._onEvent({
  279.                         name: o.PLAYER_INIT_ERROR,
  280.                         eventData: {
  281.                             message: r
  282.                         }
  283.                     });
  284.                     throw new Error(r)
  285.                 }
  286.                 new s(n).then(function(e) {
  287.                     this._sendMessage(o.token(e, t))
  288.                 }.bind(this))
  289.             }, f.prototype._onConnected = function(e) {
  290.                 e.ref in this._connectionRequests && (this._connectionRequests[e.ref].resolve(e.connected), delete this._connectionRequests[e.ref])
  291.             }, f.prototype._onCurrentState = function(e) {
  292.                 e.ref in this._getCurrentStateRequests && (this._getCurrentStateRequests[e.ref].resolve(e.state), delete this._getCurrentStateRequests[e.ref])
  293.             }, f.prototype._onVolume = function(e) {
  294.                 e.ref in this._getVolumeRequests && (this._getVolumeRequests[e.ref].resolve(e.volume), delete this._getVolumeRequests[e.ref])
  295.             }, f.prototype._handleMessages = function(e, t, n) {
  296.                 e in this._messageHandlers && this._messageHandlers[e](t, n)
  297.             }, f.prototype._sendMessage = function(e) {
  298.                 return c.send(n, e, a)
  299.             }, f.prototype._sendMessageWhenLoaded = function(e) {
  300.                 return this.isLoaded.then(this._sendMessage.bind(this, e))
  301.             }, f
  302.         };
  303.     e.exports.setupPlayerEnv = a
  304. }, function(e, t, n) {
  305.     "use strict";
  306.     var r = n(0),
  307.         s = function() {
  308.             this._onMessageCallback = function() {}, this._receiveMessage = this._receiveMessage.bind(this), this._messageId = 0
  309.         };
  310.     s.prototype.listen = function(e, t) {
  311.         this._onMessageCallback = t, e.addEventListener("message", this._receiveMessage)
  312.     }, s.prototype.stopListening = function(e) {
  313.         e.removeEventListener("message", this._receiveMessage)
  314.     }, s.prototype.send = function(e, t, n) {
  315.         return e.postMessage(this._addMessageId(t), n || "*"), t.seq
  316.     }, s.prototype._addMessageId = function(e) {
  317.         return e.seq = this._messageId++, e
  318.     }, s.prototype._receiveMessage = function(e) {
  319.         var t = e.data;
  320.         t.type === r.SPOTIFY_MESSAGE && t.body && t.body.topic && this._onMessageCallback(t.body.topic, t.body.data, t.seq)
  321.     }, e.exports = s
  322. }, function(e, t, n) {
  323.     "use strict";
  324.     (function(t) {
  325.         var n = t.Promise;
  326.         if (!n) throw new Error("Fatal: no Promise implementation available.");
  327.         var r;
  328.         r = Object.defineProperty ? function(e, t, n) {
  329.             return e[t] ? e : (Object.defineProperty(e, t, {
  330.                 value: n,
  331.                 configurable: !0,
  332.                 writable: !0
  333.             }), e)
  334.         } : function(e, t, n) {
  335.             return e[t] ? e : (e[t] = n, e)
  336.         }, r(n, "defer", function() {
  337.             var e = {};
  338.             return e.promise = new n(function(t, n) {
  339.                 e.resolve = t, e.reject = n
  340.             }), e
  341.         }), r(n.prototype, "spread", function(e, t) {
  342.             return this.then(function(e) {
  343.                 return n.all(e)
  344.             }).then(function(t) {
  345.                 return 1 === t.length ? e(t[0]) : e.apply(this, t)
  346.             }, t)
  347.         }), e.exports = n
  348.     }).call(t, n(1))
  349. }, function(e, t, n) {
  350.     "use strict";
  351.     (function(t) {
  352.         function r() {
  353.             var e = new t.Uint8Array(16);
  354.             return t.crypto.getRandomValues(e), i.toHex(e.join(""), 40).slice(0, 40)
  355.         }
  356.  
  357.         function s() {
  358.             for (var e = new Array(27), t = e.length; t--;) e[t] = Math.floor(8 * Math.random());
  359.             return i.toHex(e.join(""), 40)
  360.         }
  361.  
  362.         function o(e, n) {
  363.             if (e && "string" == typeof e) return e;
  364.             if (n) return u();
  365.             var r = t.localStorage.getItem(c);
  366.             return r || (r = u(), t.localStorage.setItem(c, r)), r
  367.         }
  368.         var i = n(7),
  369.             a = "function" == typeof t.Uint8Array && void 0 !== t.crypto && "function" == typeof t.crypto.getRandomValues,
  370.             u = a ? r : s,
  371.             c = "_spharmony_device_id";
  372.         e.exports = {
  373.             get: o,
  374.             generate: u,
  375.             generateWithCrypto: r,
  376.             generateWithRandom: s
  377.         }
  378.     }).call(t, n(1))
  379. }, function(e, t, n) {
  380.     "use strict";
  381.  
  382.     function r(e, t, n) {
  383.         for (var r = 0, s = 0; s < e.length; ++s) {
  384.             var o = e[s] * t + r;
  385.             e[s] = o % n, r = ~~(o / n)
  386.         }
  387.         for (; r;) e.push(r % n), r = ~~(r / n)
  388.     }
  389.  
  390.     function s(e, t, n, r) {
  391.         var s, o, i = 0;
  392.         for (o = 0; o < t.length; ++o) s = ~~e[o] + t[o] * n + i, e[o] = s % r, i = ~~(s / r);
  393.         for (; i;) s = ~~e[o] + i, e[o] = s % r, i = ~~(s / r), ++o
  394.     }
  395.  
  396.     function o(e, t, n) {
  397.         for (var o = [0], i = [1], a = 0; a < e.length; ++a) s(o, i, e[a], n), r(i, t, n);
  398.         return o
  399.     }
  400.  
  401.     function i(e, t) {
  402.         for (var n = [], r = 0; r < e.length; ++r) n.push(t[e[r]]);
  403.         return n.reverse()
  404.     }
  405.  
  406.     function a(e, t) {
  407.         for (; e.length < t;) e.push(0);
  408.         return e
  409.     }
  410.     var u = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
  411.         c = {},
  412.         _ = {};
  413.     ! function() {
  414.         var e, t;
  415.         for (e = 0, t = u.length; e < t; ++e) _[u[e]] = e;
  416.         for (e = 0; e < 16; ++e) c["0123456789abcdef" [e]] = e;
  417.         for (e = 0; e < 16; ++e) c["0123456789ABCDEF" [e]] = e
  418.     }(), e.exports = {
  419.         fromBytes: function(e, t) {
  420.             return i(a(o(e.slice(0).reverse(), 256, 62), t), u).join("")
  421.         },
  422.         toBytes: function(e, t) {
  423.             return a(o(i(e, _), 62, 256), t).reverse()
  424.         },
  425.         toHex: function(e, t) {
  426.             return i(a(o(i(e, _), 62, 16), t), u).join("")
  427.         },
  428.         fromHex: function(e, t) {
  429.             return i(a(o(i(e, c), 16, 62), t), u).join("")
  430.         }
  431.     }
  432. }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement