Giter Site home page Giter Site logo

ccvideoplayer's Introduction

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.

ccvideoplayer's People

Contributors

psineur avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.