mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
parent
f84fa2492f
commit
b83067d0ee
1 changed files with 9 additions and 31 deletions
|
@ -196,6 +196,7 @@ const Icon = ({
|
|||
/>
|
||||
);
|
||||
|
||||
// tslint:disable-next-line: max-func-body-length
|
||||
export const LightboxObject = ({
|
||||
objectURL,
|
||||
contentType,
|
||||
|
@ -216,37 +217,12 @@ export const LightboxObject = ({
|
|||
return false;
|
||||
}, []);
|
||||
|
||||
const playVideo = () => {
|
||||
if (!videoRef) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { current } = videoRef;
|
||||
if (!current) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (current.paused) {
|
||||
void current.play();
|
||||
} else {
|
||||
current.pause();
|
||||
}
|
||||
};
|
||||
|
||||
const pauseVideo = () => {
|
||||
if (!videoRef) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { current } = videoRef;
|
||||
if (current) {
|
||||
current.pause();
|
||||
}
|
||||
};
|
||||
|
||||
// auto play video on showing a video attachment
|
||||
useUnmount(() => {
|
||||
pauseVideo();
|
||||
if (!videoRef?.current) {
|
||||
return;
|
||||
}
|
||||
videoRef.current.pause.pause();
|
||||
});
|
||||
|
||||
if (isImageTypeSupported) {
|
||||
|
@ -263,13 +239,15 @@ export const LightboxObject = ({
|
|||
const isVideoTypeSupported = GoogleChrome.isVideoTypeSupported(contentType);
|
||||
if (isVideoTypeSupported) {
|
||||
if (urlToLoad) {
|
||||
playVideo();
|
||||
if (videoRef?.current.paused) {
|
||||
void videoRef.current.play();
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<video
|
||||
role="button"
|
||||
ref={videoRef}
|
||||
onClick={playVideo}
|
||||
controls={true}
|
||||
style={styles.object as any}
|
||||
key={urlToLoad}
|
||||
|
|
Loading…
Reference in a new issue