mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 21:06:42 +07:00
simple player controls
This commit is contained in:
parent
3fcff3ea0d
commit
69ff9a7652
8 changed files with 128 additions and 25 deletions
|
@ -5,6 +5,9 @@ import * as PLAYER_ACTIONS from '~/redux/player/actions';
|
|||
import { IFile } from '~/redux/types';
|
||||
import { PLAYER_STATES } from '~/redux/player/constants';
|
||||
import { Player } from '~/utils/player';
|
||||
import classNames from 'classnames';
|
||||
import * as styles from './styles.scss';
|
||||
import { Icon } from '~/components/input/Icon';
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
player: selectPlayer(state),
|
||||
|
@ -61,8 +64,16 @@ const AudioPlayerUnconnected = ({
|
|||
}, [file, current, setPlaying, onProgress]);
|
||||
|
||||
return (
|
||||
<div onClick={onPlay}>
|
||||
- {file.url} - {progress} - {playing && 'playing'}
|
||||
<div onClick={onPlay} className={classNames(styles.wrap, { playing })}>
|
||||
<div className={styles.playpause}>
|
||||
{playing && status === PLAYER_STATES.PLAYING ? <Icon icon="pause" /> : <Icon icon="play" />}
|
||||
</div>
|
||||
<div className={styles.content}>
|
||||
<div className={styles.progress}>
|
||||
<div className={styles.bar} style={{ width: `${progress}%` }} />
|
||||
</div>
|
||||
<div className={styles.title}>{file.url}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
101
src/components/media/AudioPlayer/styles.scss
Normal file
101
src/components/media/AudioPlayer/styles.scss
Normal file
|
@ -0,0 +1,101 @@
|
|||
.wrap {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
&:global(.playing) {
|
||||
.progress {
|
||||
opacity: 1;
|
||||
pointer-events: all;
|
||||
touch-action: auto;
|
||||
}
|
||||
|
||||
.title {
|
||||
top: 15px;
|
||||
opacity: 1;
|
||||
font-size: 12px;
|
||||
padding-right: 140px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.playpause {
|
||||
flex: 0 0 $comment_height;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
|
||||
svg {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
fill: transparentize($color: white, $amount: 0.5);
|
||||
stroke: transparentize($color: white, $amount: 0.5);
|
||||
transition: fill 250ms, stroke 250ms;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
svg {
|
||||
fill: white;
|
||||
stroke: white;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
padding: 0 $gap;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.title {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
opacity: 0.2;
|
||||
pointer-events: none;
|
||||
touch-action: none;
|
||||
padding: 0 10px;
|
||||
box-sizing: border-box;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
text-align: left;
|
||||
transition: all 0.5s;
|
||||
}
|
||||
|
||||
.progress {
|
||||
height: 20px;
|
||||
position: relative;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
touch-action: none;
|
||||
transition: opacity 0.5s;
|
||||
left: 0;
|
||||
|
||||
&::after {
|
||||
content: ' ';
|
||||
position: absolute;
|
||||
height: 10px;
|
||||
border-radius: 5px;
|
||||
background: transparentize(white, 0.95);
|
||||
width: 100%;
|
||||
top: 5px;
|
||||
left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.bar {
|
||||
background: linear-gradient(270deg, $green, $wisegreen);
|
||||
position: absolute;
|
||||
height: 10px;
|
||||
left: 0;
|
||||
top: 5px;
|
||||
border-radius: 5px;
|
||||
min-width: 10px;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue