documentation

This commit is contained in:
2022-02-07 20:08:52 -06:00
parent 8aa9ef9ae7
commit 24493767f9
2 changed files with 13 additions and 6 deletions

View File

@@ -95,7 +95,13 @@ img, video {
/* Video player */
.video-player {
display: inline-flex;
}
.post-audio, .post-video {
position: absolute;
}
/* Handles comment styles on toggle */

View File

@@ -2,16 +2,17 @@ import { useState, useEffect, useRef } from 'react';
export default function VideoPlayer({data, src}) {
const vid = useRef();
const aud = useRef();
const aud = useRef(); // identifies location of video/audio in DOM
const [playing, setPlaying] = useState(false); // handles play/pause logic
const crossPostSrc = src;
let url = crossPostSrc ? crossPostSrc :
(data.url ? data.url : null);
const [playing, setPlaying] = useState(false);
let url = crossPostSrc ? crossPostSrc : // sets video source according to applicable
(data.url ? data.url : null); // location within reddit response
useEffect(() => {
if (playing) {
useEffect(() => { // synchronizes play/pause between two components
if (playing) { // according to section of state
vid.current.play();
vid.current.currentTime = aud.current.currentTime;
} else if (!playing) {