Implemented the ability for the spacebar to initiate video playback
This commit is contained in:
parent
b43ed0b64f
commit
fb3785feed
2 changed files with 21 additions and 7 deletions
|
@ -4,12 +4,23 @@ import Link from "component/link";
|
|||
import Modal from "component/modal";
|
||||
|
||||
class VideoPlayButton extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
document.addEventListener("keydown", this.onKeyDown.bind(this));
|
||||
}
|
||||
|
||||
onPurchaseConfirmed() {
|
||||
this.props.closeModal();
|
||||
this.props.startPlaying();
|
||||
this.props.loadVideo(this.props.uri);
|
||||
}
|
||||
|
||||
onKeyDown(event) {
|
||||
if (event.keyCode === 32) {
|
||||
event.preventDefault();
|
||||
this.onWatchClick();
|
||||
}
|
||||
}
|
||||
|
||||
onWatchClick() {
|
||||
this.props.purchaseUri(this.props.uri).then(() => {
|
||||
if (!this.props.modal) {
|
||||
|
@ -45,9 +56,10 @@ class VideoPlayButton extends React.PureComponent {
|
|||
isLoading ||
|
||||
fileInfo === undefined ||
|
||||
(fileInfo === null && (!costInfo || costInfo.cost === undefined));
|
||||
const icon = ["audio", "video"].indexOf(mediaType) !== -1
|
||||
? "icon-play"
|
||||
: "icon-folder-o";
|
||||
const icon =
|
||||
["audio", "video"].indexOf(mediaType) !== -1
|
||||
? "icon-play"
|
||||
: "icon-folder-o";
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
@ -73,9 +85,11 @@ class VideoPlayButton extends React.PureComponent {
|
|||
onConfirmed={this.onPurchaseConfirmed.bind(this)}
|
||||
onAborted={closeModal}
|
||||
>
|
||||
{__("This will purchase")} <strong>{title}</strong> {__("for")}
|
||||
{" "}<strong><FilePrice uri={uri} look="plain" /></strong>
|
||||
{" "}{__("credits")}.
|
||||
{__("This will purchase")} <strong>{title}</strong> {__("for")}{" "}
|
||||
<strong>
|
||||
<FilePrice uri={uri} look="plain" />
|
||||
</strong>{" "}
|
||||
{__("credits")}.
|
||||
</Modal>
|
||||
<Modal
|
||||
isOpen={modal == "timedOut"}
|
||||
|
|
|
@ -29,7 +29,7 @@ class VideoPlayer extends React.PureComponent {
|
|||
player.append(
|
||||
this.file(),
|
||||
container,
|
||||
{ autoplay: false, controls: true },
|
||||
{ autoplay: false, controls: true, enableKeyboard: true },
|
||||
renderMediaCallback.bind(this)
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue