playerStateStream property

Stream<PlaybackState> get playerStateStream

Returns a stream of combined player state updates.

Implementation

Stream<PlaybackState> get playerStateStream => Rx.combineLatest7<
  ProcessingState,
  bool,
  int,
  int,
  double,
  double,
  String?,
  PlaybackState
>(
  _processingStateSubject.stream,
  _playingSubject.stream,
  _positionSubject.stream,
  _durationSubject.stream,
  _volumeSubject.stream,
  _speedSubject.stream,
  Stream.value(
    _audioSource is UriAudioSource
        ? (_audioSource as UriAudioSource).title
        : null,
  ),
  (processingState, playing, position, duration, volume, speed, title) =>
      PlaybackState(
        processingState: processingState,
        playing: playing,
        position: position,
        duration: duration,
        timestamp: DateTime.now().millisecondsSinceEpoch,
        speed: speed,
        volume: volume,
        title: title ?? 'Unknown',
        artist:
            _audioSource is UriAudioSource
                ? (_audioSource as UriAudioSource).artist
                : null,
        album:
            _audioSource is UriAudioSource
                ? (_audioSource as UriAudioSource).album
                : null,
        url:
            _audioSource is UriAudioSource
                ? (_audioSource as UriAudioSource).uri.toString()
                : null,
      ),
);