subscribePlayerContext static method

Stream<PlayerContext> subscribePlayerContext()

Subscribes to the PlayerContext and returns it.

Throws a PlatformException if this fails Throws a MissingPluginException if the method is not implemented on the native platforms.

Implementation

static Stream<PlayerContext> subscribePlayerContext() {
  try {
    var playerContextSubscription =
        _playerContextChannel.receiveBroadcastStream();
    return playerContextSubscription.asyncMap((playerContextJson) {
      var playerContextMap =
          jsonDecode(playerContextJson.toString()) as Map<String, dynamic>;
      return PlayerContext.fromJson(playerContextMap);
    });
  } on Exception catch (e) {
    _logException(MethodNames.subscribePlayerContext, e);
    rethrow;
  }
}