First attempt to add metadata to web player
This commit is contained in:
parent
f88791f06f
commit
8987a0cd94
@ -50,7 +50,7 @@ class API {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension MusicEntryAPIExt on MusicEntry {
|
extension MusicEntryAPIExt on MusicEntry {
|
||||||
String get coverURL => "${config.apiURL}/cover/$id";
|
String get coverURL => "${config.apiURL}/cover/$id?token=${config.apiToken}";
|
||||||
|
|
||||||
String get musicURL =>
|
String get musicURL =>
|
||||||
"${config.apiURL}/download/$id?token=${config.apiToken}";
|
"${config.apiURL}/download/$id?token=${config.apiToken}";
|
||||||
|
@ -7,6 +7,7 @@ import 'package:fluentui_system_icons/fluentui_system_icons.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:music_web_player/api.dart';
|
import 'package:music_web_player/api.dart';
|
||||||
import 'package:music_web_player/ui/cover_image.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';
|
import 'package:video_player/video_player.dart';
|
||||||
|
|
||||||
extension DurationExt on Duration {
|
extension DurationExt on Duration {
|
||||||
@ -79,6 +80,8 @@ class _MusicPlayerState extends State<MusicPlayer> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
updateMusicSession(currMusic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
lib/ui/player_web_interface.dart
Normal file
20
lib/ui/player_web_interface.dart
Normal 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",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
14
pubspec.lock
14
pubspec.lock
@ -8,6 +8,20 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.8.2"
|
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:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -50,6 +50,9 @@ dependencies:
|
|||||||
video_player: ^2.3.0
|
video_player: ^2.3.0
|
||||||
chewie_audio: ^1.3.0
|
chewie_audio: ^1.3.0
|
||||||
|
|
||||||
|
# Audio integration in browser
|
||||||
|
audio_service_web: ^0.1.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
Loading…
Reference in New Issue
Block a user