From a4b25359be070bbdb9114889304699a1c8165c0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Vanvelthem?= Date: Thu, 20 Sep 2018 15:30:30 +0200 Subject: [PATCH] Fix: signal multiple sources change to the browser (#482) --- src/Player.js | 3 ++- src/players/FilePlayer.js | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Player.js b/src/Player.js index a15c10bb..88c591d3 100644 --- a/src/Player.js +++ b/src/Player.js @@ -1,6 +1,7 @@ import React, { Component } from 'react' import { propTypes, defaultProps } from './props' +import { isEqual } from './utils' const SEEK_ON_PLAY_EXPIRY = 5000 @@ -32,7 +33,7 @@ export default class Player extends Component { componentWillReceiveProps (nextProps) { // Invoke player methods based on incoming props const { url, playing, volume, muted, playbackRate } = this.props - if (url !== nextProps.url) { + if (!isEqual(url, nextProps.url)) { if (this.isLoading) { console.warn(`ReactPlayer: the attempt to load ${nextProps.url} is being deferred until the player has loaded`) this.loadOnReady = nextProps.url diff --git a/src/players/FilePlayer.js b/src/players/FilePlayer.js index 1f509bc3..0e363d38 100644 --- a/src/players/FilePlayer.js +++ b/src/players/FilePlayer.js @@ -118,7 +118,14 @@ export class FilePlayer extends Component { this.dash.getDebug().setLogToBrowserConsole(false) }) } - if (isMediaStream(url)) { + + if (url instanceof Array) { + // When setting new urls () on an already loaded video, + // HTMLMediaElement.load() is needed to reset the media element + // and restart the media resource. Just replacing children source + // dom nodes is not enough + this.player.load() + } else if (isMediaStream(url)) { try { this.player.srcObject = url } catch (e) {