-
-
Notifications
You must be signed in to change notification settings - Fork 504
Description
in your positionIndicator
Widget in example ,
Widget positionIndicator(MediaItem mediaItem, PlaybackState state) {
double seekPos;
print(state.currentPosition); //*********************************** HERE 1
return StreamBuilder(
stream: Rx.combineLatest2<double, double, double>(
_dragPositionSubject.stream,
Stream.periodic(Duration(milliseconds: 200)),
(dragPosition, _) => dragPosition),
builder: (context, snapshot) {
print(state.currentPosition); //++++++++++++++++++++++++++++++HERE 2
double position = snapshot.data ?? state.currentPosition.toDouble();
double duration = mediaItem?.duration?.toDouble();
return Column(
children: [
...
I added 2 printline , HERE 1
and HERE 2
,
but I don't know why the value of HERE 2
will be updated but the value of HERE 1
is constant after a little wihle after play the audio.
because I see the positionIndicator Widget is in StreamBuilder
of type ScreenState
and also ScreenState includes final state = screenState?.playbackState;
which it includes currentPosition getter.
so I think the source of HERE 1
and HERE 2
are both from ScreenState and only because HERE 2
resides into :
stream: Rx.combineLatest2<double, double, double>(
_dragPositionSubject.stream,
Stream.periodic(Duration(milliseconds: 200)),
(dragPosition, _) => dragPosition,
),
should not affect the value of currentPosition
.
so if it is possible , some one explain why the value of HERE 2
will be updated during the time ( I know the HERE 2
should be printed at least every 200 mil ) but I don't understand 2 thing :
1- why HERE 1
and HERE 2
value are not same after a little time after play the audio?
2- why do you don't update PlaybackState
every 200 mil in AudioService , because it contains currentPosition
and should add its value to stream ?
Thanks to community.