getHttpLiveStreamUrl method

Future<String> getHttpLiveStreamUrl(
  1. VideoId videoId
)

Gets the HTTP Live Stream (HLS) manifest URL for the specified video (if it's a live video stream).

Implementation

Future<String> getHttpLiveStreamUrl(VideoId videoId) async {
  final watchPage = await WatchPage.get(_httpClient, videoId.value);

  final playerResponse = watchPage.playerResponse;

  if (playerResponse == null) {
    throw TransientFailureException(
        'Couldn\'t extract the playerResponse from the Watch Page!');
  }

  if (!playerResponse.isVideoPlayable) {
    throw VideoUnplayableException.unplayable(videoId,
        reason: playerResponse.videoPlayabilityError ?? '');
  }

  var hlsManifest = playerResponse.hlsManifestUrl;
  if (hlsManifest == null) {
    throw VideoUnplayableException.notLiveStream(videoId);
  }
  return hlsManifest;
}