diff options
Diffstat (limited to 'client/components/UI/AudioPlayerView.jsx')
| -rw-r--r-- | client/components/UI/AudioPlayerView.jsx | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/client/components/UI/AudioPlayerView.jsx b/client/components/UI/AudioPlayerView.jsx new file mode 100644 index 0000000..62745ed --- /dev/null +++ b/client/components/UI/AudioPlayerView.jsx @@ -0,0 +1,36 @@ +import { h, Component } from 'preact' + +const audio = document.createElement('audio') + +export default function AudioPlayerView (props) { + if (props.file) { + document.body.style.backgroundImage = 'url(' + pngpath(props.file) + ')' + audio.src = mp3path(props.file) + audio.play() + return ( + <div> + Playing {props.file.name} + </div> + ) + } + else { + return ( + <div> + Not Playing + </div> + ) + } +} + +function filepath (file) { + return '/data/' + file.folder_id + '/' + encodeURIComponent(file.name) +} +function mp3path (file) { + if (file.mime !== 'audio/mp3') { + return filepath(file) + '.mp3' + } + return filepath(file) +} +function pngpath (file) { + return filepath(file) + '.png' +} |
