Search code examples
flutteryoutubemedia-player

Playing youtube live stream using permanent URL


I want to display a live stream from YouTube in Flutter using a permanent URL.

It's very simple if I have the video Id by simply using youtube_player_flutter as follows:

YoutubePlayerController _controller = YoutubePlayerController(
  initialVideoId: 'NpEaa2P7qZI',
  params: YoutubePlayerParams(
    showControls: true,
    showFullscreenButton: true,
  ),
);

However, I want to display videos from permanent URLs like on of these:

The reason being that https://www.youtube.com/watch?v=nA9UZF-SZoQ where the id is nA9UZF-SZoQ (the current live stream url) is not always valid and the app will break if it changes.

Is there as solution to play permanent URLs from youtube in flutter? Do I have to use the youtube api for this or maybe look for an iframe solution instead?

Thank you.


Solution

  • Made a pull request at the github repo. If its merged, it will be as simple as:

    YoutubePlayerController _controller = YoutubePlayerController(
      initialVideoId: 'placeholder-will-be-ignored',
      channelId: 'YOUTUBE_CHANNEL_ID',
      params: YoutubePlayerParams(
        showControls: true,
        showFullscreenButton: true,
      ),
    );