newtaDev / pod_player

Video player for flutter web & mobile devices, Play video from youtube or vimeo or network in flutter using pod player
https://pub.dev/packages/pod_player
MIT License
106 stars 202 forks source link

I'm unable to play YouTube shorts #210

Open BusayoSamuel opened 5 months ago

BusayoSamuel commented 5 months ago

I get the invalid argument error whenever I attempt to play YouTube shorts

Essenbay commented 4 months ago

Use this function to get youtube code

   String getYoutubeVideoId(String url) {
    final RegExp regExp = RegExp(
        r"(?:https?:\/\/)?(?:(?:www\.)?youtube\.com\/(?:(?:shorts\/)|(?:watch\?v=))|(?:youtu.be\/))([\-a-zA-Z0-9_]+)");
    final match = regExp.firstMatch(url);
    final result = match?.group(1) ?? "";
    return result;
  }

And set it to datasource of controller