const React = require('react') const Bitfield = require('bitfield') const prettyBytes = require('prettier-bytes') const zeroFill = require('zero-fill') const TorrentSummary = require('../lib/torrent-summary') const {dispatch, dispatcher} = require('../lib/dispatcher') // Shows a streaming video player. Standard features + Chromecast + Airplay module.exports = class Player extends React.Component { render () { // Show the video as large as will fit in the window, play immediately // If the video is on Chromecast or Airplay, show a title screen instead var state = this.props.state var showVideo = state.playing.location === 'local' return (
{showVideo ? renderMedia(state) : renderCastScreen(state)} {renderPlayerControls(state)}
) } } // Handles volume change by wheel function handleVolumeWheel (e) { dispatch('changeVolume', (-e.deltaY | e.deltaX) / 500) } function renderMedia (state) { if (!state.server) return // Unfortunately, play/pause can't be done just by modifying HTML. // Instead, grab the DOM node and play/pause it if necessary // Get the