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';
|
import { browser } from '$app/environment';
|
||||||
|
|
||||||
export const currentStream = writable({});
|
export const currentStream = writable({});
|
||||||
export const currentSongIndex = writable(0);
|
export const currentSongIndex = writable(null);
|
||||||
|
|
||||||
export const favoritedStreams = writable(
|
export const favoritedStreams = writable(
|
||||||
new Set(JSON.parse((browser && localStorage.getItem('favoritedStreams')) || '[]'))
|
new Set(JSON.parse((browser && localStorage.getItem('favoritedStreams')) || '[]'))
|
||||||
@@ -12,6 +12,18 @@ if (browser) {
|
|||||||
favoritedStreams.subscribe((val) => {
|
favoritedStreams.subscribe((val) => {
|
||||||
localStorage.setItem('favoritedStreams', JSON.stringify(Array.from(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 = [
|
export const tagList = [
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { error } from "@sveltejs/kit";
|
import { getStreams } from '$lib/database.js';
|
||||||
import { getStreams } from "$lib/database.js";
|
|
||||||
|
|
||||||
export function load() {
|
export function load() {
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user