react-player
Advanced tools
Comparing version 0.5.2 to 0.5.3
@@ -7,2 +7,10 @@ # Change Log | ||
#### [v0.5.3](https://github.com/CookPete/react-player/compare/v0.5.2...v0.5.3) | ||
> 26 January 2016 | ||
* Support YouTube start time param [`7908463`](https://github.com/CookPete/react-player/commit/7908463d2dc1d3f59910432edd45460da152d426) | ||
* Add onError tests [`9626ccb`](https://github.com/CookPete/react-player/commit/9626ccbcb5b5b22496c1e02cb702e633e65b803b) | ||
* Better karma test grouping [`8a3d4e8`](https://github.com/CookPete/react-player/commit/8a3d4e83944466945002634c84a1c1bfa5035fd9) | ||
#### [v0.5.2](https://github.com/CookPete/react-player/compare/v0.5.1...v0.5.2) | ||
@@ -9,0 +17,0 @@ > 25 January 2016 |
@@ -34,4 +34,6 @@ 'use strict'; | ||
var RESOLVE_URL = '//api.soundcloud.com/resolve.json'; | ||
var MATCH_URL = /^https?:\/\/(soundcloud.com|snd.sc)\/([a-z0-9-]+\/[a-z0-9-]+)$/; | ||
var MATCH_URL = /^https?:\/\/(soundcloud.com|snd.sc)\/([a-z0-9-_]+\/[a-z0-9-_]+)$/; | ||
var songData = {}; // Cache song data requests | ||
var SoundCloud = function (_Base) { | ||
@@ -88,4 +90,14 @@ _inherits(SoundCloud, _Base); | ||
value: function getSongData(url) { | ||
if (songData[url]) { | ||
return Promise.resolve(songData[url]); | ||
} | ||
return fetch(RESOLVE_URL + '?url=' + url + '&client_id=' + this.props.soundcloudConfig.clientId).then(function (response) { | ||
return response.json(); | ||
if (response.status >= 200 && response.status < 300) { | ||
songData[url] = response.json(); | ||
return songData[url]; | ||
} else { | ||
var error = new Error(response.statusText); | ||
error.response = response; | ||
throw error; | ||
} | ||
}); | ||
@@ -101,3 +113,9 @@ } | ||
_this3.getSongData(url).then(function (data) { | ||
if (url !== _this3.props.url) return; // Abort if url changes during async requests | ||
if (url !== _this3.props.url) { | ||
return; // Abort if url changes during async requests | ||
} | ||
if (!data.streamable) { | ||
_this3.props.onError(new Error('SoundCloud track is not streamable')); | ||
return; | ||
} | ||
var image = data.artwork_url || data.user.avatar_url; | ||
@@ -112,4 +130,4 @@ if (image) { | ||
}); | ||
}); | ||
}); | ||
}, _this3.props.onError); | ||
}, this.props.onError); | ||
} | ||
@@ -116,0 +134,0 @@ }, { |
@@ -25,2 +25,4 @@ 'use strict'; | ||
var _utils = require('../utils'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -112,3 +114,6 @@ | ||
if (this.isReady) { | ||
this.player.cueVideoById(id); | ||
this.player.cueVideoById({ | ||
videoId: id, | ||
startSeconds: (0, _utils.parseStartTime)(url) | ||
}); | ||
return; | ||
@@ -126,3 +131,5 @@ } | ||
videoId: id, | ||
playerVars: _extends({}, DEFAULT_PLAYER_VARS, _this2.props.youtubeConfig.playerVars), | ||
playerVars: _extends({}, DEFAULT_PLAYER_VARS, _this2.props.youtubeConfig.playerVars, { | ||
start: (0, _utils.parseStartTime)(url) | ||
}), | ||
events: { | ||
@@ -134,6 +141,8 @@ onReady: function onReady() { | ||
onStateChange: _this2.onStateChange, | ||
onError: _this2.props.onError | ||
onError: function onError(event) { | ||
return _this2.props.onError(event.data); | ||
} | ||
} | ||
}); | ||
}); | ||
}, this.props.onError); | ||
} | ||
@@ -180,3 +189,3 @@ }, { | ||
value: function getFractionPlayed() { | ||
if (!this.isReady || !this.player.getCurrentTime) return null; | ||
if (!this.isReady || !this.getDuration()) return null; | ||
return this.player.getCurrentTime() / this.getDuration(); | ||
@@ -183,0 +192,0 @@ } |
{ | ||
"name": "react-player", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "A react component for playing a variety of URLs, including file paths, YouTube, SoundCloud and Vimeo", | ||
@@ -84,3 +84,3 @@ "main": "lib/ReactPlayer.js", | ||
"webpack-hot-middleware": "^2.6.0", | ||
"whatwg-fetch": "^0.10.1" | ||
"whatwg-fetch": "^0.11.0" | ||
}, | ||
@@ -87,0 +87,0 @@ "dependencies": { |
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
1
69350
17
941