Skip to content

Commit

Permalink
Fix: signal multiple sources change to the browser (#482)
Browse files Browse the repository at this point in the history
  • Loading branch information
belgattitude authored and seniorapple committed Sep 20, 2018
1 parent dcf73cc commit eee2514
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Player.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react'

import { propTypes, defaultProps } from './props'
import { isEqual } from './utils'

const SEEK_ON_PLAY_EXPIRY = 5000

Expand Down Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion src/players/FilePlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (<source>) 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) {
Expand Down

0 comments on commit eee2514

Please sign in to comment.