5

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?

Matthew Flaschen
  • 278,309
  • 50
  • 514
  • 539
slingkid
  • 101
  • 2
  • 6

7 Answers7

8

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!

EdGs
  • 356
  • 6
  • 18
  • Thanks! This works for me, is there a way to get BACK to my app once the video finishes? – Abby Fichtner Jan 29 '11 at 19:54
  • 1
    As far as I know, not yet. The current described method is just a workaround, and the user does need to tap twice on the back button to go back to your application. Unfortunately at this point we can’t monitor, or have any kind of delegate method that would indicate the movie stopped playing. – EdGs Feb 02 '11 at 01:08
  • 1
    URL property is obsolete and URI takes only absolute URI what to do in this case? – Milan Aggarwal Aug 27 '12 at 19:39
2

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

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

Rico Suter
  • 11,548
  • 6
  • 67
  • 93
1

Try to use following sample;

  WebBrowserTask webBrowserTask = new WebBrowserTask();
  webBrowserTask.Uri = new Uri("http://www.youtube.com/embed/V3oJR5IAMxM?autoplay=1");
  webBrowserTask.Show();

this should open video directly, but I think you will have to still double click to go back.

Teoman shipahi
  • 47,454
  • 15
  • 134
  • 158
1

There is a solution for that now. You can use vnd.youtube protocol to launch the YouTube application from Microsoft and play.

C#

 Windows.System.Launcher.LaunchUriAsync(

 new System.Uri("vnd.youtube:9bZkp7q19f0")

 );

Unfortunately Launcher.LaunchUriAsync method only works with Windows Phone 8 devices and beyond.

garenyondem
  • 541
  • 9
  • 24
0

No. Mabe in next version of OS will be custom choosers and lunchers.

Lukasz Madon
  • 14,664
  • 14
  • 64
  • 108
0

To display a video from YouTube, you will need the Video Player for YouTube. Otherwise, you will need to write a custom decoder that will receive the YouTube stream and display it in a MediaElement.

Den
  • 16,686
  • 4
  • 47
  • 87
0

As you've discovered this isn't currently possible.

There is currently no way to launch another application, other than by using a Launcher or Chooser.

On the YouTube site, individual videos can be configured to autoplay or not. I'm not aware of a way to override this.

However, on the phone this is different. YouTube uses flash to play videos but Flash is not currently supported on the phone. YouTube videos can only be played if the YouTube application is installed. When you open the youtube site with the webbrowsertask the user must click on the image to launch the player.
If web pages were able to launch applications without first requiring user action this could be a huge security issue.

N.B. The YouTube app has special elevated privileges, not generally available, to be able to be launched in the way it is.

Matt Lacey
  • 65,560
  • 11
  • 91
  • 143