Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

soundcloud-audio

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

soundcloud-audio - npm Package Compare versions

Comparing version 0.1.7 to 1.0.0

52

index.js
'use strict';
var anchor;
var keys = 'protocol hostname host pathname port search hash href'.split(' ');
function _parseURL (url) {
if (!anchor) {
anchor = document.createElement('a');
}
anchor.href = url || '';
var result = {}
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i];
result[key] = anchor[key];
}
return result;
}
function _appendQueryParam (url, param, value) {
var U = _parseURL(url);
var regex = /\?(?:.*)$/;
var chr = regex.test(U.search) ? '&' : '?';
var result = U.protocol + '//' + U.host + U.port + U.pathname + U.search + chr + param + '=' + value + U.hash;
return result;
}
function SoundCloud (clientId) {

@@ -23,9 +46,2 @@ if (!(this instanceof SoundCloud)) {

SoundCloud.prototype.appendQueryParam = function(url, param, value) {
var regex = /\?(?:.*)$/;
var chr = regex.test(url) ? '&' : '?';
return url + chr + param + '=' + value;
};
SoundCloud.prototype.resolve = function (url, callback) {

@@ -36,5 +52,6 @@ if (!url) {

url = this._baseUrl + '/resolve.json?url=' + url + '&client_id=' + this._clientId;
var resolveUrl = this._baseUrl + '/resolve.json?url=' + encodeURIComponent(url) + '&client_id=' + this._clientId;
this._jsonp(resolveUrl, function (data) {
this.cleanData();
this._jsonp(url, function (data) {
if (Array.isArray(data)) {

@@ -48,2 +65,6 @@ var tracks = data;

this._track = data;
// save timings
var U = _parseURL(url);
this._track.stream_url += U.hash;
}

@@ -63,3 +84,3 @@

var id = 'jsonp_callback_' + Math.round(100000 * Math.random());
var id = 'jsonp_callback_' + (new Date()).valueOf();
window[id] = function (data) {

@@ -73,3 +94,3 @@ if (script.parentNode) {

script.src = url + (url.indexOf('?') >= 0 ? '&' : '?') + 'callback=' + id;
script.src = _appendQueryParam(url, 'callback', id);
target.parentNode.insertBefore(script, target);

@@ -99,3 +120,3 @@ };

this._track = {stream_url: streamUrl};
this.audio.src = streamUrl + '?client_id=' + this._clientId;
this.audio.src = _appendQueryParam(streamUrl, 'client_id', this._clientId);
};

@@ -129,3 +150,3 @@

src = this.appendQueryParam(src, 'client_id', this._clientId);
src = _appendQueryParam(src, 'client_id', this._clientId);

@@ -178,2 +199,7 @@ if (src !== this.audio.src) {

SoundCloud.prototype.cleanData = function () {
this._track = void 0;
this._playlist = void 0;
};
module.exports = SoundCloud;
{
"name": "soundcloud-audio",
"version": "0.1.7",
"version": "1.0.0",
"description": "Play SoundCloud tracks and playslists in modern browsers with HTML5 Audio API",

@@ -5,0 +5,0 @@ "main": "index.js",

# <img src="http://www.officialpsds.com/images/thumbs/Soundcloud-Logo-psd47614.png" width="75" align="left">&nbsp;soundcloud-audio.js
[![build status](http://img.shields.io/travis/voronianski/soundcloud-audio.js.svg?style=flat)](https://travis-ci.org/voronianski/soundcloud-audio.js)
[![npm version](http://badge.fury.io/js/soundcloud-audio.svg)](http://badge.fury.io/js/soundcloud-audio)
[![Download Count](http://img.shields.io/npm/dm/soundcloud-audio.svg?style=flat)](http://www.npmjs.com/package/soundcloud-audio)

@@ -5,0 +7,0 @@ > Wrapper around [HTML5 `<audio>`](https://developer.mozilla.org/en/docs/Web/HTML/Element/audio) and SoundCloud [tracks](https://developers.soundcloud.com/docs/api/reference#tracks) and [playlists](https://developers.soundcloud.com/docs/api/reference#playlists) APIs. It could be treated as small replacement for official [SoundCloud SDK](https://developers.soundcloud.com/docs/api/sdks#javascript).

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc