diff --git a/lib/src/common/stream_provider_share_button.dart b/lib/src/common/stream_provider_share_button.dart index 63a97602c..fae36c954 100644 --- a/lib/src/common/stream_provider_share_button.dart +++ b/lib/src/common/stream_provider_share_button.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_tabler_icons/flutter_tabler_icons.dart'; import 'package:url_launcher/url_launcher.dart'; +import '../../get.dart'; +import '../app/app_model.dart'; import 'icons.dart'; import '../l10n/l10n.dart'; @@ -40,17 +42,8 @@ class StreamProviderShareButton extends StatelessWidget { final clearedText = text?.replaceAll(RegExp(r"[:/?#\[\]@!$&'()*+,;=%]"), ' ') ?? ''; - final address = switch (streamProvider) { - StreamProvider.youTubeMusic => - 'https://music.youtube.com/search?q=$clearedText', - StreamProvider.appleMusic => - 'https://music.apple.com/us/search?term=$clearedText', - StreamProvider.spotify => 'https://open.spotify.com/search/$clearedText', - StreamProvider.amazonMusic => - 'https://music.amazon.de/search/$clearedText?filter=IsLibrary%7Cfalse&sc=none', - StreamProvider.amazon => - 'https://www.amazon.de/s?k=$clearedText&i=digital-music' - }; + String address = buildAddress(clearedText); + return IconButton( tooltip: onSearch != null ? context.l10n.search @@ -70,6 +63,45 @@ class StreamProviderShareButton extends StatelessWidget { ), ); } + + String buildAddress(String query) { + final address = switch (streamProvider) { + StreamProvider.youTubeMusic => + 'https://music.youtube.com/search?q=$query', + StreamProvider.appleMusic => + 'https://music.apple.com/us/search?term=$query', + StreamProvider.spotify => 'https://open.spotify.com/search/$query', + StreamProvider.amazonMusic => + 'https://music.amazon.${getAmazonSuffix()}/search/$query?filter=IsLibrary%7Cfalse&sc=none', + StreamProvider.amazon => + 'https://www.amazon.${getAmazonSuffix()}/s?k=$query&i=digital-music' + }; + return address; + } + + String getAmazonSuffix() { + final countryCode = getIt().countryCode; + return switch (countryCode) { + 'au' => 'com.au', + 'at' => 'at', + 'br' => 'com.br', + 'ca' => 'ca', + 'fr' => 'fr', + 'de' => 'de', + 'in' => 'in', + 'it' => 'it', + 'jp' => 'co.jp', + 'mx' => 'com.mx', + 'nl' => 'nl', + 'pl' => 'pl', + 'sg' => 'com.sg', + 'es' => 'es', + 'ae' => 'ae', + 'uk' || 'ie' => 'co.uk', + 'us' => 'com', + _ => 'com', + }; + } } class StreamProviderRow extends StatelessWidget { diff --git a/lib/src/player/view/player_track.dart b/lib/src/player/view/player_track.dart index 5861c49e6..059a66013 100644 --- a/lib/src/player/view/player_track.dart +++ b/lib/src/player/view/player_track.dart @@ -43,6 +43,12 @@ class PlayerTrack extends StatelessWidget with WatchItMixin { disabledThumbRadius: bottomPlayer ? 0 : 5.0, ); + final bufferActive = active && + buffer != null && + position != null && + buffer.inSeconds >= position.inSeconds; + final secondaryTrackValue = + bufferActive ? buffer.inSeconds.toDouble() : 0.0; final slider = Tooltip( preferBelow: false, message: @@ -65,8 +71,7 @@ class PlayerTrack extends StatelessWidget with WatchItMixin { min: 0, max: sliderActive ? duration.inSeconds.toDouble() : 1.0, value: sliderActive ? position.inSeconds.toDouble() : 0, - secondaryTrackValue: - sliderActive ? buffer?.inSeconds.toDouble() : 0, + secondaryTrackValue: secondaryTrackValue, onChanged: sliderActive ? (v) async { setPosition(Duration(seconds: v.toInt()));