This repository has been archived on 2021-06-30. You can view files and clone it, but cannot push or open issues or pull requests.
melodii/src/components/AlbumArt.js
2019-02-08 19:34:04 -06:00

32 lines
887 B
JavaScript

import React from 'react';
import noalbumart from '../assets/img/noalbumart.png';
import Emitter from '../melodii/Events';
export default class AlbumArt extends React.Component {
constructor() {
super();
this.state = {albumArt: noalbumart};
this.handleEvents();
}
shouldComponentUpdate(nextprops, nextState) {
return this.state.albumArt !== nextState.albumArt;
}
render() {
console.log("Album Art Updated");
return (
<div id='albumContainer'>
<img alt='Album-Art' src={this.state.albumArt} id='albumImg'></img>
</div>
);
}
/**
* @listens Song#updateAlbumArt Updates Album Art
*/
handleEvents() {
Emitter.on('updateAlbumArt', (blob, err) => {
if (err) throw err;
this.setState({albumArt: blob});
});
}
}