diff --git a/_locales/en/messages.json b/_locales/en/messages.json index f24ad3499..e358968e0 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -404,7 +404,6 @@ "device": "Device", "destination": "Destination", "learnMore": "Learn more", - "playAtCustomSpeed": "Play at $multipler$x speed", "linkVisitWarningTitle": "Open this link in your browser?", "linkVisitWarningMessage": "Are you sure you want to open $url$ in your browser?", "open": "Open", diff --git a/stylesheets/_session.scss b/stylesheets/_session.scss index 622277f15..4fbf56b6e 100644 --- a/stylesheets/_session.scss +++ b/stylesheets/_session.scss @@ -1385,3 +1385,23 @@ input { padding: $session-margin-sm $session-margin-lg; border-radius: 4px; } + +.speedButton { + padding: $session-margin-xs; + opacity: 0.6; + transition: none; + &:hover { + @include themify($themes) { + opacity: 1; + } + } + .session-button { + transition: none; + + &:hover { + @include themify($themes) { + color: themed('textColorOpposite'); + } + } + } +} diff --git a/ts/components/conversation/H5AudioPlayer.tsx b/ts/components/conversation/H5AudioPlayer.tsx index 53c3bf8ed..7ce6a01f3 100644 --- a/ts/components/conversation/H5AudioPlayer.tsx +++ b/ts/components/conversation/H5AudioPlayer.tsx @@ -1,23 +1,22 @@ // Audio Player import React, { useEffect, useRef, useState } from 'react'; -import H5AudioPlayer from 'react-h5-audio-player'; -import { useSelector } from 'react-redux'; +import H5AudioPlayer, { RHAP_UI } from 'react-h5-audio-player'; import { useTheme } from 'styled-components'; import { useEncryptedFileFetch } from '../../hooks/useEncryptedFileFetch'; -import { getAudioAutoplay } from '../../state/selectors/userConfig'; import { SessionIcon, SessionIconSize, SessionIconType } from '../session/icon'; +import { SessionButton, SessionButtonColor, SessionButtonType } from '../session/SessionButton'; export const AudioPlayerWithEncryptedFile = (props: { src: string; contentType: string; - playbackSpeed: number; playNextMessage?: (index: number) => void; playableMessageIndex?: number; nextMessageToPlay?: number; }) => { const theme = useTheme(); + + const [playbackSpeed, setPlaybackSpeed] = useState(1.0); const { urlToLoad } = useEncryptedFileFetch(props.src, props.contentType); - const { playbackSpeed } = props; const player = useRef(null); useEffect(() => { @@ -55,6 +54,21 @@ export const AudioPlayerWithEncryptedFile = (props: { listenInterval={100} onEnded={onEnded} ref={player} + customControlsSection={[ + RHAP_UI.MAIN_CONTROLS, + RHAP_UI.VOLUME, +
+ { + setPlaybackSpeed(playbackSpeed === 1 ? 1.5 : 1); + }} + buttonType={SessionButtonType.Simple} + buttonColor={SessionButtonColor.None} + /> +
, + ]} customIcons={{ play: ( { expiring: false, expired: false, imageBroken: false, - playbackSpeed: 1, }; this.ctxMenuID = `ctx-menu-message-${uuid()}`; } @@ -205,7 +203,6 @@ class MessageInner extends React.PureComponent { }} > { ) : null} - {isAudio(attachments) ? ( - - {window.i18n('playAtCustomSpeed', this.state.playbackSpeed === 1 ? 2 : 1)} - - ) : null} { MessageInteraction.copyBodyToClipboard(text); @@ -827,15 +819,6 @@ class MessageInner extends React.PureComponent { ); } - /** - * Doubles / halves the playback speed based on the current playback speed. - */ - private updatePlaybackSpeed() { - this.setState(prevState => ({ - playbackSpeed: prevState.playbackSpeed === 1 ? 2 : 1, - })); - } - private handleContextMenu(e: any) { e.preventDefault(); e.stopPropagation();