How does VideoPlayer work?

Hello everybody! I’ve used cocos2d-x in a couple of games before, but only in the first iterations of this cool engine. I’ve been working with other frameworks since (for a number of reasons), so I’ve missed the cocos2d-x 2.x and 3.x iterations.

Now I want to engage in a personal project with cocos2d-x 3.1, and I need to be able to play several videos in full-screen. Some time ago, I read that this could only be achieved writing native code for each platform… but I’ve just noticed the new VideoPlayer class, in one of the latest releases!

Has anybody used this class already? Does it work well both in Android and iOS? What kind of video formats can it play? I want to experiment with it myself, of course (I’m already downloading the last release as I write this), but any experience or tips beforehand would be much appreciated :slight_smile:

@lorenzochomp

The current version of VideoPlayer only supports iOS and Android . It calls the native media player on each platform to play video.
So the supported video format is platform dependent. If you have any suggestions after trying, please let me know. I will keep in touch with the guy who implements the VideoPlayer widget.

Thanks! iOS and Android support is fine for the moment. I’ll try to start coding my app this weekend, and I’ll test the VideoPlayer class first. I’ll share my results here when I’m done :slight_smile:

1.not work in android. videoview 0:0
2.not good in ipad, the videoplay not at center

Ouch… that happened to you with the 3.1 release? I started last night to test this, and I was having issues to compile the Win32 build (I know it doesn’t work with this platform, but my issues were related the new UI classes).

If this doesn’t work, I was thinking in going back to cocos2d-x v2.2, and wrapping the native video player myself, as explained here: http://www.gethugames.in/blog/2013/09/cocos2d-x-cross-platform-video-player-part-2-android.html

I like the 3.x API much more, though :frowning:

Ok… after having several issues when trying to compile with UI features (including the VideoPlayer), I’ve decided to go back to version 2.2.5 of cocos2d-x, it’s a bit more stable, I think.

I’m following this tutorial for native video playback, in case someone needs to do the same: http://www.gethugames.in/blog/2013/09/cocos2d-x-cross-platform-video-player-ios.html

@kyo9999
What’s the problem?

@lorenzochomp
What’s the UI issue?

  1. Cocos2d-x 3.1.1 VideoPlayer VideoView 0:0 in Android
    Cocos2d-x 3.1.1 VideoPlayer VideoView 0:0 in Android

  2. C++ Cocos2d-x 3.1.1 VideoPlayer not at center in iPad
    C++ Cocos2d-x 3.1.1 VideoPlayer not at center in iPad

@zhangxm Thanks a lot for your reply. To be fair, my issues are likely caused by my ignorance of the newer Visual Studio Express 2013, not by cocos2d-xv3.x. I got quite frustrated trying to compile my project when using the ui stuff (like the said VideoPlayer). The thread is this: Cocos2dx v3.0 UI Classes - gotta get this workign

I love the new API and the C++11 support, but I’m feeling that this branch is still too experimental for serious applications, so I think I’ll wait a bit and stick to cocos2d-xv2.x for the time being :slight_smile:

@lorenzochomp - can you tell me what you feel is experimental and not for serious development? V3 is way more stable and efficient that v2. Are you just having trouble with VideoPlayer?

@slackmoehrle - Well, my “experimental sensation” started as soon as I downloaded the package for v3.1 in my Linux box. I had to upgrade my g++ (I had 4.6, which is very widespread and supports most features of C++11, but under the old name of C++0x), and then I noticed that something was broken with the CMake scripts (I think that the bug is reported somewhere), so I had to manually tweak it (I guess that almost anybody uses cocos2d-x on Linux, so it wasn’t well tested).

When v3.2 RC0 was out, I read that I had to upgrade g++ once again (to v4.9). So I tried on Windows this time, with Visual Studio. Everything was ok, until I started to meddle with the VideoPlayer…

Another reason that makes me switch back to v2.x, is that v3.x has drop several target platforms (like BB10). I guess that’s because of C++11.

So… why do you say that v3.x is “way more stable and efficient” than v3.x? Are you talking about GLES 3?

About BB10, yep, it is because of c++11.
About linux, we only test it on Ubuntu. Because there are so many types of linux, we can not test on all linux platforms.

v3.x is more stable than v2.x is that:

  • we fixed many bugs
  • we use c++ 11, which will reduce some errors, such as range loop support
  • c++11 supports move semantic which can reduce copy operation
  • use more efficient algorithm and structure, such as unordered_map, std::sort
  • use new renderer, has auto batching and auto culling

I am able to play video using 3.2 v of cocos2d-x on Android. But I have 2 issues.

  1. When I touch video then video goes to pause state. ( How to disable touch on video)
  2. When I press back button its fullScreenMode gets disabled. (I do not want video player to handle back button).

Regards
Milind

@mkdk I am having problems in play video on android device. The UI Video player works on IOS but when I try to play a video(from my res folder) I get a pop up which says “Can not play this video”. Can you help me out on this?

what path are you using for the video? Show me your calls to VideoPlayer

@slackmoehrle Unable to play a video on android device using Ui Video Player