Skip to content

Commit

Permalink
Prevent errors when unmounting before SDK loads
Browse files Browse the repository at this point in the history
  • Loading branch information
cookpete committed Oct 28, 2017
1 parent d3401dc commit 979e639
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/players/DailyMotion.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default class DailyMotion extends Component {
return
}
getSDK(SDK_URL, SDK_GLOBAL, SDK_GLOBAL_READY, DM => DM.player).then(DM => {
if (!this.container) return
const Player = DM.player
this.player = new Player(this.container, {
width: '100%',
Expand Down
1 change: 1 addition & 0 deletions src/players/SoundCloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default class SoundCloud extends Component {
fractionLoaded = null
load (url, isReady) {
getSDK(SDK_URL, SDK_GLOBAL).then(SC => {
if (!this.iframe) return
const { PLAY, PLAY_PROGRESS, PAUSE, FINISH, ERROR } = SC.Widget.Events
if (!isReady) {
this.player = SC.Widget(this.iframe)
Expand Down
1 change: 1 addition & 0 deletions src/players/Streamable.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default class Streamable extends Component {
secondsLoaded = null
load (url) {
getSDK(SDK_URL, SDK_GLOBAL).then(playerjs => {
if (!this.iframe) return
this.player = new playerjs.Player(this.iframe)
this.player.on('ready', this.props.onReady)
this.player.on('play', this.props.onPlay)
Expand Down
1 change: 1 addition & 0 deletions src/players/Vidme.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default class Vidme extends FilePlayer {
const { onError } = this.props
this.stop()
this.getData(url).then(data => {
if (!this.player) return
this.player.src = this.getURL(data)
}, onError)
}
Expand Down
1 change: 1 addition & 0 deletions src/players/Vimeo.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default class Vimeo extends Component {
return
}
getSDK(SDK_URL, SDK_GLOBAL).then(Vimeo => {
if (!this.container) return
this.player = new Vimeo.Player(this.container, {
...this.props.config.vimeo.playerOptions,
url,
Expand Down
1 change: 1 addition & 0 deletions src/players/YouTube.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default class YouTube extends Component {
return
}
getSDK(SDK_URL, SDK_GLOBAL, SDK_GLOBAL_READY, YT => YT.loaded).then(YT => {
if (!this.container) return
this.player = new YT.Player(this.container, {
width: '100%',
height: '100%',
Expand Down

0 comments on commit 979e639

Please sign in to comment.