blob: d2c9982e2d25eff6b3647f5c64628ca5e06024b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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 class='audioPlayer'>
Playing {props.file.name}
</div>
)
}
else {
return (
<div class='audioPlayer'>
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'
}
|