question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Programatically setting playing to true or false does nothing

See original GitHub issue

I want to use the player with custom controls so I’ve set controls to false and set playing equal to a state variable. Changing the variable does nothing, neither does just setting playing to true. Even if initialized with playing set to true there is no audio.

import React from 'react'
import { connect } from 'react-redux'
import ReactPlayer from 'react-player'

class Player extends React.Component {
  
  componentWillReceiveProps(nextProps) {
    console.log(nextProps)
   // logs as expected
  }
  
  render() {
    
    const { audioPlayer } = this.props

    return (
      <ReactPlayer
        url='https://s3.amazonaws.com/*************/30rocktheme.mp3'
        playing={audioPlayer.isPlaying}
      />
    )
  }
}

export default connect(store => ({
  audioPlayer: store.audioPlayer,
}))(Player)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
artemis-primecommented, Sep 7, 2020

Why is this closed?? I’m experiencing this on Chrome / Linux. In the below component, the clicking the button has no effect.

const Player = ({ url }) => {
  
  const [playing, setPlaying] = useState(false)

  return (
    <div style={{position: 'relative'}}>
      <ReactPlayer
        allowFullScreen="allowFullScreen"
        frameBorder="0"
        className={s.player}
        url={url}
        width='100%'
        height='100%'
        playing={playing}
        config={{
          youtube: {
            playerVars: {
              controls: 1,
              allowFullScreen: 1,
              showinfo: 1,
              playsinline: 1,
            }
          }
        }}
        onStart={onStart}
      />
      <button style={{position: 'absolute', right: 0, top: 0 }} onClick={() => {setPlaying(false)}}>pause / play</button>
    </div>
  )
}
0reactions
cookpetecommented, Sep 28, 2021

Why is this closed?

Explained in my previous comment:

If either of you have an example repo or jsFiddle where the issue is occuring consistently, feel free to reopen the issue.

It’s much harder for me to help if I can’t easily recreate the issue myself.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Programatically setting playing to true or false does nothing
I want to use the player with custom controls so I've set controls to false and set playing equal to a state variable....
Read more >
React-player play videos automatically when loaded without ...
Depends on browser which you are using but video must be muted if you want to autoplay without users interaction.
Read more >
Autoplay guide for media and Web Audio APIs
Automatically starting the playback of audio (or videos with audio tracks) immediately upon page load can be an unwelcome surprise to users.
Read more >
Scripting API: GameObject.SetActive - Unity - Manual
Activates/Deactivates the GameObject, depending on the given true or false value. A GameObject may be inactive because a parent is not active. In...
Read more >
Interact programmatically with the Navigation component
The Navigation component provides ways to programmatically create and interact with certain navigation elements.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found