mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55: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 =
|
final AsyncSnapshot<SharedPreferences?> localStorage =
|
||||||
useFuture(future, initialData: null);
|
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(() {
|
useEffect(() {
|
||||||
if (localStorage.hasData) {
|
if (localStorage.hasData) {
|
||||||
_volume.value = localStorage.data?.getDouble(LocalStorageKeys.volume) ??
|
_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:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
@ -52,7 +50,9 @@ class PlayerView extends HookConsumerWidget {
|
|||||||
body: Column(
|
body: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Column(
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
currentTrack?.name ?? "Not playing",
|
currentTrack?.name ?? "Not playing",
|
||||||
@ -72,6 +72,7 @@ class PlayerView extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
HookBuilder(builder: (context) {
|
HookBuilder(builder: (context) {
|
||||||
final ticker = useSingleTickerProvider();
|
final ticker = useSingleTickerProvider();
|
||||||
final controller = useAnimationController(
|
final controller = useAnimationController(
|
||||||
|
@ -224,7 +224,10 @@ class Playback extends ChangeNotifier {
|
|||||||
final ytTrack = await toYoutubeTrack(youtube, track);
|
final ytTrack = await toYoutubeTrack(youtube, track);
|
||||||
if (setTrackUriById(track.id!, ytTrack.uri!)) {
|
if (setTrackUriById(track.id!, ytTrack.uri!)) {
|
||||||
await player
|
await player
|
||||||
.setAudioSource(AudioSource.uri(Uri.parse(ytTrack.uri!)))
|
.setAudioSource(
|
||||||
|
AudioSource.uri(Uri.parse(ytTrack.uri!)),
|
||||||
|
preload: true,
|
||||||
|
)
|
||||||
.then((value) {
|
.then((value) {
|
||||||
_currentTrack = track;
|
_currentTrack = track;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
Loading…
Reference in New Issue
Block a user