You might want to play a movie in your game in order to enrich the representation. Cocos2d-x provides a VideoPlayer
class for this purpose. This class makes it easy to play a movie; however, it is still an experimental
class. So, you have to be very careful while using it.
You have to prepare something before using the VideoPlayer
class.
You have to add the movie file to the
Resources/res
folder. In this case, we add the video calledsplash.mp4
.Next, you have to including a header file. The code to do so is as follows:
#include "ui/CocosGUI.h" USING_NS_CC; using namespace experimental::ui;
Then, you have to add the following code to the
proj.android/jni/Android.mk
file for building an Android application.LOCAL_WHOLE_STATIC_LIBRARIES += cocos_ui_static $(call import-module,ui)
In Xcode, you have to add
MediaPlayer.framework
for iOS, as shown in the following image: