react-player
Advanced tools
Comparing version 0.3.4 to 0.3.5
@@ -7,2 +7,9 @@ # Change Log | ||
#### [v0.3.5](https://github.com/CookPete/react-player/compare/v0.3.4...v0.3.5) | ||
> 4 January 2016 | ||
* Fix YouTube onReady bugs [`#21`](https://github.com/CookPete/react-player/pull/21) | ||
* Set isReady before setVolume in onReady [`#23`](https://github.com/CookPete/react-player/issues/23) | ||
#### [v0.3.4](https://github.com/CookPete/react-player/compare/v0.3.3...v0.3.4) | ||
@@ -9,0 +16,0 @@ > 3 January 2016 |
@@ -32,7 +32,11 @@ 'use strict'; | ||
this.onReady = function () { | ||
_this.isReady = true; | ||
_this.setVolume(_this.props.volume); | ||
if (_this.props.playing || _this.preloading) { | ||
_this.preloading = false; | ||
_this.isReady = true; | ||
_this.play(); | ||
if (_this.loadOnReady) { | ||
_this.load(_this.loadOnReady, _this.props.playing); | ||
} else { | ||
_this.play(); | ||
} | ||
} | ||
@@ -39,0 +43,0 @@ }; |
@@ -33,2 +33,3 @@ 'use strict'; | ||
var SDK_GLOBAL = 'YT'; | ||
var SDK_GLOBAL_READY = 'onYouTubeIframeAPIReady'; | ||
var MATCH_URL = /^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/; | ||
@@ -43,3 +44,3 @@ var PLAYER_ID = 'youtube-player'; | ||
var count = 0; | ||
var playerIdCount = 0; | ||
@@ -56,10 +57,16 @@ var YouTube = (function (_Base) { | ||
this.playerId = PLAYER_ID + '-' + count++; | ||
this.playerId = PLAYER_ID + '-' + playerIdCount++; | ||
this.onStateChange = function (state) { | ||
var YT = window[SDK_GLOBAL]; | ||
if (state.data === YT.PlayerState.PLAYING) _this.props.onPlay(); | ||
if (state.data === YT.PlayerState.PAUSED) _this.props.onPause(); | ||
if (state.data === YT.PlayerState.BUFFERING) _this.props.onBuffer(); | ||
if (state.data === YT.PlayerState.ENDED) _this.props.onEnded(); | ||
this.onStateChange = function (_ref) { | ||
var data = _ref.data; | ||
var _window$SDK_GLOBAL$PlayerState = window[SDK_GLOBAL].PlayerState; | ||
var PLAYING = _window$SDK_GLOBAL$PlayerState.PLAYING; | ||
var PAUSED = _window$SDK_GLOBAL$PlayerState.PAUSED; | ||
var BUFFERING = _window$SDK_GLOBAL$PlayerState.BUFFERING; | ||
var ENDED = _window$SDK_GLOBAL$PlayerState.ENDED; | ||
if (data === PLAYING) _this.props.onPlay(); | ||
if (data === PAUSED) _this.props.onPause(); | ||
if (data === BUFFERING) _this.props.onBuffer(); | ||
if (data === ENDED) _this.props.onEnded(); | ||
}; | ||
@@ -84,4 +91,4 @@ } | ||
return new Promise(function (resolve, reject) { | ||
var previousOnReady = window.onYouTubeIframeAPIReady; | ||
window.onYouTubeIframeAPIReady = function () { | ||
var previousOnReady = window[SDK_GLOBAL_READY]; | ||
window[SDK_GLOBAL_READY] = function () { | ||
if (previousOnReady) previousOnReady(); | ||
@@ -110,2 +117,7 @@ resolve(window[SDK_GLOBAL]); | ||
} | ||
if (this.loadingSDK) { | ||
this.loadOnReady = url; | ||
return; | ||
} | ||
this.loadingSDK = true; | ||
this.getSDK().then(function (YT) { | ||
@@ -118,3 +130,6 @@ _this2.player = new YT.Player(_this2.playerId, { | ||
events: { | ||
onReady: _this2.onReady, | ||
onReady: function onReady() { | ||
_this2.loadingSDK = false; | ||
_this2.onReady(); | ||
}, | ||
onStateChange: _this2.onStateChange, | ||
@@ -121,0 +136,0 @@ onError: _this2.props.onError |
{ | ||
"name": "react-player", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"description": "A react component for playing a variety of URLs, including file paths, YouTube, SoundCloud and Vimeo", | ||
@@ -14,2 +14,3 @@ "main": "lib/ReactPlayer.js", | ||
"postpublish": "npm run clean", | ||
"preversion": "npm run lint && npm run test", | ||
"version": "auto-changelog --package --template compact; git add CHANGELOG.md" | ||
@@ -16,0 +17,0 @@ }, |
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
65184
1182