Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
1  
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. –  Jaakko Lipsanen Jul 10 '13 at 5:39
    
I wonder what happens if you play a video with ads... –  congusbongus Jul 10 '13 at 7:33
    
It'll play the ad. :) –  Vaughan Hilts Jul 10 '13 at 12:43

2 Answers 2

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.