Skip to content

Commit

Permalink
Added video test for iOS. Runs and changes orientation OK on simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
psineur committed Apr 12, 2011
1 parent 3b53390 commit 4090d0e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CCVideoPlayer.xcodeproj/project.pbxproj
Expand Up @@ -56,6 +56,7 @@
6D466C9E1353D069005D6364 /* VideoPlayerImplMac.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D466C971353D069005D6364 /* VideoPlayerImplMac.m */; };
6D466C9F1353D069005D6364 /* VideoPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D466C991353D069005D6364 /* VideoPlayer.m */; };
6D466CFC1353D4D6005D6364 /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D466CFB1353D4D6005D6364 /* MediaPlayer.framework */; };
6D466D7C1353D846005D6364 /* bait.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 6D466D7B1353D846005D6364 /* bait.mp4 */; };
DC6640030F83B3EA000B3E49 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */; };
DC6640050F83B3EA000B3E49 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640040F83B3EA000B3E49 /* OpenAL.framework */; };
DCCBF1B70F6022AE0040855A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */; };
Expand Down Expand Up @@ -313,6 +314,7 @@
6D466C981353D069005D6364 /* VideoPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoPlayer.h; sourceTree = "<group>"; };
6D466C991353D069005D6364 /* VideoPlayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VideoPlayer.m; sourceTree = "<group>"; };
6D466CFB1353D4D6005D6364 /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; };
6D466D7B1353D846005D6364 /* bait.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = bait.mp4; sourceTree = "<group>"; };
DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
DC6640040F83B3EA000B3E49 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; };
DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -672,6 +674,7 @@
50F414EB1069373D002A0D5E /* Resources */ = {
isa = PBXGroup;
children = (
6D466D7B1353D846005D6364 /* bait.mp4 */,
E02BB762126CC1E0006E46A2 /* iTunesArtwork */,
E02BB4FE126CA50F006E46A2 /* Icon@2x.png */,
E02BB4FF126CA50F006E46A2 /* Icon-Small@2x.png */,
Expand Down Expand Up @@ -1155,6 +1158,7 @@
E02BB507126CA50F006E46A2 /* Icon-Small-50.png in Resources */,
E02BB508126CA50F006E46A2 /* Icon-72.png in Resources */,
E02BB763126CC1E0006E46A2 /* iTunesArtwork in Resources */,
6D466D7C1353D846005D6364 /* bait.mp4 in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
3 changes: 2 additions & 1 deletion Classes/HelloWorldLayer.h
Expand Up @@ -9,9 +9,10 @@

// When you import this file, you import all the cocos2d classes
#import "cocos2d.h"
#import "VideoPlayer.h"

// HelloWorldLayer
@interface HelloWorldLayer : CCLayer
@interface HelloWorldLayer : CCLayer <VideoPlayerDelegate>
{
}

Expand Down
36 changes: 27 additions & 9 deletions Classes/HelloWorldLayer.m
Expand Up @@ -9,6 +9,7 @@

// Import the interfaces
#import "HelloWorldLayer.h"
#import "VideoPlayer.h"

// HelloWorldLayer implementation
@implementation HelloWorldLayer
Expand All @@ -35,21 +36,38 @@ -(id) init
// Apple recommends to re-assign "self" with the "super" return value
if( (self=[super init])) {

// create and initialize a Label
CCLabelTTF *label = [CCLabelTTF labelWithString:@"Hello World" fontName:@"Marker Felt" fontSize:64];

// ask director the the window size
CGSize size = [[CCDirector sharedDirector] winSize];
// Add button
CCLabelTTF *label = [CCLabelTTF labelWithString:@"Play video" fontName:@"Marker Felt" fontSize:64];
CCMenuItemLabel *labelItem = [CCMenuItemLabel itemWithLabel:label
target: self
selector: @selector(testVideoPlayer)];

CCMenu *menu = [CCMenu menuWithItems: labelItem, nil];
[menu alignItemsHorizontally];
[self addChild: menu];

// position the label on the center of the screen
label.position = ccp( size.width /2 , size.height/2 );

// add the label as a child to this Layer
[self addChild: label];
// Init Video Player
[VideoPlayer setDelegate: self];
}
return self;
}

- (void) testVideoPlayer
{
[VideoPlayer playMovieWithFile:@"bait.mp4"];
}

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

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

// on "dealloc" you need to release all your retained objects
- (void) dealloc
{
Expand Down
6 changes: 6 additions & 0 deletions Classes/RootViewController.m
Expand Up @@ -15,6 +15,7 @@

#import "RootViewController.h"
#import "GameConfig.h"
#import "VideoPlayer.h"

@implementation RootViewController

Expand Down Expand Up @@ -125,6 +126,11 @@ -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrien
rect.size.height *= contentScaleFactor;
}
glView.frame = rect;


// update video player orienation
UIDeviceOrientation deviceOrientation = (UIDeviceOrientation)toInterfaceOrientation;
[VideoPlayer updateOrientationWithOrientation: deviceOrientation ];
}
#endif // GAME_AUTOROTATION == kGameAutorotationUIViewController

Expand Down
Binary file added Resources/bait.mp4
Binary file not shown.

0 comments on commit 4090d0e

Please sign in to comment.