From fead6816234976a1e949ea1fbb439e309572593d Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Thu, 24 Oct 2024 22:04:15 -0400 Subject: [PATCH] volume slider --- frontend/src/Call/components/MediaPlayer.css | 17 ++++++++ frontend/src/Call/components/MediaPlayer.js | 46 +++++++++++++++----- 2 files changed, 53 insertions(+), 10 deletions(-) diff --git a/frontend/src/Call/components/MediaPlayer.css b/frontend/src/Call/components/MediaPlayer.css index 121f82f..e9c4772 100644 --- a/frontend/src/Call/components/MediaPlayer.css +++ b/frontend/src/Call/components/MediaPlayer.css @@ -49,6 +49,23 @@ font-weight: bold; text-align: center; } + .volume-icon { + padding: 0px 15px 0px 15px; + } + .volume-slider { + padding: 0px 0px 0px 0px; + } + .icon-button-item { + cursor:pointer; + display: flex; + justify-content: center; + align-items: center; + padding: 5px; + width: 50px; + color: white; + font-weight: bold; + } + .button-item { cursor:pointer; display: flex; diff --git a/frontend/src/Call/components/MediaPlayer.js b/frontend/src/Call/components/MediaPlayer.js index 681d938..5250e9b 100644 --- a/frontend/src/Call/components/MediaPlayer.js +++ b/frontend/src/Call/components/MediaPlayer.js @@ -6,6 +6,8 @@ import { Label, Grid, GridRow, + Header, + Popup, GridColumn, LabelGroup, Button @@ -24,6 +26,7 @@ import "./MediaPlayer.css"; const MediaPlayer = (props) => { const audioRef = React.createRef(); const call = props.call; + const [volume, setVolume] = useState(1); const [sourceIndex, setSourceIndex] = useState(0); const [wavesurfer, setWavesurfer] = useState(null) const [isPlaying, setIsPlaying] = useState(false) @@ -36,7 +39,7 @@ const MediaPlayer = (props) => { useEffect(() => { setSourceIndex(0); - + if ('mediaSession' in navigator) { navigator.mediaSession.metadata = new MediaMetadata({ title: "Waiting for Call...", @@ -71,6 +74,12 @@ const MediaPlayer = (props) => { setSourceIndex(0); }, [call]); + useEffect(() => { + if (wavesurfer) { + wavesurfer.setVolume(volume); + } + }, [volume, wavesurfer]); + const onReady = (ws) => { setWavesurfer(ws) @@ -140,21 +149,38 @@ const MediaPlayer = (props) => {
- - -
- { - isPlaying - ? () - : () - } +
+ } hoverable position='top center'> + + { + setVolume(event.target.valueAsNumber) + }} + /> + +
+ +
+ { + isPlaying + ? () + : () + } +
+