Skip to content

Instantly share code, notes, and snippets.

@ryanashcraft
Last active July 5, 2018 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanashcraft/6628691b636f426f60331d8db4d06dab to your computer and use it in GitHub Desktop.
Save ryanashcraft/6628691b636f426f60331d8db4d06dab to your computer and use it in GitHub Desktop.
AmpliTunes without react-amplitude
import React, { Fragment } from "react";
class NowPlayingView extends React.Component {
componentDidMount() {
this.props.logViewNowPlayingScreen();
}
componentDidUpdate = prevProps => {
if (prevProps.songId !== this.props.songId) {
this.props.logChangeSong(songId);
}
};
render() {
return (
<PlayControls
songId={this.props.songId}
genreId={this.props.genreId}
playlistId={this.props.playlistId}
isFavorited={this.props.isFavorited}
getTimeElapsed={this.props.getTimeElapsed}
/>
);
}
}
class PlayControls extends React.Component {
render() {
const commonProps = {
songId: this.props.songId,
genreId: this.props.genreId,
playlistId: this.props.playlistId,
isFavorited: this.props.isFavorited,
getTimeElapsed: this.props.getTimeElapsed
};
return (
<div>
<Seeker {...commonProps} />
<div>
<RewindButton {...commonProps} />
<PlayPauseButton {...commonProps} />
<FastForwardButton {...commonProps} />
</div>
<div>
<ShareMenu {...commonProps} />
</div>
</div>
);
}
}
class FastForwardButton extends React.Component {
fastForward = () => {
this.props.logFastForward({
songId: this.props.songId,
genreId: this.props.genreId,
playlistId: this.props.playlistId,
isFavorited: this.props.isFavorited,
timeElapsed: this.props.getTimeElapsed()
});
this.props.fastForward();
}
render() {
return (
<Button onClick={this.fastForward}>
<Icon name="FAST_FORWARD" />
</Button>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment