Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to launch a YouTube URL on Windows Phone 7

I would like to launch directly to the YouTube player on Windows Phone 7.

I tried using WebBrowserTask and giving a YouTube URL, it opens up the browser and brings me to a page with a thumbnail of the YouTube video, I need to click on the thumbnail before the video plays.

I like to skip the extra click. I like the user to click a button in my app, and it should play the video directly. Is there a way to do it?

like image 520
slingkid Avatar asked Nov 13 '10 02:11

slingkid


2 Answers

Once you have the Youtube app installed, from within you application you can start the WebBrowserTask and do the follwing:

        Regex Youtube = new Regex("youtu(?:\\.be|be\\.com)/(?:.*v(?:/|=)|(?:.*/)?)([a-zA-Z0-9-_]+)");            

        Match youtubeMatch = Youtube.Match(YOUTUBE_VIDEO_URL);           

        string id = string.Empty;

        if (youtubeMatch.Success)
            id = youtubeMatch.Groups[1].Value; 

        WebBrowserTask webBrowserTask = new WebBrowserTask();


        webBrowserTask.URL = "vnd.youtube:"+ id +"?vndapp=youtube_mobile";
        webBrowserTask.Show();

That should launch the browser, then automatically launch the Youtube App. Cheers!

like image 86
EdGs Avatar answered Jan 03 '23 00:01

EdGs


Finally I've worked out a clean solution (without browser task, and no "double back key pressing"):

http://mytoolkit.codeplex.com/wikipage?title=YouTube

like image 43
Rico Suter Avatar answered Jan 03 '23 02:01

Rico Suter