haxpor / cocos2dx-videoplayer-ios

Cross Platform (iOS and Android) Video Player for Cocos2d-x

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cocos2dx-videoplayer-ios

Build Status

Brief

Based on original work by saiy2k.

This refactored, re-structured files and introduced cleaner way to hook up MPMoviePlayerController to work with cocos2dx.

In the original work, it will make changes on EAGLView class which is part of cocos2dx library. But not anymore, EAGLView class is left intact. Also in coding the game, this aims to avoid using .mm file as those classes working with the game can be used to add more support on other platform i.e. Android. All in all, you can focus on C++ purely.

See more detail below.

Code

As the core, it has the following core files.

  1. CCVideoPlayeriOS.h and CCVideoPlayeriOS.mm Low level code hooking up videoplayer stuff and cocos2d view.

  2. CCVideoPlayerWrapper.h and CCVideoPlayerWrapper.mm A bridge class interfacing low level class with C++ class (which will be only used when coding game)

  3. CCVideoPlayer.h and CCVideoPlayer.cpp Pure C++ class that will be using by users while coding game

Usage

  1. Copy CCVideoPlayeriOS (.h, and .mm), CCVideoPlayerWrapper (.h and .mm), CCVideoPlayer (.h and .cpp), and ICCVideoPlayerProtocol.h to your project.

  2. Whenever you want to play video, add this following code at the top. #include "CCVideoPlayer.h"

  3. Play video with this code. CCVideoPlayer::sharedInstance()->playVideo("videos/vidfile");

Note

It only detects .mp4 file extension.

Whenever call playVideo(), its video screen will be put on top of the current view and the video automatically plays. It won't have any playback control buttons over the video screen. The video will be scaled with respect to aspect ratio against the screen's resolution.

Whenever the video finishes playing, it will automatically remove out its view and go back to the previous view. You can add custom code up on its completion by implement ICCVideoPlayerProtocol.h in your class via onVideoFinish() method.

About

Cross Platform (iOS and Android) Video Player for Cocos2d-x


Languages

Language:C++ 75.2%Language:C 15.9%Language:Objective-C 4.4%Language:Objective-C++ 3.5%Language:HTML 1.0%Language:CMake 0.0%