First attempt to add metadata to web player

This commit is contained in:
Pierre HUBERT 2022-03-26 11:47:58 +01:00
parent f88791f06f
commit 8987a0cd94
5 changed files with 41 additions and 1 deletions

View File

@ -50,7 +50,7 @@ class API {
}
extension MusicEntryAPIExt on MusicEntry {
String get coverURL => "${config.apiURL}/cover/$id";
String get coverURL => "${config.apiURL}/cover/$id?token=${config.apiToken}";
String get musicURL =>
"${config.apiURL}/download/$id?token=${config.apiToken}";

View File

@ -7,6 +7,7 @@ import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart';
import 'package:music_web_player/api.dart';
import 'package:music_web_player/ui/cover_image.dart';
import 'package:music_web_player/ui/player_web_interface.dart';
import 'package:video_player/video_player.dart';
extension DurationExt on Duration {
@ -79,6 +80,8 @@ class _MusicPlayerState extends State<MusicPlayer> {
}
}
}));
updateMusicSession(currMusic);
}
}

View File

@ -0,0 +1,20 @@
// 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';
void updateMusicSession(MusicEntry entry) {
MediaSession.metadata = MediaMetadata({
"title": entry.title,
"artist": entry.artist,
"artwork": [
{
"src": entry.coverURL,
"sizes": "512x512",
"type": "image/jpeg",
}
]
});
}

View File

@ -8,6 +8,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.2"
audio_service_platform_interface:
dependency: transitive
description:
name: audio_service_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0"
audio_service_web:
dependency: "direct main"
description:
name: audio_service_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1"
boolean_selector:
dependency: transitive
description:

View File

@ -50,6 +50,9 @@ dependencies:
video_player: ^2.3.0
chewie_audio: ^1.3.0
# Audio integration in browser
audio_service_web: ^0.1.1
dev_dependencies:
flutter_test:
sdk: flutter