youtube url

May 6, 2013 at 9:20 PM
Is there any functions available that will play the video through the youtube url? I'd rather not duplicate functionality if it already exists... If not then I guess I'll have to parse the id out myself and send that in.
Coordinator
May 6, 2013 at 9:22 PM
No, there is no such method... but this should be a simple regex...
May 6, 2013 at 9:48 PM
ok, well if anyone else needs to find the ID, here's one that I found that I'm using:

string regExp = @"(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^""&?\/ ]{11})";
        Regex rgx = new Regex(regExp, RegexOptions.IgnoreCase);

        Match matches = rgx.Match(t);
        if (matches.Success)
            return matches.Groups[1].Value;
        else
            return "";