Improve typing of onTrackDidChange

This commit is contained in:
Jordan Eldredge 2019-03-16 23:30:25 -07:00
parent 8ca8de7738
commit 96c65aaebb
2 changed files with 12 additions and 2 deletions

View file

@ -4,7 +4,7 @@ import { LoadedURLTrack } from "../../js/types";
export default function enableMediaSession(webamp: WebampLazy) {
if ("mediaSession" in navigator) {
/* global MediaMetadata */
webamp.onTrackDidChange((track: LoadedURLTrack | null) => {
webamp.onTrackDidChange(track => {
if (track == null) {
return;
}

12
index.d.ts vendored
View file

@ -45,6 +45,16 @@ interface BlobTrack extends TrackInfo {
blob: Blob;
}
interface LoadedURLTrack {
url: string;
metaData: {
artist: string | null;
title: string | null;
album: string | null;
albumArtUrl: string | null;
};
}
/**
* Many methods on the webamp instance deal with track.
*
@ -190,7 +200,7 @@ export default class Webamp {
* @returns An "unsubscribe" function. Useful if at some point in the future you want to stop listening to these events.
*/
public onTrackDidChange(
cb: (trackInfo: { url: string } | null) => void
cb: (trackInfo: LoadedURLTrack | null) => void
): () => void;
/**