diff --git a/CCVideoPlayer.xcodeproj/project.pbxproj b/CCVideoPlayer.xcodeproj/project.pbxproj index e131176..5a227db 100755 --- a/CCVideoPlayer.xcodeproj/project.pbxproj +++ b/CCVideoPlayer.xcodeproj/project.pbxproj @@ -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 */; }; @@ -313,6 +314,7 @@ 6D466C981353D069005D6364 /* VideoPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoPlayer.h; sourceTree = ""; }; 6D466C991353D069005D6364 /* VideoPlayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VideoPlayer.m; sourceTree = ""; }; 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 = ""; }; 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; }; @@ -672,6 +674,7 @@ 50F414EB1069373D002A0D5E /* Resources */ = { isa = PBXGroup; children = ( + 6D466D7B1353D846005D6364 /* bait.mp4 */, E02BB762126CC1E0006E46A2 /* iTunesArtwork */, E02BB4FE126CA50F006E46A2 /* Icon@2x.png */, E02BB4FF126CA50F006E46A2 /* Icon-Small@2x.png */, @@ -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; }; diff --git a/Classes/HelloWorldLayer.h b/Classes/HelloWorldLayer.h index 49a0ffc..e70ec35 100644 --- a/Classes/HelloWorldLayer.h +++ b/Classes/HelloWorldLayer.h @@ -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 { } diff --git a/Classes/HelloWorldLayer.m b/Classes/HelloWorldLayer.m index 3fb8789..3d623d5 100755 --- a/Classes/HelloWorldLayer.m +++ b/Classes/HelloWorldLayer.m @@ -9,6 +9,7 @@ // Import the interfaces #import "HelloWorldLayer.h" +#import "VideoPlayer.h" // HelloWorldLayer implementation @implementation HelloWorldLayer @@ -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 { diff --git a/Classes/RootViewController.m b/Classes/RootViewController.m index ec5cdcd..932aac5 100644 --- a/Classes/RootViewController.m +++ b/Classes/RootViewController.m @@ -15,6 +15,7 @@ #import "RootViewController.h" #import "GameConfig.h" +#import "VideoPlayer.h" @implementation RootViewController @@ -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 diff --git a/Resources/bait.mp4 b/Resources/bait.mp4 new file mode 100644 index 0000000..738145d Binary files /dev/null and b/Resources/bait.mp4 differ