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
103 stars 187 forks source link

I'm unable to play YouTube shorts #210

Open BusayoSamuel opened 3 months ago

BusayoSamuel commented 3 months ago

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

Essenbay commented 3 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