|
|
@ -151,10 +151,23 @@ const Icon = ({
|
|
|
|
|
|
|
|
|
|
|
|
export class Lightbox extends React.Component<Props> {
|
|
|
|
export class Lightbox extends React.Component<Props> {
|
|
|
|
private containerRef: HTMLDivElement | null = null;
|
|
|
|
private containerRef: HTMLDivElement | null = null;
|
|
|
|
|
|
|
|
private videoRef: HTMLVideoElement | null = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private captureVideoBound: (element: HTMLVideoElement) => void;
|
|
|
|
|
|
|
|
private playVideoBound: () => void;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(props: Props) {
|
|
|
|
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.captureVideoBound = this.captureVideo.bind(this);
|
|
|
|
|
|
|
|
this.playVideoBound = this.playVideo.bind(this);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public componentDidMount() {
|
|
|
|
public componentDidMount() {
|
|
|
|
const useCapture = true;
|
|
|
|
const useCapture = true;
|
|
|
|
document.addEventListener('keyup', this.onKeyUp, useCapture);
|
|
|
|
document.addEventListener('keyup', this.onKeyUp, useCapture);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.playVideo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public componentWillUnmount() {
|
|
|
|
public componentWillUnmount() {
|
|
|
@ -162,6 +175,22 @@ export class Lightbox extends React.Component<Props> {
|
|
|
|
document.removeEventListener('keyup', this.onKeyUp, useCapture);
|
|
|
|
document.removeEventListener('keyup', this.onKeyUp, useCapture);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public captureVideo(element: HTMLVideoElement) {
|
|
|
|
|
|
|
|
this.videoRef = element;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public playVideo() {
|
|
|
|
|
|
|
|
if (!this.videoRef) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.videoRef.paused) {
|
|
|
|
|
|
|
|
this.videoRef.play();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
this.videoRef.pause();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public render() {
|
|
|
|
public render() {
|
|
|
|
const {
|
|
|
|
const {
|
|
|
|
contentType,
|
|
|
|
contentType,
|
|
|
@ -237,7 +266,13 @@ export class Lightbox extends React.Component<Props> {
|
|
|
|
const isVideoTypeSupported = GoogleChrome.isVideoTypeSupported(contentType);
|
|
|
|
const isVideoTypeSupported = GoogleChrome.isVideoTypeSupported(contentType);
|
|
|
|
if (isVideoTypeSupported) {
|
|
|
|
if (isVideoTypeSupported) {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<video controls={true} style={styles.object}>
|
|
|
|
<video
|
|
|
|
|
|
|
|
role="button"
|
|
|
|
|
|
|
|
ref={this.captureVideoBound}
|
|
|
|
|
|
|
|
onClick={this.playVideoBound}
|
|
|
|
|
|
|
|
controls={true}
|
|
|
|
|
|
|
|
style={styles.object}
|
|
|
|
|
|
|
|
>
|
|
|
|
<source src={objectURL} />
|
|
|
|
<source src={objectURL} />
|
|
|
|
</video>
|
|
|
|
</video>
|
|
|
|
);
|
|
|
|
);
|
|
|
|