Compare commits
No commits in common. "c3e19308aab94090f14c581f0aa0e7633265cc88" and "b4882ea4d9fd388a752730c947be3e9b55684961" have entirely different histories.
c3e19308aa
...
b4882ea4d9
20
events.py
20
events.py
|
@ -55,26 +55,6 @@ async def select_track(request, ws, data):
|
||||||
fpath = fpath.replace('flac', 'opus')
|
fpath = fpath.replace('flac', 'opus')
|
||||||
fpath = parse.quote(fpath)
|
fpath = parse.quote(fpath)
|
||||||
track['url'] = fpath
|
track['url'] = fpath
|
||||||
coverart = parse.urljoin(fpath, 'folder.jpg')
|
|
||||||
track['coverart'] = coverart
|
|
||||||
ret = {'event': 'track', 'ok': True, 'data': track}
|
|
||||||
await ws.send_json(ret)
|
|
||||||
|
|
||||||
|
|
||||||
async def random_track(request, ws, data):
|
|
||||||
"""Select a random track."""
|
|
||||||
async with request.app['pool'].acquire() as conn:
|
|
||||||
track = await conn.fetchrow(
|
|
||||||
"SELECT * FROM TRACK ORDER BY random() LIMIT 1")
|
|
||||||
track = dict(track)
|
|
||||||
fpath = track.pop('filepath')
|
|
||||||
track.pop('last_modified')
|
|
||||||
fpath = config.static_prefix + os.path.relpath(fpath, config.music_dir)
|
|
||||||
fpath = fpath.replace('.flac', '.opus')
|
|
||||||
fpath = parse.quote(fpath)
|
|
||||||
track['url'] = fpath
|
|
||||||
coverart = parse.urljoin(fpath, 'folder.jpg')
|
|
||||||
track['coverart'] = coverart
|
|
||||||
ret = {'event': 'track', 'ok': True, 'data': track}
|
ret = {'event': 'track', 'ok': True, 'data': track}
|
||||||
await ws.send_json(ret)
|
await ws.send_json(ret)
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,6 @@ body {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
img {
|
|
||||||
max-height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
main {
|
main {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: grid;
|
display: grid;
|
||||||
|
|
|
@ -2,11 +2,6 @@ var socket;
|
||||||
|
|
||||||
function load() {
|
function load() {
|
||||||
socket = init_websocket();
|
socket = init_websocket();
|
||||||
document.querySelector('#player').addEventListener('ended', function() {
|
|
||||||
if (document.querySelector('#shuffle').checked) {
|
|
||||||
socket.send_event('random_track', {});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Websocket setup */
|
/* Websocket setup */
|
||||||
|
@ -122,7 +117,6 @@ function track_recv(data) {
|
||||||
player.firstElementChild.src = data['url'];
|
player.firstElementChild.src = data['url'];
|
||||||
player.load();
|
player.load();
|
||||||
player.play();
|
player.play();
|
||||||
document.querySelector('#albumCover').firstChild.src = data['coverart'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Websocket send */
|
/* Websocket send */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user