2022-03-26 10:47:58 +00:00
|
|
|
// ignore_for_file: avoid_web_libraries_in_flutter
|
|
|
|
|
|
|
|
import 'dart:html';
|
|
|
|
|
|
|
|
import 'package:audio_service_web/js/media_session_web.dart';
|
|
|
|
import 'package:music_web_player/api.dart';
|
|
|
|
|
2022-03-26 10:55:09 +00:00
|
|
|
void updateMusicSession({
|
|
|
|
required MusicEntry entry,
|
|
|
|
required Function() onPlay,
|
|
|
|
required Function() onPause,
|
|
|
|
required Function() onStop,
|
|
|
|
required Function() onPreviousTrack,
|
|
|
|
required Function() onNextTrack,
|
|
|
|
}) {
|
2022-03-26 10:47:58 +00:00
|
|
|
MediaSession.metadata = MediaMetadata({
|
|
|
|
"title": entry.title,
|
|
|
|
"artist": entry.artist,
|
|
|
|
"artwork": [
|
|
|
|
{
|
|
|
|
"src": entry.coverURL,
|
|
|
|
"sizes": "512x512",
|
|
|
|
"type": "image/jpeg",
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
2022-03-26 10:55:09 +00:00
|
|
|
|
|
|
|
MediaSession.setActionHandler("play", (p0) => onPlay());
|
|
|
|
MediaSession.setActionHandler("pause", (p0) => onPause());
|
|
|
|
MediaSession.setActionHandler("stop", (p0) => onStop());
|
|
|
|
MediaSession.setActionHandler("previoustrack", (p0) => onPreviousTrack());
|
|
|
|
MediaSession.setActionHandler("nexttrack", (p0) => onNextTrack());
|
2022-03-26 10:47:58 +00:00
|
|
|
}
|