0

Currently i am working on music app and according to my ui i have to manage audio player with carousel slider.The without carousel slider it is working fine but with carousel slider when click on the shuffle or when onPageChanged called, i used the skipToQueueItem for play particular song with audio player, that time suddenly audioHandler.mediaItem listen continuously called and in every 1 second changed song and slider images because of skipToQueueItem line.I used just audio and audio service package.For privacy i am not sharing the code.But for update carousel slider with audio i used below code.

      audioHandler.queue.listen((playlist) async {
      if (playlist.isEmpty) {
      mediaItemsListNotifier.value = [];
      } else {
      ///Update media items notifier list value
      mediaItemsListNotifier.value = playlist;
      await audioHandler.updateQueue(playlist);
      }
      });


       audioHandler.mediaItem.listen((mediaItem) async {
       int index = audioHandler.queue.value.indexOf(mediaItem!);
       currentSliderIndex.value = index >= 0 ? index : 0;

       ///Main issue using this line
       await audioHandle.skipToQueueItem(currentSliderIndex.value);
       carouselController.jumpToPage(currentSliderIndex.value);
       }
  • My comprehension of your question broke down after the word "but". I don't understand, but "what"? – Ryan Heise Nov 25 '22 at 01:26
  • I updated question @RyanHeise and please check – Kesmi Topiwala Nov 25 '22 at 04:21
  • OK, but now you have this key line of code which you commented as being the "main issue", calling `skipToQueueItem`, but for privacy reasons you won't show what it actually does. I could guess, but I don't want to put in the effort to write up an answer based on a guess. If `skipToqueueItem` is so important, you should probably share what that line actually does. It's clear that it's a key part of your unintentional loop, but I can't explain that to you without pointing to your unrevealed code. – Ryan Heise Nov 25 '22 at 05:13
  • skipToQueueItem is working for play current media item according to index wise which i getting from the audioHandler.mediaItem.listen after update my media item list without skipToQueueItem the audioHandler is not play current mediaItem @RyanHeise – Kesmi Topiwala Nov 25 '22 at 05:46
  • Since you didn't provide what I asked for, I'm afraid I can't help you, but hopefully someone else will help you. – Ryan Heise Nov 25 '22 at 08:19
  • I am used skipToQueueItem line for play particular media item after shuffle enabled but also changed carousel slider images because media item list is shuffling and if i am wrong could you explain again. For play particular song we used the skipToQueueItem method of audio handler so any replace option of skipToQueueItem method? @RyanHeise – Kesmi Topiwala Nov 25 '22 at 11:16
  • I think you have misunderstood what I'm asking because you still did not reveal the code. I can already see the method call for `skipToQueueItem`, but I don't know what that method does without seeing the method definition. The method definition tells me what that method actually does. Somewhere within the implementation of that method will be the answer to your question, so if you don't reveal that, then you can't have a definitive answer. – Ryan Heise Nov 27 '22 at 02:10

0 Answers0