Can download songs

This commit is contained in:
Pierre HUBERT 2022-06-05 15:49:53 +02:00
parent c82dc6754f
commit dd81d5654c
7 changed files with 107 additions and 2 deletions

View File

@ -2,5 +2,12 @@
New generation of music web player for the [music server](https://gitlab.com/pierre42100/musicsserver) written based on Flutter. New generation of music web player for the [music server](https://gitlab.com/pierre42100/musicsserver) written based on Flutter.
### Debugging
Add the following run arguments:
```bash
--dart-define API_URL=<MUSIC_SERVER_ENDPINT> --dart-define API_TOKEN=<API_TOKEN>
```
## Screenshot ## Screenshot
![screenshot of app](img/screenshot-1.jpg) ![screenshot of app](img/screenshot-1.jpg)

View File

@ -8,6 +8,7 @@ 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:music_web_player/ui/player_web_interface.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:video_player/video_player.dart'; import 'package:video_player/video_player.dart';
extension DurationExt on Duration { extension DurationExt on Duration {
@ -191,7 +192,24 @@ class _MusicPlayerState extends State<MusicPlayer> {
), ),
Positioned( Positioned(
top: 10, right: 10, child: _buildToggleListButton()), top: 10,
right: 10,
child: fluent.Row(
children: [
_buildToggleListButton(),
],
)),
Positioned(
bottom: 10,
right: 10,
child: fluent.Row(
children: [
_buildDownloadTrackButton(),
const SizedBox(width: 10),
_buildAboutButton(),
],
)),
], ],
), ),
), ),
@ -284,6 +302,22 @@ class _MusicPlayerState extends State<MusicPlayer> {
), ),
); );
Widget _buildDownloadTrackButton() => fluent.Button(
onPressed: () =>
launchUrlString(currMusic.musicURL, webOnlyWindowName: "_blank"),
child: const fluent.Icon(fluent.FluentIcons.download),
);
Widget _buildAboutButton() => fluent.Button(
onPressed: () => showLicensePage(
context: context,
applicationName: "Music Player",
applicationIcon:
const fluent.Icon(FluentIcons.music_note_2_24_regular),
),
child: const fluent.Icon(fluent.FluentIcons.info),
);
Widget _buildToggleListButton() => fluent.ToggleButton( Widget _buildToggleListButton() => fluent.ToggleButton(
checked: _showPlaylist, checked: _showPlaylist,
onChanged: (s) => setState(() => _showPlaylist = s), onChanged: (s) => setState(() => _showPlaylist = s),

View File

@ -6,6 +6,10 @@
#include "generated_plugin_registrant.h" #include "generated_plugin_registrant.h"
#include <url_launcher_linux/url_launcher_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) { void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
} }

View File

@ -3,6 +3,7 @@
# #
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
url_launcher_linux
) )
list(APPEND FLUTTER_FFI_PLUGIN_LIST list(APPEND FLUTTER_FFI_PLUGIN_LIST

View File

@ -439,6 +439,62 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.1" version: "1.3.1"
url_launcher:
dependency: "direct main"
description:
name: url_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.2"
url_launcher_android:
dependency: transitive
description:
name: url_launcher_android
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.17"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.17"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.11"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
uuid: uuid:
dependency: transitive dependency: transitive
description: description:

View File

@ -53,6 +53,9 @@ dependencies:
# Audio integration in browser # Audio integration in browser
audio_service_web: ^0.1.1 audio_service_web: ^0.1.1
# Open external links
url_launcher: ^6.1.2
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter

View File

@ -29,7 +29,7 @@
<!-- Favicon --> <!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png"/> <link rel="icon" type="image/png" href="favicon.png"/>
<title>music_web_player</title> <title>Music Web Player</title>
<link rel="manifest" href="manifest.json"> <link rel="manifest" href="manifest.json">
<style type="text/css"> <style type="text/css">