diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-07-21 04:48:52 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-07-21 04:48:52 +0200 |
| commit | d41070c7b00fafc974a1a6e7b6d1b42391fa57ed (patch) | |
| tree | 4178eba89627e8581cdc5eea65bf7f11591f6b45 /client/components/UI/AudioPlayerView.jsx | |
| parent | d02cbad01f3abfa8a1aad0b55b8bd9cf544090cf (diff) | |
all async paths working
Diffstat (limited to 'client/components/UI/AudioPlayerView.jsx')
| -rw-r--r-- | client/components/UI/AudioPlayerView.jsx | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/client/components/UI/AudioPlayerView.jsx b/client/components/UI/AudioPlayerView.jsx index d2c9982..e715c27 100644 --- a/client/components/UI/AudioPlayerView.jsx +++ b/client/components/UI/AudioPlayerView.jsx @@ -1,19 +1,21 @@ import { h, Component } from 'preact' - +import { pngpath, mp3path } from '../../vendor/paths' 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.currentTime = 0 audio.play() return ( - <div class='audioPlayer'> + <div class='audioPlayer' onClick={() => audio.paused ? audio.play() : audio.pause()}> Playing {props.file.name} </div> ) } else { + audio.pause() return ( <div class='audioPlayer'> Not Playing @@ -21,16 +23,3 @@ export default function AudioPlayerView (props) { ) } } - -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' -} |
