Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoplay on custom stream urls? #88

Open
davidfloegel opened this issue Aug 9, 2018 · 7 comments
Open

Autoplay on custom stream urls? #88

davidfloegel opened this issue Aug 9, 2018 · 7 comments

Comments

@davidfloegel
Copy link

Hi,

great plugin!

Is there a way to autoplay a custom track once the player has been mounted?

Thanks

David

@steveabouem
Copy link

steveabouem commented Aug 9, 2018

Running into same issue. Can't figure it out.

@steveabouem
Copy link

Figured it out. I manually triggered a click event on the button.
async componentDidMount() { /*get the button itself(i had 2 on my page)*/ const button = window.document.getElementsByTagName('button')[1] /*wait for the props to come in, in order for the click event to be called*/ await this.props /*manually trigger the click event.*/ button.click() }
This is the only lifecycle method that worked for me, others would start the video then stop it, because of incoming props( among which the default prop "playing: false").

@jlariza
Copy link

jlariza commented Aug 14, 2018

Hi! I have the same issue; I have not been able to use autoplay on a custom url.

@lcmartinezdev
Copy link

Hello, Any update?

@hansfpc
Copy link

hansfpc commented Oct 25, 2018

Any update?

@davalapar
Copy link

Workaround: set a global let var to true, on first time the track gets available, call the play() function and put the var to false so the user will be able to play / pause using the buttons.

let autoplay = true;

const SoundcloudPlayer = withSoundCloudAudio((props) => {
  const { soundCloudAudio, playing, track } = props;

  if (track && autoplay) {
    soundCloudAudio.play();
    autoplay = false;
  }

  // other code goes here
});

@sbrichardson
Copy link
Contributor

@davalapar, I would change the global to a flag on the component instance (this.autoplay), since multiple instances on the same page, or different pages that should keep auto playing would be affected by the one global. It could need a higher state manager though since only one player should auto play etc. Another fix is to, toggle the flag back to true on unmount.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants