mirror of
https://github.com/mgerb/go-discord-bot
synced 2026-01-11 17:42:48 +00:00
feat: add player controls to uploaded clips on stats page
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import React from 'react';
|
||||
import { ClipPlayerControl } from '../clip-player-control/clip-player-control';
|
||||
import './sound-list.scss';
|
||||
|
||||
interface Props {
|
||||
soundList: SoundType[];
|
||||
type: string;
|
||||
type: 'sounds' | 'clips';
|
||||
onPlayDiscord?: (sound: SoundType) => void;
|
||||
showDiscordPlay?: boolean;
|
||||
}
|
||||
@@ -46,7 +47,7 @@ export class SoundList extends React.Component<Props, State> {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { onPlayDiscord, showDiscordPlay, soundList, type } = this.props;
|
||||
const { showDiscordPlay, soundList, type } = this.props;
|
||||
|
||||
return (
|
||||
<div className="card">
|
||||
@@ -65,41 +66,7 @@ export class SoundList extends React.Component<Props, State> {
|
||||
<div key={index} className="sound-list__item">
|
||||
<div className="text-wrap">{(sound.prefix || '') + sound.name}</div>
|
||||
|
||||
{this.checkExtension(sound.extension) && this.state.showAudioControls[index] ? (
|
||||
<audio
|
||||
controls
|
||||
src={`/public/${type.toLowerCase()}/` + sound.name + '.' + sound.extension}
|
||||
itemType={'audio/' + sound.extension}
|
||||
style={{ width: '100px' }}
|
||||
/>
|
||||
) : (
|
||||
<div>
|
||||
<a
|
||||
href={`/public/${type.toLowerCase()}/` + sound.name + '.' + sound.extension}
|
||||
download
|
||||
title="Download"
|
||||
className="fa fa-download link"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<i
|
||||
title="Play in browser"
|
||||
className="fa fa-play link"
|
||||
aria-hidden="true"
|
||||
style={{ paddingLeft: '15px' }}
|
||||
onClick={() => this.handlePlayAudioInBrowser(sound, type)}
|
||||
/>
|
||||
{showDiscordPlay &&
|
||||
onPlayDiscord && (
|
||||
<i
|
||||
title="Play in discord"
|
||||
className="fa fa-play-circle link fa-lg"
|
||||
aria-hidden="true"
|
||||
style={{ paddingLeft: '10px' }}
|
||||
onClick={() => onPlayDiscord!(sound)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<ClipPlayerControl showDiscordPlay={showDiscordPlay} sound={sound} type={type} />
|
||||
</div>
|
||||
);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user