fix(player): stabilize first playback and refresh design
This commit is contained in:
@@ -61,6 +61,7 @@ class EstadoRadio extends ChangeNotifier {
|
||||
|
||||
bool _cargandoPopulares = false;
|
||||
bool _cargandoBusqueda = false;
|
||||
EstadoReproduccion _estadoReproduccion = EstadoReproduccion.detenido;
|
||||
String? _errorCarga;
|
||||
|
||||
List<Emisora> get populares => _populares;
|
||||
@@ -118,12 +119,11 @@ class EstadoRadio extends ChangeNotifier {
|
||||
/// Escucha el stream de estado del audio y gestiona errores de reproducción.
|
||||
void _escucharErroresReproduccion() {
|
||||
_suscripcionEstadoAudio = audio.estadoStream.listen((estado) {
|
||||
if (estado == EstadoReproduccion.error) {
|
||||
if (timer.activo) {
|
||||
unawaited(timer.cancelar());
|
||||
}
|
||||
notifyListeners();
|
||||
_estadoReproduccion = estado;
|
||||
if (estado == EstadoReproduccion.error && timer.activo) {
|
||||
unawaited(timer.cancelar());
|
||||
}
|
||||
notifyListeners();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -192,7 +192,19 @@ class EstadoRadio extends ChangeNotifier {
|
||||
}
|
||||
|
||||
Future<void> reproducir(Emisora emisora) async {
|
||||
final actual = audio.emisoraActual;
|
||||
final mismaEmisoraActiva = actual?.uuid == emisora.uuid;
|
||||
final yaEstaConectandoOSonando =
|
||||
_estadoReproduccion == EstadoReproduccion.cargando ||
|
||||
_estadoReproduccion == EstadoReproduccion.reproduciendo ||
|
||||
audio.estaSonando;
|
||||
if (mismaEmisoraActiva && yaEstaConectandoOSonando) {
|
||||
notifyListeners();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
notifyListeners();
|
||||
await audio.reproducir(emisora);
|
||||
unawaited(radio.registrarClick(emisora.uuid));
|
||||
await _aplicarPresetActivo(_presetParaEmisora(emisora.uuid));
|
||||
|
||||
Reference in New Issue
Block a user