0
\$\begingroup\$

Is there any way to play a YouTube video given the URL in XNA? I know it can be done using a shockwave control but I need it in XNA.

I need to make a game where it has to be a YouTube video on the back... something like this:

Texture2D texture = YouTubevideoPlayer.GetTexture();

Because I need the streaming on a texture.

I think it can be done by using the youtube APIs... but some tutorial or useful code its a great help.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ I don't know if this will help anything, but you should look at Awesomium: awesomium.com/about. It allows you to render webpages in normal applications. There are plenty of talk about how to integrate it with XNA that can be found by googling. \$\endgroup\$
    – user9790
    Commented Jul 10, 2013 at 5:39
  • \$\begingroup\$ I wonder what happens if you play a video with ads... \$\endgroup\$ Commented Jul 10, 2013 at 7:33
  • \$\begingroup\$ It'll play the ad. :) \$\endgroup\$ Commented Jul 10, 2013 at 12:43

2 Answers 2

1
\$\begingroup\$

According to the documentation, only .wmv format is supported, and even then it must be encoded using a limited set of parameters.

From the link:

1) Video enabled with Digital Rights Management cannot be used.
2) Video must be encoded to the Windows Media Video 9 "Main" profile by using the VC-1 standard.
3) Video must be encoded with a constant bit rate (CBR).
4) Video must include an audio track.
5) Audio accompanying the video must be Windows Media Audio (.wma) encoded, with a single-pass CBR format.
6) XNA Game Studio supports the following maximum bit rates: 
Profile          Level          Maximum Bit Rate          Representative resolutions by frame rate
Main             Low            2 Mbps                    320 × 240 @ 24 Hz (QVGA) 
                 Medium         10 Mbps                   720 × 480 @ 30 Hz (480p) 
                                                          720 × 576 @ 25 Hz (576p) 
                 High           20 Mbps                   1280 × 720 @ 30 Hz (720p) 

That's not to say there isn't possibly some clever way to stream the video from YouTube, convert chunks of it to .wmv with the required encoding as they stream in, and load those chunks to the content manager, but it's nothing that would be supported by the framework, and sounds like a lot of work for a problem that probably has a better solution.

\$\endgroup\$
0
\$\begingroup\$

You can use Awesomeium in XNA which has a built in flash player - simply creating a local page with the player and then playing it will be enough. You can then render this texture to the screen.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .