soundcloud-audio
Advanced tools
Comparing version 0.1.5 to 0.1.6
21
index.js
@@ -28,7 +28,11 @@ 'use strict'; | ||
url = this._baseUrl+'/resolve.json?url='+url+'&client_id='+this._clientId; | ||
url = this._baseUrl + '/resolve.json?url=' + url + '&client_id=' + this._clientId; | ||
this._jsonp(url, function (data) { | ||
if (data.tracks) { | ||
if (Array.isArray(data)) { | ||
var tracks = data; | ||
data = {tracks: tracks}; | ||
this._playlist = data; | ||
} else if (data.tracks) { | ||
this._playlist = data; | ||
} else { | ||
@@ -38,3 +42,6 @@ this._track = data; | ||
this.duration = data.duration/1000; // convert to seconds | ||
this.duration = data.duration && !isNaN(data.duration) ? | ||
data.duration / 1000 : // convert to seconds | ||
0; // no duration is zero | ||
callback(data); | ||
@@ -48,3 +55,3 @@ }.bind(this)); | ||
var id = 'jsonp_callback_'+Math.round(100000*Math.random()); | ||
var id = 'jsonp_callback_' + Math.round(100000 * Math.random()); | ||
window[id] = function (data) { | ||
@@ -83,3 +90,3 @@ if (script.parentNode) { | ||
this._track = {stream_url: streamUrl}; | ||
this.audio.src = streamUrl+'?client_id='+this._clientId; | ||
this.audio.src = streamUrl + '?client_id=' + this._clientId; | ||
}; | ||
@@ -113,3 +120,3 @@ | ||
src += '?client_id='+this._clientId; | ||
src += '?client_id=' + this._clientId; | ||
@@ -137,3 +144,3 @@ if (src !== this.audio.src) { | ||
var tracksLength = this._playlist.tracks.length; | ||
if (this._playlistIndex >= tracksLength-1) { | ||
if (this._playlistIndex >= tracksLength - 1) { | ||
return; | ||
@@ -140,0 +147,0 @@ } |
{ | ||
"name": "soundcloud-audio", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Play SoundCloud tracks and playslists in modern browsers with HTML5 Audio API", | ||
@@ -33,6 +33,9 @@ "main": "index.js", | ||
"browserify": "^8.1.0", | ||
"chai": "^3.3.0", | ||
"jasmine-core": "^2.1.3", | ||
"karma": "^0.12.31", | ||
"karma-chai": "^0.1.0", | ||
"karma-chrome-launcher": "^0.1.7", | ||
"karma-jasmine": "^0.3.4", | ||
"karma-mocha": "^0.2.0", | ||
"mocha": "^2.3.3", | ||
"uglify-js": "^2.4.16", | ||
@@ -39,0 +42,0 @@ "watchify": "^2.2.1" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15114
9
161
10