PlayerDebug.jsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import React, { Component } from "react";
  2. import PropTypes from "prop-types";
  3. import { connect } from "react-redux";
  4. @connect(state => ({
  5. volume: state.volume.get("loudness"),
  6. muted: state.volume.get("muted"),
  7. songId: state.station.currentSong.get("songId"),
  8. duration: state.station.currentSong.getIn(["timings", "duration"]),
  9. skipDuration: state.station.currentSong.getIn(["timings", "skipDuration"]),
  10. timeElapsed: state.station.currentSong.getIn(["timings", "timeElapsed"]),
  11. timePaused: state.station.currentSong.getIn(["timings", "timePaused"]),
  12. pausedAt: state.station.currentSong.getIn(["timings", "pausedAt"]),
  13. startedAt: state.station.currentSong.getIn(["timings", "startedAt"]),
  14. exists: state.station.currentSong.get("songId") !== "",
  15. paused: state.station.info.get("paused"),
  16. mode: state.station.info.get("mode"),
  17. }))
  18. export default class PlayerDebug extends Component {
  19. static propTypes = {
  20. };
  21. static defaultProps = {
  22. };
  23. constructor(props) {
  24. super(props);
  25. }
  26. /*getTimeElapsed = () => {
  27. if (this.props.exists) {
  28. // TODO Replace with Date.currently
  29. let timePausedNow = 0;
  30. if (this.props.paused) timePausedNow = Date.now() - this.props.pausedAt;
  31. return Date.now() - this.props.startedAt - this.props.timePaused - timePausedNow;
  32. } else return 0;
  33. };*/
  34. render() {
  35. return (
  36. <div style={{border: "1px solid black"}}>
  37. <h3>Volume</h3>
  38. <b>Loudness: </b> { this.props.volume } <br/>
  39. <b>Muted: </b> { this.props.muted.toString() } <br/>
  40. <hr/>
  41. <h3>Station info</h3>
  42. <b>Paused: </b> { this.props.paused.toString() } <br/>
  43. <b>Mode: </b> { this.props.mode } <br/>
  44. <hr/>
  45. <h3>Current song</h3>
  46. <b>Song id: </b> { this.props.songId } <br/>
  47. <b>Duration: </b> { this.props.duration } <br/>
  48. <b>Skip duration: </b> { this.props.skipDuration } <br/>
  49. <b>Time elapsed: </b> { this.props.timeElapsed } <br/>
  50. <b>Time paused: </b> { this.props.timePaused } <br/>
  51. <b>Paused at: </b> { this.props.pausedAt } <br/>
  52. <b>Started at: </b> { this.props.startedAt } <br/>
  53. <b>Exists: </b> { this.props.exists.toString() } <br/>
  54. <hr/>
  55. </div>
  56. );
  57. }
  58. }