mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
bugfixed first played playlist/track doesn't play
This commit is contained in:
parent
932462d773
commit
39a92a56f3
BIN
assets/warmer.mp3
Normal file
BIN
assets/warmer.mp3
Normal file
Binary file not shown.
@ -33,6 +33,16 @@ class Player extends HookConsumerWidget {
|
||||
final AsyncSnapshot<SharedPreferences?> localStorage =
|
||||
useFuture(future, initialData: null);
|
||||
|
||||
useEffect(() {
|
||||
/// warm up the audio player before playing actual audio
|
||||
/// It's for resolving unresolved issue related to just_audio's
|
||||
/// [disposeAllPlayers] method which is throwing
|
||||
/// [UnimplementedException] in the [PlatformInterface]
|
||||
/// implementation
|
||||
player.setAsset("assets/warmer.mp3");
|
||||
return null;
|
||||
}, []);
|
||||
|
||||
useEffect(() {
|
||||
if (localStorage.hasData) {
|
||||
_volume.value = localStorage.data?.getDouble(LocalStorageKeys.volume) ??
|
||||
|
@ -1,5 +1,3 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
@ -52,25 +50,28 @@ class PlayerView extends HookConsumerWidget {
|
||||
body: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
currentTrack?.name ?? "Not playing",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.headline4?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: paletteColor.titleTextColor,
|
||||
),
|
||||
),
|
||||
artistsToClickableArtists(
|
||||
currentTrack?.artists ?? [],
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
textStyle: Theme.of(context).textTheme.headline6!.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: paletteColor.bodyTextColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
currentTrack?.name ?? "Not playing",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.headline4?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: paletteColor.titleTextColor,
|
||||
),
|
||||
),
|
||||
artistsToClickableArtists(
|
||||
currentTrack?.artists ?? [],
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
textStyle: Theme.of(context).textTheme.headline6!.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: paletteColor.bodyTextColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
HookBuilder(builder: (context) {
|
||||
final ticker = useSingleTickerProvider();
|
||||
|
@ -224,7 +224,10 @@ class Playback extends ChangeNotifier {
|
||||
final ytTrack = await toYoutubeTrack(youtube, track);
|
||||
if (setTrackUriById(track.id!, ytTrack.uri!)) {
|
||||
await player
|
||||
.setAudioSource(AudioSource.uri(Uri.parse(ytTrack.uri!)))
|
||||
.setAudioSource(
|
||||
AudioSource.uri(Uri.parse(ytTrack.uri!)),
|
||||
preload: true,
|
||||
)
|
||||
.then((value) {
|
||||
_currentTrack = track;
|
||||
notifyListeners();
|
||||
|
Loading…
Reference in New Issue
Block a user