import { WebampLazy } from "./Webamp" ; export default function enableMediaSession ( webamp ) { if ( "mediaSession" in navigator ) { webamp . onTrackDidChange ( ( track ) => { if ( track == null ) { return ; } const { metaData : { title , artist , album , albumArtUrl } , } = track ; navigator . mediaSession . metadata = new MediaMetadata ( { title , artist , album , artwork : albumArtUrl ? [ { src : albumArtUrl , } , ] : [ ] , } ) ; } ) ; navigator . mediaSession . setActionHandler ( "play" , ( ) => { webamp . play ( ) ; } ) ; navigator . mediaSession . setActionHandler ( "pause" , ( ) => { webamp . pause ( ) ; } ) ; navigator . mediaSession . setActionHandler ( "seekbackward" , ( ) => { webamp . seekBackward ( 10 ) ; } ) ; navigator . mediaSession . setActionHandler ( "seekforward" , ( ) => { webamp . seekForward ( 10 ) ; } ) ; navigator . mediaSession . setActionHandler ( "previoustrack" , ( ) => { webamp . previousTrack ( ) ; } ) ; navigator . mediaSession . setActionHandler ( "nexttrack" , ( ) => { webamp . nextTrack ( ) ; } ) ; } }