summaryrefslogtreecommitdiff
path: root/client/components/UI/AudioPlayer.jsx
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-07-07 18:43:24 +0200
committerJules Laplace <julescarbon@gmail.com>2017-07-07 18:43:24 +0200
commitb89147ecd38b0f95a2e4917aba7f44bf3bb70327 (patch)
tree554d0d726755c89e55dbe79f0339cceb13543dd5 /client/components/UI/AudioPlayer.jsx
parentd520c67839724e80d8b68b8fe933f1e7755a8f42 (diff)
refactor audioplayer
Diffstat (limited to 'client/components/UI/AudioPlayer.jsx')
-rw-r--r--client/components/UI/AudioPlayer.jsx35
1 files changed, 35 insertions, 0 deletions
diff --git a/client/components/UI/AudioPlayer.jsx b/client/components/UI/AudioPlayer.jsx
new file mode 100644
index 0000000..de6502c
--- /dev/null
+++ b/client/components/UI/AudioPlayer.jsx
@@ -0,0 +1,35 @@
+import { h, Component } from 'preact'
+
+const audio = document.createElement('audio')
+
+export default function AudioPlayer (props) {
+ if (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'
+}