-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mebtte
committed
Sep 17, 2023
1 parent
b605c1a
commit 039eded
Showing
10 changed files
with
103 additions
and
32 deletions.
There are no files selected for viewing
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
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import Slider from '@/components/slider'; | ||
import { CSSProperties } from 'react'; | ||
import styled from 'styled-components'; | ||
import absoluteFullSize from '@/style/absolute_full_size'; | ||
import { CSSVariable } from '@/global_style'; | ||
import useAudioCurrentMillisecond from '../use_audio_current_millisecond'; | ||
import playerEventemitter, { | ||
EventType as PlayerEventType, | ||
} from '../eventemitter'; | ||
|
||
const style: CSSProperties = { | ||
zIndex: 1, | ||
}; | ||
const SecondTrack = styled.div` | ||
${absoluteFullSize} | ||
background-color: ${CSSVariable.BACKGROUND_COLOR_LEVEL_FIVE}; | ||
transform-origin: left; | ||
`; | ||
|
||
function Progress({ | ||
duration, | ||
bufferedPercent, | ||
}: { | ||
duration: number; | ||
bufferedPercent: number; | ||
}) { | ||
const onChange = (p: number) => | ||
playerEventemitter.emit(PlayerEventType.ACTION_SET_TIME, { | ||
second: duration * p, | ||
}); | ||
|
||
const currentMillisecond = useAudioCurrentMillisecond(); | ||
const percent = duration ? currentMillisecond / 1000 / duration : 0; | ||
|
||
return ( | ||
<Slider | ||
current={percent} | ||
onChange={onChange} | ||
style={style} | ||
secondTrack={ | ||
<SecondTrack | ||
style={{ | ||
transform: `scaleX(${bufferedPercent * 100}%)`, | ||
}} | ||
/> | ||
} | ||
/> | ||
); | ||
} | ||
|
||
export default Progress; |
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