UNPKG

react-jw-player

Version:

A React component for launching JW Player instances on the client.

62 lines (51 loc) 1.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function onTime(event) { var hasFired = this.state.hasFired; var position = event.position, duration = event.duration; var hasChanged = false; if (!hasFired.threeSeconds && position > 3) { this.props.onThreeSeconds(); hasFired.threeSeconds = true; hasChanged = true; } if (!hasFired.tenSeconds && position > 10) { this.props.onTenSeconds(); hasFired.tenSeconds = true; hasChanged = true; } if (!hasFired.thirtySeconds && position > 30) { this.props.onThirtySeconds(); hasFired.thirtySeconds = true; hasChanged = true; } if (!hasFired.twentyFivePercent && position / duration * 100 > 25) { this.props.onTwentyFivePercent(); hasFired.twentyFivePercent = true; hasChanged = true; } if (!hasFired.fiftyPercent && position / duration * 100 > 50) { this.props.onFiftyPercent(); hasFired.fiftyPercent = true; hasChanged = true; } if (!hasFired.seventyFivePercent && position / duration * 100 > 75) { this.props.onSeventyFivePercent(); hasFired.seventyFivePercent = true; hasChanged = true; } if (!hasFired.ninetyFivePercent && position / duration * 100 > 95) { this.props.onNinetyFivePercent(); hasFired.ninetyFivePercent = true; hasChanged = true; } if (hasChanged) { this.setState({ hasFired: hasFired }); } } exports.default = onTime;