add mediasession info
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import { writable, get } from 'svelte/store';
|
||||
import { browser } from '$app/environment';
|
||||
|
||||
export const currentStream = writable({});
|
||||
export const currentSongIndex = writable(0);
|
||||
export const currentSongIndex = writable(null);
|
||||
|
||||
export const favoritedStreams = writable(
|
||||
new Set(JSON.parse((browser && localStorage.getItem('favoritedStreams')) || '[]'))
|
||||
@@ -12,6 +12,18 @@ if (browser) {
|
||||
favoritedStreams.subscribe((val) => {
|
||||
localStorage.setItem('favoritedStreams', JSON.stringify(Array.from(val)));
|
||||
});
|
||||
|
||||
if ('mediaSession' in navigator) {
|
||||
currentSongIndex.subscribe((val) => {
|
||||
if (val != null) {
|
||||
const song = get(currentStream).tracks[val];
|
||||
navigator.mediaSession.metadata = new MediaMetadata({
|
||||
artist: song[1],
|
||||
title: song[2]
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const tagList = [
|
||||
|
||||
Reference in New Issue
Block a user