PlayerDebug.jsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. privatePlaylistQueue: state.station.info.get("privatePlaylistQueue"),
  18. }))
  19. export default class PlayerDebug extends Component {
  20. static propTypes = {
  21. };
  22. static defaultProps = {
  23. };
  24. constructor(props) {
  25. super(props);
  26. }
  27. /*getTimeElapsed = () => {
  28. if (this.props.exists) {
  29. // TODO Replace with Date.currently
  30. let timePausedNow = 0;
  31. if (this.props.paused) timePausedNow = Date.now() - this.props.pausedAt;
  32. return Date.now() - this.props.startedAt - this.props.timePaused - timePausedNow;
  33. } else return 0;
  34. };*/
  35. render() {
  36. return (
  37. <div style={{border: "1px solid black"}}>
  38. <h3>Volume</h3>
  39. <b>Loudness: </b> { this.props.volume } <br/>
  40. <b>Muted: </b> { this.props.muted.toString() } <br/>
  41. <hr/>
  42. <h3>Station info</h3>
  43. <b>Paused: </b> { this.props.paused.toString() } <br/>
  44. <b>Mode: </b> { this.props.mode } <br/>
  45. <hr/>
  46. <h3>Current song</h3>
  47. <b>Song id: </b> { this.props.songId } <br/>
  48. <b>Duration: </b> { this.props.duration } <br/>
  49. <b>Skip duration: </b> { this.props.skipDuration } <br/>
  50. <b>Time elapsed: </b> { this.props.timeElapsed } <br/>
  51. <b>Time paused: </b> { this.props.timePaused } <br/>
  52. <b>Paused at: </b> { this.props.pausedAt } <br/>
  53. <b>Started at: </b> { this.props.startedAt } <br/>
  54. <b>Exists: </b> { this.props.exists.toString() } <br/>
  55. <h3>Adding to queue</h3>
  56. <b>Playlist to queue: </b> { this.props.privatePlaylistQueue } <br/>
  57. <hr/>
  58. </div>
  59. );
  60. }
  61. }