Skip to content

Commit

Permalink
Add playbackRate to Preview
Browse files Browse the repository at this point in the history
  • Loading branch information
desko27 committed Feb 28, 2021
1 parent 8b8595d commit e4f87eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/components/FileList/Preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import MediaDisplayer from '../../MediaDisplayer'

import styles from './index.module.css'

const PLAYBACK_RATE = 5

export default function Preview ({ file }) {
return (
<div className={styles.wrapper}>
<MediaDisplayer file={file} isMuted />
<MediaDisplayer file={file} isMuted playbackRate={PLAYBACK_RATE} />
</div>
)
}
7 changes: 6 additions & 1 deletion src/components/MediaDisplayer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const MediaDisplayer = ({
displayerRef = {},
file,
isMuted,
onVideoUpdate = () => {}
onVideoUpdate = () => {},
playbackRate
}) => {
const videoRef = useRef()

Expand Down Expand Up @@ -34,6 +35,10 @@ const MediaDisplayer = ({
if (file.type === 'video') {
const video = videoRef.current

if (playbackRate) {
video.defaultPlaybackRate = playbackRate
}

const timeupdateListener = () => {
const elapsedTime = video.currentTime
const elapsedRatioCalc = video.currentTime / video.duration
Expand Down

0 comments on commit e4f87eb

Please sign in to comment.