forked from samuellawerentz/style-guide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from contacto-io/CNTO-7149/recording-in-vc
Added the option to show Audio player speeds upfront
- Loading branch information
Showing
8 changed files
with
109 additions
and
37 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,23 @@ | ||
/* eslint-disable no-unused-vars */ | ||
import React, { useEffect, useState } from 'react' | ||
import { Popover } from 'antd' | ||
import { Button } from '../../Button/index' | ||
import { RenderButtons } from '../helpers/utils' | ||
|
||
const speeds = [0.5, 1, 1.5, 2] | ||
|
||
const speeds = [0.8, 1, 1.2, 1.5, 1.7, 2, 2.5] | ||
export default function PlaybackSpeed({ waveSurfer }) { | ||
const [speed, setSpeed] = useState(waveSurfer?.getPlaybackRate()) | ||
|
||
const handleSpeedChange = (speed) => { | ||
setSpeed(speed) | ||
waveSurfer?.setPlaybackRate(speed) | ||
} | ||
|
||
useEffect(() => { | ||
setSpeed(waveSurfer?.getPlaybackRate()) | ||
}, [waveSurfer]) | ||
|
||
return ( | ||
<Popover | ||
overlayClassName="contacto-player-speed" | ||
title="Playback Speed" | ||
content={() => ( | ||
<div> | ||
{speeds.map((speed) => ( | ||
<Button | ||
key={speed} | ||
className="contacto-player-speed" | ||
type={speed === waveSurfer?.getPlaybackRate() ? 'secondary' : 'table-action-link'} | ||
onClick={() => handleSpeedChange(speed)} | ||
> | ||
{speed}x | ||
</Button> | ||
))} | ||
</div> | ||
)} | ||
> | ||
<Button className="contacto-player-speed-trigger" type="secondary"> | ||
{speed}x | ||
</Button> | ||
</Popover> | ||
<RenderButtons | ||
speeds={speeds} | ||
waveSurfer={waveSurfer} | ||
setSpeed={setSpeed} | ||
parentClassName="contacto-player-speed" | ||
buttonClassName="contacto-player-speed-buttons" | ||
/> | ||
) | ||
} |
33 changes: 33 additions & 0 deletions
33
src/components/AudioPlayer/components/PlaybackSpeedPopup.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, { useEffect, useState } from 'react' | ||
import { Popover } from 'antd' | ||
import { Button } from '../../Button/index' | ||
import { RenderButtons } from '../helpers/utils' | ||
|
||
const speeds = [0.8, 1, 1.2, 1.5, 1.7, 2, 2.5] | ||
export default function PlaybackSpeedPopup({ waveSurfer }) { | ||
const [speed, setSpeed] = useState(waveSurfer?.getPlaybackRate()) | ||
|
||
useEffect(() => { | ||
setSpeed(waveSurfer?.getPlaybackRate()) | ||
}, [waveSurfer]) | ||
|
||
return ( | ||
<Popover | ||
overlayClassName="contacto-player-speed-popup" | ||
title="Playback Speed" | ||
content={() => ( | ||
<RenderButtons | ||
speeds={speeds} | ||
waveSurfer={waveSurfer} | ||
setSpeed={setSpeed} | ||
parentClassName="contacto-player-speed-popup" | ||
buttonClassName="contacto-player-speed-popup" | ||
/> | ||
)} | ||
> | ||
<Button className="contacto-player-speed-trigger" type="secondary"> | ||
{speed}x | ||
</Button> | ||
</Popover> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters