getNowPlayingStream method

  1. @override
Stream<NowPlayingDataChanged?> getNowPlayingStream()
override

Now playing stream of icy / meta info

Implementation

@override
Stream<NowPlayingDataChanged?> getNowPlayingStream() {
  if (_nowPlayingInfo != null) {
    return _nowPlayingInfo!;
  }

  var playerReadyStream = nowPlayingInfoEventChannel
      .receiveBroadcastStream()
      .asBroadcastStream(onCancel: (sub) {
    sub.cancel();
    _nowPlayingInfo = null;
  });

  return playerReadyStream.map<NowPlayingDataChanged>((dynamic event) {
    return NowPlayingDataChanged.fromJson(event as String);
  });
}