From fd61e89daffeafa7ac856965d8a718819436207d Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sat, 21 Sep 2024 08:10:38 -0400 Subject: [PATCH] Looking good! --- frontend/src/Call/CallPlayer.js | 17 ++-- frontend/src/Call/components/MediaPlayer.css | 34 +++++++- frontend/src/Call/components/MediaPlayer.js | 81 ++++++++++++-------- 3 files changed, 91 insertions(+), 41 deletions(-) diff --git a/frontend/src/Call/CallPlayer.js b/frontend/src/Call/CallPlayer.js index b7401b3..cefda02 100644 --- a/frontend/src/Call/CallPlayer.js +++ b/frontend/src/Call/CallPlayer.js @@ -19,8 +19,10 @@ import { MessageHeader, Button, ButtonContent, + Checkbox, GridColumn, Grid, GridRow, + Form } from "semantic-ui-react"; import "./CallPlayer.css"; import queryString from '../query-string'; @@ -179,6 +181,10 @@ function CallPlayer(props) { setStatusVisible(false); } + let autoplayClassName = "button-item"; + if (autoPlay) { + autoplayClassName += " active"; + } return (
@@ -207,24 +213,23 @@ function CallPlayer(props) {
-
handleAutoPlay(autoPlay)}>Autoplay
+
handleAutoPlay(autoPlay)}>Autoplay
-
+
Donate } />
-
+ -
- +
Link -
+
diff --git a/frontend/src/Call/components/MediaPlayer.css b/frontend/src/Call/components/MediaPlayer.css index d880b06..22a68ba 100644 --- a/frontend/src/Call/components/MediaPlayer.css +++ b/frontend/src/Call/components/MediaPlayer.css @@ -20,23 +20,51 @@ } .label-item { - padding: 5px; - width: 150px; + padding: 9px 2px 5px 2px; + width: 125px; color: white; font-weight: bold; text-align: center; } .mediaplayer-item { - padding: 5px; + + padding: 9px 5px 5px 5px; flex-grow: 1; color: white; font-weight: bold; text-align: center; } .button-item { + cursor:pointer; + display: flex; + justify-content: center; + align-items: center; padding: 5px; width: 100px; color: white; font-weight: bold; text-align: center; } + .active{ +background-color: #5c5c5c; + } + +.button-item a { + + color: white; + text-align: center; +} + + @media only screen and (max-width: 767px) { + + .button-item { + + width: 50px; + color: white; + + } + .label-item { + width: 50px; + color: white; + } +} \ No newline at end of file diff --git a/frontend/src/Call/components/MediaPlayer.js b/frontend/src/Call/components/MediaPlayer.js index f88ed7d..7dba90e 100644 --- a/frontend/src/Call/components/MediaPlayer.js +++ b/frontend/src/Call/components/MediaPlayer.js @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from "react"; +import React, { useEffect, useState, useMemo } from "react"; import { Menu, Icon, @@ -12,6 +12,9 @@ import { } from "semantic-ui-react"; import ReactAudioPlayer from 'react-audio-player' import WavesurferPlayer from '@wavesurfer/react' +import RegionsPlugin from 'wavesurfer.js/dist/plugins/regions.js'; + + import { is } from "date-fns/locale"; import "./MediaPlayer.css"; @@ -27,15 +30,29 @@ const MediaPlayer = (props) => { const [playTime, setPlayTime] = useState(0); const playSilence = props.playSilence; const parentHandlePlayPause = props.onPlayPause + const regionsPlugin = useMemo(() => RegionsPlugin.create(), []); + const plugins = useMemo(() => [regionsPlugin], [regionsPlugin]); const onReady = (ws) => { setWavesurfer(ws) setIsPlaying(false) + regionsPlugin.clearRegions(); + if (call) { + call.srcList.forEach(src => { + regionsPlugin.addRegion({ + start: src.pos, + color: "white", + drag: false, + resize: false + }); + }); + } } const onPlay = () => { setIsPlaying(true); parentHandlePlayPause(true); + } const onPause = () => { @@ -43,7 +60,7 @@ const MediaPlayer = (props) => { parentHandlePlayPause(false); } const onPlayPause = () => { - wavesurfer && wavesurfer.playPause() + wavesurfer && wavesurfer.playPause() } const updatePlayProgress = () => { @@ -53,9 +70,9 @@ const MediaPlayer = (props) => { currentTime = wavesurfer.getCurrentTime(), remainingTime = totalTime - currentTime; - if (!isPlaying) { - setIsPlaying(true); - } + if (!isPlaying) { + setIsPlaying(true); + } //console.log("totalTime: " + totalTime + " currentTime: " + currentTime + " remainingTime: " + remainingTime); @@ -81,26 +98,26 @@ const MediaPlayer = (props) => { return ( - -
- - -
- -
-
- + isPlaying + ? () + : () + } + +
+
+ { onPause={onPause} onAudioprocess={updatePlayProgress} onFinish={props.onEnded} - + plugins={plugins} /> -
+
- - - + + + -
-
+
+
) /* const audioRef = React.createRef();