Rework website with bulma instead of bootstrap #6
|
@ -67,14 +67,22 @@ class MusicPlayer extends React.Component<MusicPlayerProps, State> {
|
|||
}
|
||||
|
||||
if (this.props.playing) {
|
||||
source
|
||||
.play()
|
||||
.then(() => {
|
||||
console.info("Started playing audio");
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(`Could not play audio: ${error}`);
|
||||
});
|
||||
// Chrome is super awkward about AudioContext, and won't
|
||||
// even allow creating one without complaining about
|
||||
// wanting user input, so we need to resume the context
|
||||
// before we can actually play.
|
||||
//
|
||||
// Luckily, this has no adverse effects on Firefox.
|
||||
context.resume().then(() => {
|
||||
source
|
||||
.play()
|
||||
.then(() => {
|
||||
console.info("Started playing audio");
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(`Could not play audio: ${error}`);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
source.pause();
|
||||
}
|
||||
|
|
Reference in a new issue