diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-07-07 21:18:33 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-07-07 21:18:33 +0200 |
| commit | f8b61281be84a6e4e7a44be5109e688a7c56c671 (patch) | |
| tree | 43797c6b6cfa5c0f89c020f8c89e0da10f791a55 /client/components/UI/AudioPlayerView.jsx | |
| parent | 3d3a7b80d34c100846c8ae130b424b63ba3c0784 (diff) | |
refactor files so list updates while processing
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' +} |
