Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two audio tracks play simultaneously when I close and reopen the app #837

Open
MazenCoder opened this issue Jun 16, 2024 · 0 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@MazenCoder
Copy link

MazenCoder commented Jun 16, 2024

Flutter Version
Flutter stable: 3.22.1

Lib Version
assets_audio_player: ^3.1.1

** Platform (Android / iOS ) **

Two audio tracks play simultaneously when I close and reopen the app.
I tried to call the stop() method, but it didn't work to stop the first track.

Future<List<StationModel>> onInitApp() async {

    bool isPlaying = audioPlayer.isPlaying.value;
    if (isPlaying) await audioPlayer.stop();

    final repository = ref.watch(radioRepositoryProvider);
    final result = await repository.getHistorys(stations);
    return result.fold((l) => throw l.message, (r) async {
      Box<dynamic> settings = Boxes.settings();
      int lastIndex = settings.get(Keys.lastIndex, defaultValue: 0);
      List<Audio> audios = _stationToMediaItem(r);
      await audioPlayer.open(
        Playlist(
          audios: audios,
          startIndex: lastIndex,
        ),
        showNotification: true,
        autoStart: true,
      );
      return r;
    });
  }
@MazenCoder MazenCoder added the bug Something isn't working label Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants