Untitled

 avatar
unknown
plain_text
2 years ago
1.5 kB
29
Indexable
  Future<void> _onIndexChange(PlayListNotifier notifier, int value) async {
    // if (notifier.cancelAtEndOfChapter != null) {
    //   notifier.setCancelAtEndOfChapter(false);
    // }
    ///////////////////////////////////////////////////////new request
    // PostBookTime bookTime = PostBookTime(
    //     bookId: notifier.playerProps?.bookInfo.data?.first.id ?? 0,
    //     chapterId: notifier
    //             .playerProps?.bookInfo.data?.first.soundFiles?[value - 1].id ??
    //         0,
    //     type: 'audio',
    //     duration: playListNotifier.player.duration.toString(),
    //     subscriptionType: notifier.playerProps?.bookInfo.data?.first.type ?? '',
    //     price: notifier.playerProps?.bookInfo.data?.first.price ?? '');
    // await ApiProvider(httpClient: Dio()).postBookTime(bookTime);

    ///////////////////////////////////////////////////////new request
    if (value ==
        notifier.playerProps!.bookInfo.data!.first.soundFiles!.length) {
      notifier.setCancelAtEndOfChapter(true);
    }

    //Next chapter
    await playListNotifier.postListeningTime(
      playListNotifier.player.position.toString(),
    );
    notifier.changeIndex(value);

    if (!notifier.isSetMediaLoading) {
      await notifier.checkDownloaded();
      await notifier.setMediaItem(
        notifier.playerProps!.bookInfo,
        notifier.listIndex ?? 0,
      );
      await notifier.setSource('', notifier.player.playing);
    }

    notifier.didLog50 = false;
    notifier.didLog85 = false;
  }
Editor is loading...
Leave a Comment