Video player #14

Merged
innocuous-symmetry merged 10 commits from video-player into master 2022-02-08 17:36:39 +00:00
2 changed files with 13 additions and 6 deletions
Showing only changes of commit 24493767f9 - Show all commits

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) {