Skip to content

Commit

Permalink
Use CCEventDelegate instead of wideKeyDelegate. Fixes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
psineur committed Apr 13, 2011
1 parent 3a0249d commit da28d9c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Classes/VideoPlayer/Mac/MyMovieView.h
Expand Up @@ -9,10 +9,10 @@

#import <Cocoa/Cocoa.h>
#import "QTKit/QTKit.h"
#import "CCEventDispatcher.h"

@interface MyMovieView : QTMovieView {

}
@interface MyMovieView : QTMovieView <CCKeyboardEventDelegate>
{}

@end

Expand Down
9 changes: 8 additions & 1 deletion Classes/VideoPlayer/Mac/MyMovieView.m
Expand Up @@ -35,11 +35,18 @@ - (void) mouseDown:(NSEvent *)theEvent

- (void) keyDown:(NSEvent *)theEvent
{

if ( ![theEvent isARepeat] )
[VideoPlayer cancelPlaying];
}

-(BOOL) ccKeyDown:(NSEvent*)event
{
if ( ![event isARepeat] )
[VideoPlayer cancelPlaying];

return NO;
}

- (void)viewDidMoveToWindow
{
NSWindow *window = [self window];
Expand Down
6 changes: 3 additions & 3 deletions Classes/VideoPlayer/Mac/VideoPlayerImplMac.m
Expand Up @@ -70,8 +70,8 @@ - (void)playMovieAtURL:(NSURL*)theURL attachedInView: (NSView *) targetView
[[self.videoViewController view] setFrame: [windowContentView bounds]];

// Start handling events on movie view
//[[windowContentView window] makeFirstResponder: [self.videoViewController view] ];
[MacGLView setWideKeyboardDelegate: [self.videoViewController view]];
[[CCEventDispatcher sharedDispatcher] addKeyboardDelegate: (MyMovieView *)[self.videoViewController view]
priority: NSIntegerMin ];

// Register for end notification
[[NSNotificationCenter defaultCenter] addObserver: self
Expand Down Expand Up @@ -113,7 +113,7 @@ -(void)movieFinishedCallback:(NSNotification*)aNotification
[[self retainedView] setFrame:[windowContentView bounds]];

// Stop handling events on movie view
[MacGLView setWideKeyboardDelegate: nil];
[[CCEventDispatcher sharedDispatcher] removeKeyboardDelegate: self];
[[windowContentView window] makeFirstResponder: self.retainedView ];


Expand Down
4 changes: 0 additions & 4 deletions README.md
Expand Up @@ -25,10 +25,6 @@ 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 )

Also it needs a little bit changed MacGLView - it was modified in commit with SHA: 3b5339070dadab02e9b7381c2becebbd616ade31

Without modified MacGLView VideoPlayer will compile with warnings and crash at starting playback on a Mac ( Probably it's possible to fix this, so it will work without modifying MacGLView, but cancelling video by pressing a key will not work. Issue #4 )

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

To play videofile foo.mp4 simply use:
Expand Down

0 comments on commit da28d9c

Please sign in to comment.