Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Universal Mac / iOS VideoPlayer, compatible with Cocos2D, that is used in iTraceur
branch: master

This branch is even with baksogen:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
CCVideoPlayer-mac.xcodeproj
CCVideoPlayer.xcodeproj
Classes
Resources
libs
.gitignore
CCVideoPlayer_Prefix.pch
LICENSE.cocos2d
LICENSE.cocosdenshion
README.md
main.m

README.md

ATTENTION: SOURCE MOVED

VideoPlayer is now known as CCVideoPlayer and is available as a part of cocos2d-iphone-extensions repo: https://github.com/cocos2d/cocos2d-iphone-extensions
All further development will be done there. This repo is outdated now.

VideoPlayer

Simple Video Player for Cocos2D apps. This repo contains iOS & Mac XCode projects, demonstrating usage of VideoPlayer.

Features

  • Universal support (iPhone + iPad + Mac)
  • Play / Cancel (by tap or key pressed on mac)
  • Plays file from Caches or Resources directory (if found)
  • Easy to use

Limitations

  1. iOS: Supported orientations are only Landscape Left & Landscape Right ( Issue #5 )

Usage

VideoPlayer by itself is located in Classes/VideoPlayer folder. CustomVideoView.nib is located in Resources and needed only for Mac. (Probably it's possible to remove it and load view with code only. Issue #3 )

To link it you need MediaPlayer.framework for iOS & QTKit for Mac

To play videofile foo.mp4 simply use:

// First tries to find file in NSCachesDirectory and play it from there
// Second tries to find file in resources directory
// Does nothing if file not found 
[VideoPlayer playMovieWithFile: @"bait.mp4"];

VideoPlayer ignores orientation change by itself, but you can manually change it's orientation:

UIDeviceOrientation deviceOrientation = (UIDeviceOrientation)toInterfaceOrientation;
[VideoPlayer updateOrientationWithOrientation: deviceOrientation ];

Playing video uses a lot of resources, so it's recommended to stop gpu render and other heavy tasks, while playing video. You can do this by setting a VideoPlayer delegate:

[VideoPlayer setDelegate: self]; 

Your delegate class should conform to VideoPlayerDelegate and implement these methods:

- (void) moviePlaybackFinished
{
    [[CCDirector sharedDirector] startAnimation];
}

- (void) movieStartsPlaying
{
    [[CCDirector sharedDirector] stopAnimation];
}

It's a weak link, so don't forget to set delegate to nil in dealloc.

Supported Video Formats

Supported formats are the same as for MPMediaPlayer for iOS and QTMovie for Mac. mp4 bundled with tests is compatible with both Mac & iOS

Contribution

VideoPlayer is a part of stuff, that i used in iTraceur - Freerunning / Platform Game. I would like to share with Open Source community as much as possible, cause Open Source helped me a lot with iTraceur. So questions, suggestions and corrections are always welcome.

Something went wrong with that request. Please try again.