This project is read-only.

Play video in Cocos2D-XNA

Topics: Platform UI
Aug 19, 2014 at 4:22 PM
Edited Aug 20, 2014 at 2:10 AM
I build a Game in Window with OpenGL.And I need to play a movie in my Cocos2D-XNA game. But i can't find any API for Cocos2d-XNA or Monogame. Please help me!
Aug 19, 2014 at 7:42 PM
I don't understand what you have here ...
I built a game in Windows using OpenGL
Does this mean you have a custom game that is solely in OpenGL using GL and GLut calls? Or does this mean you are using Cocos2d-XNA for OpenGL and MonoGame GL?
I need to play a movie in my Cocos2D-XNA game, but I can't find any IPA for ...
IPA? That's an iOS type of distribution format.

Is this an XNA game using MonoGame and Cocos2d-XNA? If you want to play a video then you can use the Video player in MonoGame. For instance, let's say you have a full screen video as an interstitial. You can add a new DrawableComponent to your application and add a video player into the drawable component. Then you just run the video as an overlay to the root DrawableComponent that is the cocos2d-xna game. It really is that easy thanks to MonoGame and XNA.

If you are mixing runtime technologies, such as homebrew OpenGL and MonoGame with cocos2d-xna, then that's quite a bit more difficult. You would have to manually manage how the GL framebuffer allocations are handled between your game's GL content and the MonoGame GL context. Only one thread can access the root GL context at any time.
Aug 20, 2014 at 12:41 AM
Edited Aug 20, 2014 at 12:42 AM
Aw Sorry. I will explain again. I am building a Cocos2D-XNA Game in Window. And Cocos2D-XNA support both for Direct-X and OpenGL. I try Direct-X but when I use CCLabel to load a .ttf font it got a error in _renderTarget.BeginDraw();(_renderTarget is Null this function is in CCLabel-Window.cs ) .But when I use with OpenGL it run no problem. It the first problem. Now my second problem is the Video Player. When I check, MonoGame with OpenGL doesn't have class VideoPlayer. But MonoGame with Direct-X has. So now I down know what to do next. I upload my GameplayLayer with my first problem
public GameplayLayer()
            CCLabel a = new CCLabel("Hello Kanda", "fonts/kanda.ttf", 12);
            a.Position = new CCPoint(512, 384);
And it got a problem at "CCLabel a = new CCLabel("Hello Kanda", "fonts/kanda.ttf", 12);" throw _renderTarget is null
Aug 20, 2014 at 1:13 AM
I ran through the tests for the DX platform and I do not get any render target errors. I see a few stray render artifacts though.
Aug 20, 2014 at 2:09 AM
Edited Aug 20, 2014 at 2:20 AM
I just ran through the tests for the DX platform. I choose SystemFontTest and then exception throw again. Can you give me some solution ?. Maybe I should install some software ?You can see the exception with this image!
Aug 20, 2014 at 6:13 AM
In this case I bet it's a problem with your graphics card. What kind of hardware are you using? what buffer parameters did you request when you setup the application? Are you using a depth stencil? Some graphics cards that are older do not support depth stencil buffers.
Aug 20, 2014 at 2:44 PM
Thanks, I try to build on another computer. Then it work fine!. My graphics card is ATI Radeon 7690 and Intel HD 3000. But maybe because my driver too old so it get a problem. So I got another answer. I tried to Play Video on Cocos2D-XNA GDI, DirectX then it works fine. But Cocos2D-XNA with OpenGL doesn't have API for it ?. Can you tell me how to play Video with Cocos2D-XNA OpenGL ?
Aug 20, 2014 at 11:09 PM
I don't see a video player from MonoGame for OpenGL. The DX version of MonoGame uses the SharpDX media foundation support. Not sure when, if ever, the MG team will have an OpenGL desktop player for video. You could try "FNA" which is a fork of MonoGame that has support for the Linux/OpenGL desktop side:

I have never tried Ethan's MonoGame (FNA), so you would be forging a new path for the framework.
Aug 21, 2014 at 11:27 AM
Ok! I will try research FNA :D. Thanks for helping me !