blob: e715c2754dbccb0e924c4734a1639c18bd8ddc13 (
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
|
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' onClick={() => audio.paused ? audio.play() : audio.pause()}>
Playing {props.file.name}
</div>
)
}
else {
audio.pause()
return (
<div class='audioPlayer'>
Not Playing
</div>
)
}
}
|