sarbagyastha / youtube_player_flutter

A Flutter plugin for inline playback or streaming of YouTube videos using the official iFrame Player API.
https://youtube.sarbagyastha.com.np
BSD 3-Clause "New" or "Revised" License
708 stars 820 forks source link

[BUG] YoutubePlayerController.convertUrlToId doesn't work on live shared URL. #789

Open quoc-huynh-cosee opened 1 year ago

quoc-huynh-cosee commented 1 year ago

Describe the bug Using the YoutubePlayerController.convertUrlToId on a shared llive URL returns null. The format of the shared URL is https://www.youtube.com/live/{videoId}?feature=share.

To Reproduce Steps to reproduce the behavior:

  1. Go to a Youtube live video.
  2. Press share.
  3. Use the YoutubePlayerController.convertUrlToId with the shared URL.

Expected behavior The ID should be extracted instead of returning null.

Eng-Mohamed-Elsayed commented 1 year ago

Fix

 String? getYoutubeVideoIdByURL(String url) {
    final regex = RegExp(r'.*\?v=(.+?)($|[\&])', caseSensitive: false);
    try {
      if (regex.hasMatch(url)) {
        return regex.firstMatch(url)!.group(1);
      }
    } catch (e) {
      return null;
    }
  }
Add00w commented 1 year ago

This PR fixes the issue https://github.com/sarbagyastha/youtube_player_flutter/pull/868#issue-1889119772

Add00w commented 1 year ago

use the changes like this :

    git:
      url: https://github.com/Add00w/youtube_player_flutter.git
      ref: master
      path: packages/youtube_player_flutter

for temporary

DevanshiGor commented 2 months ago

I am also facing same issue. please suggest some workaround.