Changeset 1286
- Timestamp:
- 06/22/10 18:27:49 (2 years ago)
- Location:
- trunk/CommonMediaPlayer
- Files:
-
- 9 modified
- 2 copied
-
Classes/CMPDefines.h (modified) (1 diff)
-
Classes/CMPPlayerManager.m (modified) (3 diffs)
-
CommonMediaPlayer.xcodeproj/project.pbxproj (modified) (5 diffs)
-
General Actions/CMPOverlayAction.h (copied) (copied from trunk/CommonMediaPlayer/Media Players/DVD Framework/CMPDVDWindowCreationAction.h) (5 diffs)
-
General Actions/CMPOverlayAction.m (copied) (copied from trunk/CommonMediaPlayer/Media Players/DVD Framework/CMPDVDWindowCreationAction.m) (25 diffs)
-
Media Players/DVD Framework/CMPDVDPlayer.h (modified) (3 diffs)
-
Media Players/DVD Framework/CMPDVDPlayer.m (modified) (7 diffs)
-
Media Players/DVD Framework/CMPDVDPlayerController.h (modified) (3 diffs)
-
Media Players/DVD Framework/CMPDVDPlayerController.m (modified) (13 diffs)
-
Media Players/DVD Framework/CMPDVDWindowCreationAction.h (modified) (1 diff)
-
Media Players/DVD Framework/CMPDVDWindowCreationAction.m (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/CommonMediaPlayer/Classes/CMPDefines.h
r1265 r1286 22 22 //Note, only defines should ever be in this file! 23 23 24 #define CMPVersion 9//Full Version Number24 #define CMPVersion 10 //Full Version Number 25 25 #define CMPAPIVersion 1 //API version 1 -
trunk/CommonMediaPlayer/Classes/CMPPlayerManager.m
r1262 r1286 36 36 + (CMPPlayerManager *)sharedPlayerManager 37 37 { 38 CMPPlayerManager *shared = nil;38 static CMPPlayerManager *shared = nil; 39 39 if(shared == nil) 40 40 shared = [[CMPPlayerManager alloc] init]; … … 174 174 { 175 175 //NSLog(@"Using Player"); 176 [player retain];177 176 break; 178 177 } … … 206 205 //XXX Prefs 207 206 id <CMPPlayerController> controller = [[(Class)[goodControllers anyObject] alloc] initWithScene:scene player:player]; 207 [goodControllers release]; 208 208 return [controller autorelease]; 209 209 } -
trunk/CommonMediaPlayer/CommonMediaPlayer.xcodeproj/project.pbxproj
r1266 r1286 52 52 F50CCE911119DECA00213966 /* CMPDVDPlayerController.h in Headers */ = {isa = PBXBuildFile; fileRef = F50CCE8F1119DECA00213966 /* CMPDVDPlayerController.h */; settings = {ATTRIBUTES = (); }; }; 53 53 F50CCE921119DECA00213966 /* CMPDVDPlayerController.m in Sources */ = {isa = PBXBuildFile; fileRef = F50CCE901119DECA00213966 /* CMPDVDPlayerController.m */; }; 54 F512FF4811D170D40062B86E /* CMPOverlayAction.h in Headers */ = {isa = PBXBuildFile; fileRef = F512FF4611D170D40062B86E /* CMPOverlayAction.h */; }; 55 F512FF4911D170D40062B86E /* CMPOverlayAction.m in Sources */ = {isa = PBXBuildFile; fileRef = F512FF4711D170D40062B86E /* CMPOverlayAction.m */; }; 54 56 F531CAE3111E2EF9005DF910 /* CMPLeopardDVDPlayer.h in Headers */ = {isa = PBXBuildFile; fileRef = F531CAE1111E2EF9005DF910 /* CMPLeopardDVDPlayer.h */; }; 55 57 F531CAE4111E2EF9005DF910 /* CMPLeopardDVDPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = F531CAE2111E2EF9005DF910 /* CMPLeopardDVDPlayer.m */; }; … … 123 125 F50CCE8F1119DECA00213966 /* CMPDVDPlayerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CMPDVDPlayerController.h; sourceTree = "<group>"; }; 124 126 F50CCE901119DECA00213966 /* CMPDVDPlayerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CMPDVDPlayerController.m; sourceTree = "<group>"; }; 127 F512FF4611D170D40062B86E /* CMPOverlayAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CMPOverlayAction.h; sourceTree = "<group>"; }; 128 F512FF4711D170D40062B86E /* CMPOverlayAction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CMPOverlayAction.m; sourceTree = "<group>"; }; 125 129 F531CAE1111E2EF9005DF910 /* CMPLeopardDVDPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CMPLeopardDVDPlayer.h; sourceTree = "<group>"; }; 126 130 F531CAE2111E2EF9005DF910 /* CMPLeopardDVDPlayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CMPLeopardDVDPlayer.m; sourceTree = "<group>"; }; … … 325 329 F5001CBD1120939D001B52FE /* CMPOverlayModeAction.h */, 326 330 F5001CBE1120939D001B52FE /* CMPOverlayModeAction.m */, 331 F512FF4611D170D40062B86E /* CMPOverlayAction.h */, 332 F512FF4711D170D40062B86E /* CMPOverlayAction.m */, 327 333 ); 328 334 path = "General Actions"; … … 374 380 87C75D8411BB51AE00D53B37 /* CMPMPPlayer.h in Headers */, 375 381 87C75D8611BB51AE00D53B37 /* CMPMPPlayerController.h in Headers */, 382 F512FF4811D170D40062B86E /* CMPOverlayAction.h in Headers */, 376 383 ); 377 384 runOnlyForDeploymentPostprocessing = 0; … … 489 496 87C75D8511BB51AE00D53B37 /* CMPMPPlayer.m in Sources */, 490 497 87C75D8711BB51AE00D53B37 /* CMPMPPlayerController.m in Sources */, 498 F512FF4911D170D40062B86E /* CMPOverlayAction.m in Sources */, 491 499 ); 492 500 runOnlyForDeploymentPostprocessing = 0; -
trunk/CommonMediaPlayer/General Actions/CMPOverlayAction.h
r1179 r1286 1 1 /* 2 * CMP DVDWindowCreationAction.h2 * CMPOverlayAction.h 3 3 * CommonMediaPlayer 4 4 * 5 * Created by Graham Booker on Feb.2 20105 * Created by Graham Booker on Jun. 22 2010 6 6 * Copyright 2010 Common Media Player 7 7 * All rights reserved. … … 22 22 #import "CMPActionController.h" 23 23 24 @class CMPScreenReleaseAction, CMP DVDPlayer, CMPDVDPlayerPlayHeadView, CMPDVDSelectionView;24 @class CMPScreenReleaseAction, CMPPlayerPlayHeadView, CMPSelectionView; 25 25 26 26 typedef enum { 27 CMP DVDOverlayUpperLeft,28 CMP DVDOverlayUpperRight,29 CMP DVDOverlayLowerLeft,30 CMP DVDOverlayLowerRight,31 } CMP DVDOverlayPosition;27 CMPOverlayUpperLeft, 28 CMPOverlayUpperRight, 29 CMPOverlayLowerLeft, 30 CMPOverlayLowerRight, 31 } CMPOverlayPosition; 32 32 33 @interface CMP DVDOverlayWindow : NSWindow33 @interface CMPOverlayWindow : NSWindow 34 34 { 35 35 NSRect screenRect; … … 45 45 @end 46 46 47 @interface CMP DVDTextView : CMPDVDOverlayWindow47 @interface CMPTextView : CMPOverlayWindow 48 48 { 49 CMP DVDOverlayPositionposition;49 CMPOverlayPosition position; 50 50 NSTextField *textField; 51 51 } … … 55 55 @end 56 56 57 @interface CMP DVDPlayerPlayHead : CMPDVDOverlayWindow {57 @interface CMPPlayerPlayHead : CMPOverlayWindow { 58 58 NSTextField *elapsedField; 59 59 NSTextField *durationField; 60 CMPDVDPlayer *player; 61 CMPDVDPlayerPlayHeadView *playView; 62 NSTimer *updateTimer; 60 CMPPlayerPlayHeadView *playView; 63 61 } 64 - (void) setPlayer:(CMPDVDPlayer *)player;62 - (void)updateDisplayWithElapsed:(int)elapsedTime duration:(int)durationTime; 65 63 66 64 @end 67 65 68 @interface CMP DVDBlurredMenu : CMPDVDOverlayWindow66 @interface CMPBlurredMenu : CMPOverlayWindow 69 67 { 70 68 NSArray *menuItems; 71 CMP DVDSelectionView *selectionView;69 CMPSelectionView *selectionView; 72 70 NSImageView *imageView; 73 71 int selectedItem; … … 79 77 @end 80 78 79 extern NSString *CMPOverlayActionWindowKey; 81 80 82 @interface CMPDVDWindowCreationAction : NSObject <CMPActionController>{ 83 CMPScreenReleaseAction *screenRelease; 84 NSWindow *dvdWindow; 81 @interface CMPOverlayAction : NSObject <CMPActionController>{ 82 NSWindow *window; 85 83 NSMutableArray *overlays; 86 84 } 87 85 88 - (void)setWindowAlpha:(float)alpha; 89 - (CMPDVDOverlayWindow *)addBlackShieldWindow; 90 - (CMPDVDTextView *)addTextOverlayInPosition:(CMPDVDOverlayPosition)position; 91 - (CMPDVDPlayerPlayHead *)addPlayheadOverlay; 92 - (CMPDVDBlurredMenu *)addBlurredMenuOverlayWithItems:(NSArray *)items; 93 - (void)closeOverlay:(CMPDVDOverlayWindow *)overlay; 94 - (void)closeOverlay:(CMPDVDOverlayWindow *)overlay withFade:(NSNumber *)fadeTimeNumber; 86 - (CMPOverlayWindow *)addBlackShieldWindow; 87 - (CMPTextView *)addTextOverlayInPosition:(CMPOverlayPosition)position; 88 - (CMPPlayerPlayHead *)addPlayheadOverlay; 89 - (CMPBlurredMenu *)addBlurredMenuOverlayWithItems:(NSArray *)items; 90 - (void)closeOverlay:(CMPOverlayWindow *)overlay; 91 - (void)closeOverlay:(CMPOverlayWindow *)overlay withFade:(NSNumber *)fadeTimeNumber; 95 92 - (void)closeAllOverlays; 96 93 - (void)closeAllOverlaysWithFadeTime:(float)fadeTime; -
trunk/CommonMediaPlayer/General Actions/CMPOverlayAction.m
r1179 r1286 1 1 /* 2 * CMP DVDWindowCreationAction.m2 * CMPOverlayAction.m 3 3 * CommonMediaPlayer 4 4 * 5 * Created by Graham Booker on Feb.2 20105 * Created by Graham Booker on Jun. 22 2010 6 6 * Copyright 2010 Common Media Player 7 7 * All rights reserved. … … 20 20 */ 21 21 22 #import <DVDPlayback/DVDPlayback.h> 23 24 #import "CMPDVDWindowCreationAction.h" 25 #import "CMPScreenReleaseAction.h" 22 #import "CMPOverlayAction.h" 26 23 #import "CoreGraphicsServices.h" 27 24 #import "CMPOverlayModeAction.h" 28 25 #import "CMPATVVersion.h" 29 #import "CMPDVDPlayer.h"30 26 31 27 #define ANIMATE_TIME_INTERVAL 0.02 32 28 33 @implementation CMP DVDOverlayWindow29 @implementation CMPOverlayWindow 34 30 35 31 - (id)initWithContentRect:(NSRect)contentRect overWindow:(int)windowID … … 127 123 @end 128 124 129 @implementation CMP DVDTextView130 131 - (id)initWithContentRect:(NSRect)contentRect position:(CMP DVDOverlayPosition)aPosition overWindow:(int)windowID125 @implementation CMPTextView 126 127 - (id)initWithContentRect:(NSRect)contentRect position:(CMPOverlayPosition)aPosition overWindow:(int)windowID 132 128 { 133 129 self = [super initWithContentRect:contentRect overWindow:windowID]; … … 164 160 //NSLog(@"Size is %fx%f", frameRect.size.width, frameRect.size.height); 165 161 float distanceFromEdge = screenRect.size.height / 15; 166 if(position == CMP DVDOverlayUpperLeft || position == CMPDVDOverlayUpperRight)162 if(position == CMPOverlayUpperLeft || position == CMPOverlayUpperRight) 167 163 frameRect.origin.y = screenRect.size.height - frameRect.size.height - distanceFromEdge; 168 164 else 169 165 frameRect.origin.y = distanceFromEdge; 170 if(position == CMP DVDOverlayUpperRight || position == CMPDVDOverlayLowerRight)166 if(position == CMPOverlayUpperRight || position == CMPOverlayLowerRight) 171 167 frameRect.origin.x = screenRect.size.width - frameRect.size.width - distanceFromEdge; 172 168 else … … 178 174 179 175 180 @interface CMP DVDPlayerPlayHeadView : NSView176 @interface CMPPlayerPlayHeadView : NSView 181 177 { 182 178 float playHeadLocation; … … 186 182 @end 187 183 188 @implementation CMP DVDPlayerPlayHeadView184 @implementation CMPPlayerPlayHeadView 189 185 190 186 - (void)drawRect:(NSRect)rect … … 225 221 226 222 227 @implementation CMP DVDPlayerPlayHead223 @implementation CMPPlayerPlayHead 228 224 229 225 - (id)initWithContentRect:(NSRect)contentRect overWindow:(int)windowID … … 261 257 [durationField setSelectable:NO]; 262 258 263 playView = [[CMP DVDPlayerPlayHeadView alloc] initWithFrame:NSMakeRect(textWidth + textBuffer, textHeight / 5, myWidth-textWidth*2-textBuffer*2, textHeight * 3 /5)];259 playView = [[CMPPlayerPlayHeadView alloc] initWithFrame:NSMakeRect(textWidth + textBuffer, textHeight / 5, myWidth-textWidth*2-textBuffer*2, textHeight * 3 /5)]; 264 260 [[self contentView] addSubview:playView]; 265 261 [self setFrame:NSMakeRect(contentRect.size.width * 5 / 64, textHeight*2, myWidth, textHeight) display:NO]; … … 271 267 { 272 268 [durationField release]; 273 [player release];274 269 [playView release]; 275 [updateTimer invalidate];276 270 [super dealloc]; 277 271 } 278 272 279 NSString *timeStringForTime(int time)273 static NSString *timeStringForTime(int time) 280 274 { 281 275 int seconds = time % 60; … … 291 285 } 292 286 293 - (void)close 294 { 295 [updateTimer invalidate]; 296 updateTimer = nil; 297 [super close]; 298 } 299 300 - (void)updateDisplay 301 { 302 int elapsedTime = [player titleElapsedTime]; 303 int durationTime = [player titleDurationTime]; 304 287 - (void)updateDisplayWithElapsed:(int)elapsedTime duration:(int)durationTime 288 { 305 289 [elapsedField setStringValue:timeStringForTime(elapsedTime)]; 306 290 [durationField setStringValue:timeStringForTime(durationTime)]; … … 308 292 } 309 293 310 - (void)setPlayer:(CMPDVDPlayer *)aPlayer 311 { 312 [player release]; 313 player = [aPlayer retain]; 314 315 [self updateDisplay]; 316 317 [updateTimer invalidate]; 318 updateTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateDisplay) userInfo:nil repeats:YES]; 319 } 320 321 @end 322 323 @interface CMPDVDSelectionView : NSView 294 @end 295 296 @interface CMPSelectionView : NSView 324 297 { 325 298 NSTimer *moveTimer; … … 329 302 @end 330 303 331 @implementation CMP DVDSelectionView332 333 #define CMP DVDSelectionViewMoveTime 0.2304 @implementation CMPSelectionView 305 306 #define CMPSelectionViewMoveTime 0.2 334 307 335 308 - (id)initWithFrame:(NSRect)frame … … 351 324 } 352 325 353 void Interpolate (void* info, float const* inData, float* outData)326 static void Interpolate (void* info, float const* inData, float* outData) 354 327 { 355 328 float value = sin(M_PI_2 * inData[0])/2; … … 412 385 double interval = -[startTime timeIntervalSinceNow]; 413 386 float currentY; 414 if(interval > CMP DVDSelectionViewMoveTime)387 if(interval > CMPSelectionViewMoveTime) 415 388 { 416 389 currentY = finalY; … … 419 392 } 420 393 else 421 currentY = initialY + (finalY - initialY) * interval / CMP DVDSelectionViewMoveTime;394 currentY = initialY + (finalY - initialY) * interval / CMPSelectionViewMoveTime; 422 395 NSRect frame = [self frame]; 423 396 NSRect newFrame = frame; … … 442 415 443 416 444 @implementation CMP DVDBlurredMenu417 @implementation CMPBlurredMenu 445 418 446 419 - (id)initWithItems:(NSArray*)anItems contentRect:(NSRect)contentRect overWindow:(int)windowID … … 463 436 float inset = contentRect.size.height * 5 / 144; 464 437 float borderSize = contentRect.size.height / 72; 465 selectionView = [[CMP DVDSelectionView alloc] initWithFrame:NSMakeRect(left, bottom + itemHeight * (itemCount-1) - borderSize, itemWidth, itemHeight+borderSize*2)];438 selectionView = [[CMPSelectionView alloc] initWithFrame:NSMakeRect(left, bottom + itemHeight * (itemCount-1) - borderSize, itemWidth, itemHeight+borderSize*2)]; 466 439 [[self contentView] addSubview:selectionView]; 467 440 … … 595 568 @end 596 569 597 570 NSString *CMPOverlayActionWindowKey = @"window"; 598 571 599 572 @interface BRDisplayManager (compat) … … 601 574 @end 602 575 603 @implementation CMP DVDWindowCreationAction576 @implementation CMPOverlayAction 604 577 605 578 - (id)initWithController:(id <CMPPlayerController>)controller andSettings:(NSDictionary *)settings 606 579 { 580 NSWindow *win = [settings objectForKey:CMPOverlayActionWindowKey]; 581 if(win == nil) 582 return [self autorelease]; 583 607 584 self = [super init]; 608 585 if(!self) 609 586 return self; 610 587 611 // screenRelease = [[CMPOverlayModeAction alloc] initWithController:controller andSettings:settings]; 612 screenRelease = [[CMPScreenReleaseAction alloc] initWithController:controller andSettings:settings]; 588 window = [win retain]; 613 589 overlays = [[NSMutableArray alloc] init]; 614 590 … … 618 594 - (void) dealloc 619 595 { 620 [screenRelease release]; 621 [dvdWindow release]; 596 [window release]; 622 597 [overlays release]; 623 598 [super dealloc]; 624 599 } 625 600 626 static int CreateEmptyWindow(CGRect myFrame)627 {628 //NSLog(@"createEmptyWindow");629 CGSRegion frameRgn;630 CGSRegion emptyRgn;631 int window;632 char something[100];633 634 635 CGSNewRegionWithRect(&myFrame, &frameRgn);636 CGSNewEmptyRegion(&emptyRgn);637 638 int conn = CGSMainConnectionID();639 640 //NSLog(@"connection id: %i", conn);641 642 CGSNewWindowWithOpaqueShape(conn, 2, 0, 0, frameRgn, emptyRgn, 0, &something,643 32, &window);644 645 646 CGSSetWindowOpacity(conn, window, 1);647 648 649 CGSReleaseRegion(emptyRgn);650 CGSReleaseRegion(frameRgn);651 652 return window;653 }654 655 601 - (BOOL)openWithError:(NSError **)error 656 602 { 657 BOOL success = [screenRelease openWithError:error]; 658 659 if(!success) 660 { 661 NSLog(@"Release failed"); 662 return NO; 663 } 664 665 //NSLog(@"createDvdWindow"); 666 CGDirectDisplayID display = [(BRDisplayManager *)[BRDisplayManager sharedInstance] display]; 667 CGRect frame = CGDisplayBounds(display); 668 frame.size.width = CGDisplayPixelsWide(display); 669 frame.size.height = CGDisplayPixelsHigh(display); 670 671 if(frame.size.width < 0.0f) 672 frame.size.width = ABS(frame.size.width); 673 if(frame.size.height < 0.0f) 674 frame.size.height = ABS(frame.size.height); 675 676 NSRect frameRect = NSMakeRect(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); 677 NSApplicationLoad(); 678 dvdWindow = [[NSWindow alloc] initWithContentRect:frameRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; 679 [dvdWindow setReleasedWhenClosed:NO]; 680 [dvdWindow setBackgroundColor:[NSColor blackColor]]; 681 int dvdWindowID = [dvdWindow windowNumber]; 682 //dvdWindowID = CreateEmptyWindow(frame); 683 CGSSetWindowLevel(_CGSDefaultConnection(), dvdWindowID, CGShieldingWindowLevel()+1); 684 685 CGSOrderWindow(_CGSDefaultConnection(), dvdWindowID, kCGSOrderAbove, 0); 686 687 CGContextRef ctx = (CGContextRef)CGWindowContextCreate(_CGSDefaultConnection(), dvdWindowID, NULL); 688 689 CGContextClear(ctx); 690 CGContextFlush(ctx); 691 CGContextRelease(ctx); 692 693 OSStatus setWindowErr = DVDSetVideoWindowID(dvdWindowID); 694 if(setWindowErr != noErr) 695 NSLog(@"Set DVD Window error is %d", setWindowErr); 696 OSStatus displayErr = DVDSetVideoDisplay([[BRDisplayManager sharedInstance] display]); 697 if(displayErr != noErr) 698 NSLog(@"Set DVD Video error is %d", displayErr); 699 700 return setWindowErr == noErr && displayErr == noErr; 701 } 702 703 - (void)setWindowAlpha:(float)alpha 704 { 705 [dvdWindow setAlphaValue:alpha]; 706 } 707 708 - (CMPDVDOverlayWindow *)addBlackShieldWindow 709 { 710 CMPDVDOverlayWindow *ret = [[CMPDVDOverlayWindow alloc] initWithContentRect:[dvdWindow frame] overWindow:[dvdWindow windowNumber]]; 603 return YES; 604 } 605 606 - (CMPOverlayWindow *)addBlackShieldWindow 607 { 608 CMPOverlayWindow *ret = [[CMPOverlayWindow alloc] initWithContentRect:[window frame] overWindow:[window windowNumber]]; 711 609 712 610 [overlays addObject:ret]; … … 716 614 } 717 615 718 - (CMP DVDTextView *)addTextOverlayInPosition:(CMPDVDOverlayPosition)position719 { 720 CMP DVDTextView *ret = [[CMPDVDTextView alloc] initWithContentRect:[dvdWindow frame] position:position overWindow:[dvdWindow windowNumber]];616 - (CMPTextView *)addTextOverlayInPosition:(CMPOverlayPosition)position 617 { 618 CMPTextView *ret = [[CMPTextView alloc] initWithContentRect:[window frame] position:position overWindow:[window windowNumber]]; 721 619 722 620 [overlays addObject:ret]; … … 726 624 } 727 625 728 - (CMP DVDPlayerPlayHead *)addPlayheadOverlay729 { 730 CMP DVDPlayerPlayHead *ret = [[CMPDVDPlayerPlayHead alloc] initWithContentRect:[dvdWindow frame] overWindow:[dvdWindow windowNumber]];626 - (CMPPlayerPlayHead *)addPlayheadOverlay 627 { 628 CMPPlayerPlayHead *ret = [[CMPPlayerPlayHead alloc] initWithContentRect:[window frame] overWindow:[window windowNumber]]; 731 629 732 630 [overlays addObject:ret]; … … 736 634 } 737 635 738 - (CMP DVDBlurredMenu *)addBlurredMenuOverlayWithItems:(NSArray *)items739 { 740 CMP DVDBlurredMenu *ret = [[CMPDVDBlurredMenu alloc] initWithItems:items contentRect:[dvdWindow frame] overWindow:[dvdWindow windowNumber]];636 - (CMPBlurredMenu *)addBlurredMenuOverlayWithItems:(NSArray *)items 637 { 638 CMPBlurredMenu *ret = [[CMPBlurredMenu alloc] initWithItems:items contentRect:[window frame] overWindow:[window windowNumber]]; 741 639 742 640 [overlays addObject:ret]; … … 746 644 } 747 645 748 - (void)closeOverlay:(CMP DVDOverlayWindow *)overlay646 - (void)closeOverlay:(CMPOverlayWindow *)overlay 749 647 { 750 648 [self closeOverlay:overlay withFade:[NSNumber numberWithFloat:0]]; 751 649 } 752 650 753 - (void)closeOverlay:(CMP DVDOverlayWindow *)overlay withFade:(NSNumber *)fadeTimeNumber651 - (void)closeOverlay:(CMPOverlayWindow *)overlay withFade:(NSNumber *)fadeTimeNumber 754 652 { 755 653 [overlay closeWithFadeTime:fadeTimeNumber]; … … 774 672 - (BOOL)closeWithError:(NSError **)error 775 673 { 776 // int conn = _CGSDefaultConnection();777 // NSLog(@"conn: %i dvdWindow: %i", conn, dvdWindowID);778 // OSStatus theErr = CGSReleaseWindow(conn, dvdWindowID);779 // NSLog(@"CGSReleaseWindow: %d", theErr);780 674 [self closeAllOverlays]; 781 [dvdWindow close]; 782 783 return [screenRelease closeWithError:error]; 784 } 785 @end 675 [window close]; 676 return YES; 677 } 678 @end -
trunk/CommonMediaPlayer/Media Players/DVD Framework/CMPDVDPlayer.h
r1208 r1286 51 51 } CMPDVDZoomLevel; 52 52 53 @class CMPDVDPlayerController, CMPDVDFrameworkLoadAction ;53 @class CMPDVDPlayerController, CMPDVDFrameworkLoadAction, CMPPlayerPlayHead; 54 54 55 55 @interface CMPDVDPlayer : NSObject <CMPPlayer>{ … … 65 65 CMPDVDZoomLevel zoomLevel; 66 66 BOOL useStopTimer; 67 CMPPlayerPlayHead *playhead; 67 68 } 68 69 … … 104 105 - (void)setZoomLevel:(CMPDVDZoomLevel)level; 105 106 - (CMPDVDZoomLevel)zoomLevel; 107 - (void)setPlayhead:(CMPPlayerPlayHead *)playhead; 106 108 + (BOOL)isVolume:(NSString *)theVolume; 107 109 + (BOOL)isImage:(NSString *)theVolume; -
trunk/CommonMediaPlayer/Media Players/DVD Framework/CMPDVDPlayer.m
r1211 r1286 24 24 #import "CMPDVDFrameworkLoadAction.h" 25 25 #import "CMPDVDPlayerController.h" 26 #import "CMPOverlayAction.h" 26 27 #import <AudioUnit/AudioUnit.h> 27 28 … … 77 78 [frameworkLoad release]; 78 79 [stopTimer invalidate]; 80 [playhead release]; 79 81 [super dealloc]; 80 82 } … … 707 709 } 708 710 711 - (void)setPlayhead:(CMPPlayerPlayHead *)aPlayhead 712 { 713 [playhead release]; 714 playhead = [aPlayhead retain]; 715 [playhead updateDisplayWithElapsed:currentElapsedTime duration:titleDuration]; 716 } 717 709 718 static BOOL pauseOnPlay = NO; 710 719 - (void)initiatePlaybackWithResume:(BOOL *)resume; … … 759 768 DVDCloseMediaFile(); 760 769 DVDCloseMediaVolume(); 761 DVDSetVideoDisplay(kCGNullDirectDisplay); 770 //Seems to crash SL 771 //DVDSetVideoDisplay(kCGNullDirectDisplay); 762 772 DVDDispose(); 763 773 } … … 910 920 } 911 921 922 - (void)updatePlayhead 923 { 924 [playhead updateDisplayWithElapsed:currentElapsedTime duration:titleDuration]; 925 } 926 912 927 - (void)titleTimeChanged 913 928 { … … 922 937 if(time != 0) 923 938 currentElapsedTime = time; 939 if(playhead != nil) 940 [self performSelectorOnMainThread:@selector(updatePlayhead) withObject:nil waitUntilDone:NO]; 924 941 } 925 942 … … 1094 1111 return NO; 1095 1112 } 1113 DVDSetTimeEventRate(100); 1096 1114 return result == noErr; 1097 1115 } -
trunk/CommonMediaPlayer/Media Players/DVD Framework/CMPDVDPlayerController.h
r1179 r1286 22 22 #import "CMPPlayerController.h" 23 23 24 @class CMPDVDPlayer, CMPDVDWindowCreationAction, CMP DVDTextView, CMPDVDPlayerPlayHead, CMPDVDBlurredMenu;24 @class CMPDVDPlayer, CMPDVDWindowCreationAction, CMPTextView, CMPPlayerPlayHead, CMPBlurredMenu, CMPOverlayAction; 25 25 26 26 typedef enum { … … 37 37 id <CMPPlayerControllerDelegate> delegate; 38 38 CMPDVDWindowCreationAction *windowCreation; 39 CMPOverlayAction *overlay; 39 40 #ifdef PLAY_WITH_OVERLAY 40 41 BOOL blacked; … … 42 43 CMPDVDPlayerControllerOverlayMode overlayMode; 43 44 NSTimer *overlayDismiss; 44 CMP DVDTextView*statusOverlay;45 CMP DVDTextView*subtitlesOverlay;46 CMP DVDTextView*audioOverlay;47 CMP DVDTextView*chapterOverlay;48 CMP DVDTextView*zoomOverlay;49 CMP DVDPlayerPlayHead*playheadOverlay;50 CMP DVDBlurredMenu*blurredMenu;45 CMPTextView *statusOverlay; 46 CMPTextView *subtitlesOverlay; 47 CMPTextView *audioOverlay; 48 CMPTextView *chapterOverlay; 49 CMPTextView *zoomOverlay; 50 CMPPlayerPlayHead *playheadOverlay; 51 CMPBlurredMenu *blurredMenu; 51 52 } 52 53 -
trunk/CommonMediaPlayer/Media Players/DVD Framework/CMPDVDPlayerController.m
r1214 r1286 23 23 #import "CMPDVDPlayer.h" 24 24 #import "CMPDVDWindowCreationAction.h" 25 #import "CMPOverlayAction.h" 25 26 #import "CMPATVVersion.h" 26 27 #import "CoreGraphicsServices.h" … … 140 141 [delegate release]; 141 142 [windowCreation release]; 143 [overlay release]; 142 144 [overlayDismiss invalidate]; 143 145 [statusOverlay release]; … … 195 197 // [self setOpacity:0.0f]; 196 198 [windowCreation openWithError:nil]; 199 overlay = [[windowCreation overlayAction] retain]; 197 200 BOOL resume = NO; 198 CMP DVDOverlayWindow *shield = [windowCreationaddBlackShieldWindow];201 CMPOverlayWindow *shield = [overlay addBlackShieldWindow]; 199 202 [shield display]; 200 203 [player initiatePlaybackWithResume:&resume]; … … 202 205 { 203 206 [self showResumeOverlayWithDismiss:NO]; 204 [ windowCreationperformSelector:@selector(closeOverlay:) withObject:shield afterDelay:0.5];207 [overlay performSelector:@selector(closeOverlay:) withObject:shield afterDelay:0.5]; 205 208 } 206 209 else 207 [ windowCreationcloseOverlay:shield withFade:[NSNumber numberWithFloat:0]];210 [overlay closeOverlay:shield withFade:[NSNumber numberWithFloat:0]]; 208 211 } 209 212 … … 343 346 } 344 347 345 static void closeAndNilOverlay(CMP DVDWindowCreationAction *windowCreation, CMPDVDOverlayWindow * *overlay, NSNumber *fadeTime)346 { 347 CMP DVDOverlayWindow *actualOverlay = *overlay;348 [ windowCreation closeOverlay:actualOverlay withFade:fadeTime];348 static void closeAndNilOverlay(CMPOverlayAction *overlayAction, CMPOverlayWindow * *overlay, NSNumber *fadeTime) 349 { 350 CMPOverlayWindow *actualOverlay = *overlay; 351 [overlayAction closeOverlay:actualOverlay withFade:fadeTime]; 349 352 [actualOverlay release]; 350 353 *overlay = nil; … … 382 385 383 386 if(closeStatus) 384 closeAndNilOverlay( windowCreation, &statusOverlay, fadeTime);387 closeAndNilOverlay(overlay, &statusOverlay, fadeTime); 385 388 if(closeSubtitles) 386 closeAndNilOverlay( windowCreation, &subtitlesOverlay, fadeTime);389 closeAndNilOverlay(overlay, &subtitlesOverlay, fadeTime); 387 390 if(closeAudio) 388 closeAndNilOverlay( windowCreation, &audioOverlay, fadeTime);391 closeAndNilOverlay(overlay, &audioOverlay, fadeTime); 389 392 if(closeChapter) 390 closeAndNilOverlay( windowCreation, &chapterOverlay, fadeTime);393 closeAndNilOverlay(overlay, &chapterOverlay, fadeTime); 391 394 if(closeZoom) 392 closeAndNilOverlay(windowCreation, &zoomOverlay, fadeTime); 393 if(closePlayhead) 394 closeAndNilOverlay(windowCreation, &playheadOverlay, fadeTime); 395 closeAndNilOverlay(overlay, &zoomOverlay, fadeTime); 396 if(closePlayhead) { 397 [player setPlayhead:nil]; 398 closeAndNilOverlay(overlay, &playheadOverlay, fadeTime); 399 } 395 400 } 396 401 … … 412 417 if(playheadOverlay) 413 418 return; 414 playheadOverlay = [[windowCreation addPlayheadOverlay] retain]; 415 [playheadOverlay setPlayer:player]; 419 playheadOverlay = [[overlay addPlayheadOverlay] retain]; 416 420 [playheadOverlay displayWithFadeTime:0.1]; 421 [player setPlayhead:playheadOverlay]; 417 422 } 418 423 … … 423 428 424 429 if(!subtitlesOverlay) 425 subtitlesOverlay = [[ windowCreation addTextOverlayInPosition:CMPDVDOverlayUpperLeft] retain];430 subtitlesOverlay = [[overlay addTextOverlayInPosition:CMPOverlayUpperLeft] retain]; 426 431 [subtitlesOverlay setText:[player currentSubFormat]]; 427 432 [subtitlesOverlay displayWithFadeTime:0.25]; 428 433 if(!audioOverlay) 429 audioOverlay = [[ windowCreation addTextOverlayInPosition:CMPDVDOverlayUpperRight] retain];434 audioOverlay = [[overlay addTextOverlayInPosition:CMPOverlayUpperRight] retain]; 430 435 [audioOverlay setText:[player currentAudioFormat]]; 431 436 [audioOverlay displayWithFadeTime:0.25]; … … 445 450 446 451 if(!chapterOverlay) 447 chapterOverlay = [[ windowCreation addTextOverlayInPosition:CMPDVDOverlayUpperLeft] retain];452 chapterOverlay = [[overlay addTextOverlayInPosition:CMPOverlayUpperLeft] retain]; 448 453 [chapterOverlay setText:[self chapterString]]; 449 454 [chapterOverlay displayWithFadeTime:0.25]; … … 470 475 471 476 if(!zoomOverlay) 472 zoomOverlay = [[ windowCreation addTextOverlayInPosition:CMPDVDOverlayUpperRight] retain];477 zoomOverlay = [[overlay addTextOverlayInPosition:CMPOverlayUpperRight] retain]; 473 478 [zoomOverlay setText:[self zoomModeString]]; 474 479 [zoomOverlay displayWithFadeTime:0.25]; … … 504 509 505 510 if(!statusOverlay) 506 statusOverlay = [[ windowCreation addTextOverlayInPosition:CMPDVDOverlayUpperLeft] retain];511 statusOverlay = [[overlay addTextOverlayInPosition:CMPOverlayUpperLeft] retain]; 507 512 [statusOverlay setText:[self stringForPlayerState]]; 508 513 [statusOverlay displayWithFadeTime:0.25]; … … 518 523 519 524 //Catch any others 520 [ windowCreationcloseAllOverlaysWithFadeTime:fadeTime];525 [overlay closeAllOverlaysWithFadeTime:fadeTime]; 521 526 522 527 [overlayDismiss invalidate]; … … 528 533 if(dismiss) 529 534 [self dismissOverlaysWithFadeTime:0]; 530 blurredMenu = [[ windowCreationaddBlurredMenuOverlayWithItems:[NSArray arrayWithObjects:@"Resume Playback", @"Start From Beginning", @"Main Menu", nil]] retain];535 blurredMenu = [[overlay addBlurredMenuOverlayWithItems:[NSArray arrayWithObjects:@"Resume Playback", @"Start From Beginning", @"Main Menu", nil]] retain]; 531 536 [blurredMenu displayWithFadeTime:0.5]; 532 537 } -
trunk/CommonMediaPlayer/Media Players/DVD Framework/CMPDVDWindowCreationAction.h
r1179 r1286 22 22 #import "CMPActionController.h" 23 23 24 @class CMPScreenReleaseAction, CMPDVDPlayer, CMPDVDPlayerPlayHeadView, CMPDVDSelectionView; 25 26 typedef enum { 27 CMPDVDOverlayUpperLeft, 28 CMPDVDOverlayUpperRight, 29 CMPDVDOverlayLowerLeft, 30 CMPDVDOverlayLowerRight, 31 } CMPDVDOverlayPosition; 32 33 @interface CMPDVDOverlayWindow : NSWindow 34 { 35 NSRect screenRect; 36 int overWindowID; 37 float initialOpacity, finalOpacity, fadeTime; 38 NSTimer *opacityChangeTimer; 39 NSDate *opacityChangeStartTime; 40 } 41 42 - (void)display; 43 - (void)displayWithFadeTime:(float)fadeTime; 44 45 @end 46 47 @interface CMPDVDTextView : CMPDVDOverlayWindow 48 { 49 CMPDVDOverlayPosition position; 50 NSTextField *textField; 51 } 52 53 - (void)setText:(NSString *)text; 54 55 @end 56 57 @interface CMPDVDPlayerPlayHead : CMPDVDOverlayWindow { 58 NSTextField *elapsedField; 59 NSTextField *durationField; 60 CMPDVDPlayer *player; 61 CMPDVDPlayerPlayHeadView *playView; 62 NSTimer *updateTimer; 63 } 64 - (void)setPlayer:(CMPDVDPlayer *)player; 65 66 @end 67 68 @interface CMPDVDBlurredMenu : CMPDVDOverlayWindow 69 { 70 NSArray *menuItems; 71 CMPDVDSelectionView *selectionView; 72 NSImageView *imageView; 73 int selectedItem; 74 int itemHeight; 75 } 76 - (BOOL)previousItem; 77 - (BOOL)nextItem; 78 - (int)selectedItem; 79 @end 80 24 @class CMPScreenReleaseAction, CMPDVDPlayer, CMPOverlayAction; 81 25 82 26 @interface CMPDVDWindowCreationAction : NSObject <CMPActionController>{ 83 27 CMPScreenReleaseAction *screenRelease; 28 CMPOverlayAction *overlayAction; 84 29 NSWindow *dvdWindow; 85 NSMutableArray *overlays;86 30 } 87 31 88 32 - (void)setWindowAlpha:(float)alpha; 89 - (CMPDVDOverlayWindow *)addBlackShieldWindow; 90 - (CMPDVDTextView *)addTextOverlayInPosition:(CMPDVDOverlayPosition)position; 91 - (CMPDVDPlayerPlayHead *)addPlayheadOverlay; 92 - (CMPDVDBlurredMenu *)addBlurredMenuOverlayWithItems:(NSArray *)items; 93 - (void)closeOverlay:(CMPDVDOverlayWindow *)overlay; 94 - (void)closeOverlay:(CMPDVDOverlayWindow *)overlay withFade:(NSNumber *)fadeTimeNumber; 95 - (void)closeAllOverlays; 96 - (void)closeAllOverlaysWithFadeTime:(float)fadeTime; 97 33 - (CMPOverlayAction *)overlayAction; 98 34 @end -
trunk/CommonMediaPlayer/Media Players/DVD Framework/CMPDVDWindowCreationAction.m
r1179 r1286 28 28 #import "CMPATVVersion.h" 29 29 #import "CMPDVDPlayer.h" 30 31 #define ANIMATE_TIME_INTERVAL 0.02 32 33 @implementation CMPDVDOverlayWindow 34 35 - (id)initWithContentRect:(NSRect)contentRect overWindow:(int)windowID 36 { 37 self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; 38 if(!self) 39 return self; 40 41 screenRect = contentRect; 42 overWindowID = windowID; 43 [self setReleasedWhenClosed:NO]; 44 45 [self setBackgroundColor:[NSColor blackColor]]; 46 [[self contentView] setNeedsDisplay:YES]; 47 48 return self; 49 } 50 51 - (void) dealloc 52 { 53 [opacityChangeTimer invalidate]; 54 [opacityChangeStartTime release]; 55 [super dealloc]; 56 } 57 58 - (void)display 59 { 60 CGSSetWindowLevel(_CGSDefaultConnection(), [self windowNumber], CGShieldingWindowLevel()+1); 61 CGSOrderWindow(_CGSDefaultConnection(), [self windowNumber], kCGSOrderAbove, overWindowID); 62 [super display]; 63 } 64 65 - (void)closeWithFadeTime:(NSNumber *)aFadeTimeNumber 66 { 67 float aFadeTime = [aFadeTimeNumber floatValue]; 68 //Alpha is horrible on the ATV since it displays grey, but this one step fade forces everything to draw in the background before it is displayed. 69 if(![CMPATVVersion usingLeopard]) 70 aFadeTime = ANIMATE_TIME_INTERVAL / 2; 71 if(aFadeTime == 0) 72 { 73 [self close]; 74 return; 75 } 76 initialOpacity = [self alphaValue]; 77 finalOpacity = 0; 78 fadeTime = aFadeTime; 79 [opacityChangeStartTime release]; 80 opacityChangeStartTime = [[NSDate date] retain]; 81 [opacityChangeTimer invalidate]; 82 opacityChangeTimer = [NSTimer scheduledTimerWithTimeInterval:ANIMATE_TIME_INTERVAL target:self selector:@selector(opacityTimerFire) userInfo:nil repeats:YES]; 83 } 84 85 - (void)displayWithFadeTime:(float)aFadeTime 86 { 87 if(finalOpacity == 1) 88 //Already displayed 89 return; 90 //Same as above 91 if(![CMPATVVersion usingLeopard]) 92 aFadeTime = ANIMATE_TIME_INTERVAL / 2; 93 if(aFadeTime) 94 [self setAlphaValue:0]; 95 [self display]; 96 if(aFadeTime) 97 { 98 initialOpacity = 0; 99 finalOpacity = 1; 100 fadeTime = aFadeTime; 101 opacityChangeStartTime = [[NSDate date] retain]; 102 opacityChangeTimer = [NSTimer scheduledTimerWithTimeInterval:ANIMATE_TIME_INTERVAL target:self selector:@selector(opacityTimerFire) userInfo:nil repeats:YES]; 103 } 104 } 105 106 - (void)opacityTimerFire 107 { 108 double interval = -[opacityChangeStartTime timeIntervalSinceNow]; 109 float currentOpacity; 110 if(interval > fadeTime) 111 { 112 [[self retain] autorelease]; //Prevent us from being released with the invalidate 113 currentOpacity = finalOpacity; 114 [opacityChangeTimer invalidate]; 115 opacityChangeTimer = nil; 116 if(finalOpacity == 0) 117 { 118 [self close]; 119 return; 120 } 121 } 122 else 123 currentOpacity = initialOpacity + (finalOpacity - initialOpacity) * interval / fadeTime; 124 [self setAlphaValue:currentOpacity]; 125 } 126 127 @end 128 129 @implementation CMPDVDTextView 130 131 - (id)initWithContentRect:(NSRect)contentRect position:(CMPDVDOverlayPosition)aPosition overWindow:(int)windowID 132 { 133 self = [super initWithContentRect:contentRect overWindow:windowID]; 134 if(!self) 135 return nil; 136 137 position = aPosition; 138 textField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 300, 300)]; 139 [[self contentView] addSubview:textField]; 140 [textField setStringValue:@""]; 141 [textField setTextColor:[NSColor colorWithDeviceHue:227.0f/360.0f saturation:.60f brightness:1 alpha:1]]; 142 [textField setBackgroundColor:[NSColor blackColor]]; 143 NSFont *font = [textField font]; 144 NSFont *newFont = [NSFont fontWithName:[font fontName] size:contentRect.size.height / 15]; 145 [textField setFont:newFont]; 146 [textField setBezeled:NO]; 147 [textField setBordered:NO]; 148 149 return self; 150 } 151 152 - (void)dealloc 153 { 154 [textField release]; 155 [super dealloc]; 156 } 157 158 - (void)setText:(NSString *)text 159 { 160 [textField setStringValue:text]; 161 [textField sizeToFit]; 162 NSRect frameRect; 163 frameRect.size = [textField frame].size; 164 //NSLog(@"Size is %fx%f", frameRect.size.width, frameRect.size.height); 165 float distanceFromEdge = screenRect.size.height / 15; 166 if(position == CMPDVDOverlayUpperLeft || position == CMPDVDOverlayUpperRight) 167 frameRect.origin.y = screenRect.size.height - frameRect.size.height - distanceFromEdge; 168 else 169 frameRect.origin.y = distanceFromEdge; 170 if(position == CMPDVDOverlayUpperRight || position == CMPDVDOverlayLowerRight) 171 frameRect.origin.x = screenRect.size.width - frameRect.size.width - distanceFromEdge; 172 else 173 frameRect.origin.x = distanceFromEdge; 174 [self setFrame:frameRect display:YES]; 175 } 176 177 @end 178 179 180 @interface CMPDVDPlayerPlayHeadView : NSView 181 { 182 float playHeadLocation; 183 } 184 - (void)setPlayHeadLocation:(float)playHeadLocation; 185 186 @end 187 188 @implementation CMPDVDPlayerPlayHeadView 189 190 - (void)drawRect:(NSRect)rect 191 { 192 NSRect myFrame = [self frame]; 193 float height = myFrame.size.height; 194 float width = myFrame.size.width; 195 [[NSColor blackColor] set]; 196 NSRectFill(rect); 197 NSBezierPath *path = [NSBezierPath bezierPath]; 198 [path moveToPoint:NSMakePoint(height/2, height)]; 199 [path appendBezierPathWithArcWithCenter:NSMakePoint(height/2, height/2) radius:height/2 startAngle:90 endAngle:270]; 200 [path lineToPoint:NSMakePoint(width-height/2, 0)]; 201 [path appendBezierPathWithArcWithCenter:NSMakePoint(width-height/2, height/2) radius:height/2 startAngle:270 endAngle:90]; 202 [path closePath]; 203 [[NSColor colorWithDeviceHue:227.0f/360.0f saturation:.60f brightness:1 alpha:1] set]; 204 [path fill]; 205 206 path = [NSBezierPath bezierPath]; 207 float position = playHeadLocation * (width - height) + height/2; 208 float border = height / 20; 209 [path moveToPoint:NSMakePoint(position, border)]; 210 [path lineToPoint:NSMakePoint(position-height/2+border, height/2)]; 211 [path lineToPoint:NSMakePoint(position, height-border)]; 212 [path lineToPoint:NSMakePoint(position+height/2-border, height/2)]; 213 [path closePath]; 214 [[NSColor blackColor] set]; 215 [path fill]; 216 } 217 218 - (void)setPlayHeadLocation:(float)aPlayHeadLocation 219 { 220 playHeadLocation = aPlayHeadLocation; 221 [self setNeedsDisplay:YES]; 222 } 223 224 @end 225 226 227 @implementation CMPDVDPlayerPlayHead 228 229 - (id)initWithContentRect:(NSRect)contentRect overWindow:(int)windowID 230 { 231 self = [super initWithContentRect:contentRect overWindow:windowID]; 232 if(!self) 233 return self; 234 235 float myWidth = contentRect.size.width * 27 / 32; 236 float textHeight = contentRect.size.height * 3 / 72; 237 float textWidth = textHeight * 3; 238 float textBuffer = textHeight / 2; 239 float textSize = contentRect.size.height / 33; 240 elapsedField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, (textSize-textHeight)/7, textWidth, textHeight)]; 241 [[self contentView] addSubview:elapsedField]; 242 [elapsedField setStringValue:@""]; 243 [elapsedField setTextColor:[NSColor whiteColor]]; 244 [elapsedField setBackgroundColor:[NSColor blackColor]]; 245 NSFont *font = [elapsedField font]; 246 NSFont *newFont = [NSFont fontWithName:[font fontName] size:textSize]; 247 [elapsedField setFont:newFont]; 248 [elapsedField setBezeled:NO]; 249 [elapsedField setBordered:NO]; 250 [elapsedField setSelectable:NO]; 251 [elapsedField setAlignment:NSRightTextAlignment]; 252 253 durationField = [[NSTextField alloc] initWithFrame:NSMakeRect(myWidth-textWidth, (textSize-textHeight)/7, textWidth, textHeight)]; 254 [[self contentView] addSubview:durationField]; 255 [durationField setStringValue:@""]; 256 [durationField setTextColor:[NSColor whiteColor]]; 257 [durationField setBackgroundColor:[NSColor blackColor]]; 258 [durationField setFont:newFont]; 259 [durationField setBezeled:NO]; 260 [durationField setBordered:NO]; 261 [durationField setSelectable:NO]; 262 263 playView = [[CMPDVDPlayerPlayHeadView alloc] initWithFrame:NSMakeRect(textWidth + textBuffer, textHeight / 5, myWidth-textWidth*2-textBuffer*2, textHeight * 3 /5)]; 264 [[self contentView] addSubview:playView]; 265 [self setFrame:NSMakeRect(contentRect.size.width * 5 / 64, textHeight*2, myWidth, textHeight) display:NO]; 266 267 return self; 268 } 269 270 - (void) dealloc 271 { 272 [durationField release]; 273 [player release]; 274 [playView release]; 275 [updateTimer invalidate]; 276 [super dealloc]; 277 } 278 279 NSString *timeStringForTime(int time) 280 { 281 int seconds = time % 60; 282 time /= 60; 283 int minutes = time % 60; 284 time /= 60; 285 int hours = time; 286 287 if(hours == 0) 288 return [NSString stringWithFormat:@"%d:%02d", minutes, seconds]; 289 290 return [NSString stringWithFormat:@"%d:%02d:%02d", hours, minutes, seconds]; 291 } 292 293 - (void)close 294 { 295 [updateTimer invalidate]; 296 updateTimer = nil; 297 [super close]; 298 } 299 300 - (void)updateDisplay 301 { 302 int elapsedTime = [player titleElapsedTime]; 303 int durationTime = [player titleDurationTime]; 304 305 [elapsedField setStringValue:timeStringForTime(elapsedTime)]; 306 [durationField setStringValue:timeStringForTime(durationTime)]; 307 [playView setPlayHeadLocation:((float)elapsedTime)/((float)durationTime)]; 308 } 309 310 - (void)setPlayer:(CMPDVDPlayer *)aPlayer 311 { 312 [player release]; 313 player = [aPlayer retain]; 314 315 [self updateDisplay]; 316 317 [updateTimer invalidate]; 318 updateTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateDisplay) userInfo:nil repeats:YES]; 319 } 320 321 @end 322 323 @interface CMPDVDSelectionView : NSView 324 { 325 NSTimer *moveTimer; 326 float initialY, finalY; 327 NSDate *startTime; 328 } 329 @end 330 331 @implementation CMPDVDSelectionView 332 333 #define CMPDVDSelectionViewMoveTime 0.2 334 335 - (id)initWithFrame:(NSRect)frame 336 { 337 self = [super initWithFrame:frame]; 338 if(!self) 339 return self; 340 341 initialY = finalY = frame.origin.y; 342 343 return self; 344 } 345 346 - (void)dealloc 347 { 348 [moveTimer invalidate]; 349 [startTime release]; 350 [super dealloc]; 351 } 352 353 void Interpolate (void* info, float const* inData, float* outData) 354 { 355 float value = sin(M_PI_2 * inData[0])/2; 356 outData[0] = value; 357 outData[1] = value; 358 outData[2] = value; 359 outData[3] = 1.0; 360 } 361 362 - (void)drawRect:(NSRect)rect 363 { 364 NSRect frame = [self frame]; 365 NSRect drawPath = frame; 366 drawPath.origin.x = frame.size.height/8; 367 drawPath.origin.y = frame.size.height/8; 368 drawPath.size.width -= frame.size.height/4; 369 drawPath.size.height -= frame.size.height/4; 370 NSBezierPath *path = [NSBezierPath bezierPathWithRect:drawPath]; 371 372 NSShadow *theShadow = [[NSShadow alloc] init]; 373 [theShadow setShadowOffset:NSMakeSize(0, 0)]; 374 [theShadow setShadowBlurRadius:frame.size.height/8]; 375 [theShadow setShadowColor:[NSColor blueColor]]; 376 [NSGraphicsContext saveGraphicsState]; 377 [theShadow set]; 378 [[NSColor blueColor] set]; 379 [path fill]; 380 381 [NSGraphicsContext restoreGraphicsState]; 382 [theShadow release]; 383 384 [[NSColor blackColor] set]; 385 NSRectFill(drawPath); 386 387 //Gradient 388 struct CGFunctionCallbacks callbacks = { 0, Interpolate, NULL }; 389 390 CGFunctionRef function = CGFunctionCreate(NULL, 1, NULL, 4, NULL, &callbacks); 391 CGColorSpaceRef cspace = CGColorSpaceCreateDeviceRGB(); 392 393 CGPoint start = CGPointMake(drawPath.origin.x, drawPath.origin.y + drawPath.size.height); 394 CGPoint end = CGPointMake(drawPath.origin.x, drawPath.origin.y + drawPath.size.height/2); 395 CGShadingRef shading = CGShadingCreateAxial(cspace, start, end, function, false, false); 396 397 CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; 398 CGContextSaveGState(context); 399 CGContextClipToRect(context, CGRectMake(drawPath.origin.x, drawPath.origin.y, drawPath.size.width, drawPath.size.height)); 400 CGContextDrawShading(context, shading); 401 CGContextRestoreGState(context); 402 403 CGShadingRelease(shading); 404 CGColorSpaceRelease(cspace); 405 CGFunctionRelease(function); 406 [[NSColor blackColor] set]; 407 [path stroke]; 408 } 409 410 - (void)moveTimerFire 411 { 412 double interval = -[startTime timeIntervalSinceNow]; 413 float currentY; 414 if(interval > CMPDVDSelectionViewMoveTime) 415 { 416 currentY = finalY; 417 [moveTimer invalidate]; 418 moveTimer = nil; 419 } 420 else 421 currentY = initialY + (finalY - initialY) * interval / CMPDVDSelectionViewMoveTime; 422 NSRect frame = [self frame]; 423 NSRect newFrame = frame; 424 newFrame.origin.y = currentY; 425 [self setFrame:newFrame]; 426 [[self superview] setNeedsDisplayInRect:frame]; 427 [self setNeedsDisplay:YES]; 428 } 429 430 - (void)animateMoveToYDelta:(float)newY 431 { 432 [moveTimer invalidate]; 433 finalY += newY; 434 initialY = [self frame].origin.y; 435 [startTime release]; 436 startTime = [[NSDate date] retain]; 437 moveTimer = [NSTimer scheduledTimerWithTimeInterval:ANIMATE_TIME_INTERVAL target:self selector:@selector(moveTimerFire) userInfo:nil repeats:YES]; 438 } 439 440 @end 441 442 443 444 @implementation CMPDVDBlurredMenu 445 446 - (id)initWithItems:(NSArray*)anItems contentRect:(NSRect)contentRect overWindow:(int)windowID 447 { 448 self = [super initWithContentRect:contentRect overWindow:windowID]; 449 if(!self) 450 return self; 451 452 imageView = [[NSImageView alloc] initWithFrame:contentRect]; 453 [[self contentView] addSubview:imageView]; 454 455 NSMutableArray *items = [[NSMutableArray alloc] init]; 456 457 int itemCount = [anItems count]; 458 itemHeight = contentRect.size.height / 12; 459 int itemWidth = itemHeight * 10; 460 int bottom = (contentRect.size.height - itemHeight * itemCount) / 2; 461 int left = (contentRect.size.width - itemWidth) / 2; 462 463 float inset = contentRect.size.height * 5 / 144; 464 float borderSize = contentRect.size.height / 72; 465 selectionView = [[CMPDVDSelectionView alloc] initWithFrame:NSMakeRect(left, bottom + itemHeight * (itemCount-1) - borderSize, itemWidth, itemHeight+borderSize*2)]; 466 [[self contentView] addSubview:selectionView]; 467 468 NSFont *newFont = nil; 469 for(int i=0; i<itemCount; i++) 470 { 471 NSTextField *menuItem = [[NSTextField alloc] initWithFrame:NSMakeRect(left+inset, bottom+itemHeight*(itemCount-1-i), itemWidth-inset, itemHeight)]; 472 [menuItem setStringValue:[anItems objectAtIndex:i]]; 473 [[self contentView] addSubview:menuItem]; 474 [menuItem setTextColor:[NSColor whiteColor]]; 475 [menuItem setDrawsBackground:NO]; 476 [menuItem setBezeled:NO]; 477 [menuItem setBordered:NO]; 478 [menuItem setSelectable:NO]; 479 if(newFont == nil) 480 { 481 NSFont *font = [menuItem font]; 482 newFont = [NSFont fontWithName:[font fontName] size:contentRect.size.height / 20]; 483 } 484 [menuItem setFont:newFont]; 485 486 [menuItem sizeToFit]; 487 NSRect frame = [menuItem frame]; 488 frame.origin.y += (itemHeight - frame.size.height) / 2; 489 [menuItem setFrame:frame]; 490 491 [items addObject:menuItem]; 492 [menuItem release]; 493 } 494 495 menuItems = [items copy]; 496 [items release]; 497 498 [self setFrame:contentRect display:YES]; 499 500 return self; 501 } 502 503 - (void) dealloc 504 { 505 [menuItems release]; 506 [selectionView release]; 507 [imageView release]; 508 [super dealloc]; 509 } 510 511 512 - (void)display 513 { 514 if(!overWindowID) 515 return; 516 CGSConnectionID cid = _CGSDefaultConnection(); 517 CGRect bounds; 518 CGSGetWindowBounds(cid, overWindowID, &bounds); 519 //NSLog(@"Bounds is %fx%f - %fx%f", bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height); 520 // CGLGetCurrentContext() 521 //NSLog(@"bounds is %fx%f-%fx%f", bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height); 522 CGRect imageBounds = bounds; 523 if(bounds.size.height > 480 || bounds.size.width > 720) 524 { 525 float py = bounds.size.height / 480; 526 float px = bounds.size.width / 720; 527 float divisor = MIN(py, px); 528 imageBounds.size.width = floorf(imageBounds.size.width / divisor); 529 imageBounds.size.height = floorf(imageBounds.size.height / divisor); 530 } 531 int bitmapSize = imageBounds.size.width *imageBounds.size.height * 4; 532 char *bitmap = malloc(bitmapSize); 533 CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); 534 CGContextRef context = CGBitmapContextCreate(bitmap, imageBounds.size.width, imageBounds.size.height, 8, imageBounds.size.width * 4, colorspace, kCGImageAlphaNoneSkipFirst); 535 // Copy the contents of the window to the graphic context 536 CGContextCopyWindowCaptureContentsToRect(context, imageBounds, cid, overWindowID, 0); 537 538 NSData *bitmapData = [NSData dataWithBytesNoCopy:bitmap length:bitmapSize]; 539 CIImage *myCIImage = [[CIImage alloc] initWithBitmapData:bitmapData bytesPerRow:imageBounds.size.width * 4 size:imageBounds.size format:kCIFormatARGB8 colorSpace:colorspace]; 540 CIFilter *gaussianBlur = [CIFilter filterWithName:@"CIGaussianBlur"]; 541 [gaussianBlur setDefaults]; 542 [gaussianBlur setValue:myCIImage forKey:@"inputImage"]; 543 [myCIImage release]; 544 545 CIImage *result = [gaussianBlur valueForKey:@"outputImage"]; 546 CIFilter *crop = [CIFilter filterWithName:@"CICrop"]; 547 [crop setDefaults]; 548 [crop setValue:result forKey:@"inputImage"]; 549 [crop setValue:[CIVector vectorWithX:0 Y:0 Z:imageBounds.size.width W:imageBounds.size.height] forKey:@"inputRectangle"]; 550 result = [crop valueForKey:@"outputImage"]; 551 NSImage *resultAsNSImage; 552 if([result isKindOfClass:[CIImage class]]) 553 { 554 resultAsNSImage = [[NSImage alloc] initWithSize:NSMakeSize([result extent].size.width, [result extent].size.height)]; 555 [resultAsNSImage addRepresentation:[NSCIImageRep imageRepWithCIImage:result]]; 556 [resultAsNSImage autorelease]; 557 } 558 else 559 resultAsNSImage = (NSImage *)result; 560 561 [resultAsNSImage setScalesWhenResized:YES]; 562 [resultAsNSImage setSize:NSMakeSize(bounds.size.width, bounds.size.height)]; 563 [imageView setImage:resultAsNSImage]; 564 [imageView setImageScaling:NSScaleProportionally]; 565 566 CGContextRelease(context); 567 CGColorSpaceRelease(colorspace); 568 569 [super display]; 570 } 571 572 - (BOOL)previousItem 573 { 574 if(selectedItem == 0) 575 return NO; 576 [selectionView animateMoveToYDelta:itemHeight]; 577 selectedItem--; 578 return YES; 579 } 580 581 - (BOOL)nextItem 582 { 583 if(selectedItem == [menuItems count]-1) 584 return NO; 585 [selectionView animateMoveToYDelta:-itemHeight]; 586 selectedItem++; 587 return YES; 588 } 589 590 - (int)selectedItem 591 { 592 return selectedItem; 593 } 594 595 @end 596 597 30 #import "CMPOverlayAction.h" 598 31 599 32 @interface BRDisplayManager (compat) … … 611 44 // screenRelease = [[CMPOverlayModeAction alloc] initWithController:controller andSettings:settings]; 612 45 screenRelease = [[CMPScreenReleaseAction alloc] initWithController:controller andSettings:settings]; 613 overlays = [[NSMutableArray alloc] init];614 46 615 47 return self; … … 619 51 { 620 52 [screenRelease release]; 53 [overlayAction release]; 621 54 [dvdWindow release]; 622 [overlays release];623 55 [super dealloc]; 624 56 } … … 690 122 CGContextFlush(ctx); 691 123 CGContextRelease(ctx); 124 125 overlayAction = [[CMPOverlayAction alloc] initWithController:nil andSettings:[NSDictionary dictionaryWithObjectsAndKeys:dvdWindow, CMPOverlayActionWindowKey, nil]]; 126 [overlayAction openWithError:nil]; 692 127 693 128 OSStatus setWindowErr = DVDSetVideoWindowID(dvdWindowID); … … 706 141 } 707 142 708 - (CMP DVDOverlayWindow *)addBlackShieldWindow143 - (CMPOverlayAction *)overlayAction 709 144 { 710 CMPDVDOverlayWindow *ret = [[CMPDVDOverlayWindow alloc] initWithContentRect:[dvdWindow frame] overWindow:[dvdWindow windowNumber]]; 711 712 [overlays addObject:ret]; 713 [ret release]; 714 715 return ret; 716 } 717 718 - (CMPDVDTextView *)addTextOverlayInPosition:(CMPDVDOverlayPosition)position 719 { 720 CMPDVDTextView *ret = [[CMPDVDTextView alloc] initWithContentRect:[dvdWindow frame] position:position overWindow:[dvdWindow windowNumber]]; 721 722 [overlays addObject:ret]; 723 [ret release]; 724 725 return ret; 726 } 727 728 - (CMPDVDPlayerPlayHead *)addPlayheadOverlay 729 { 730 CMPDVDPlayerPlayHead *ret = [[CMPDVDPlayerPlayHead alloc] initWithContentRect:[dvdWindow frame] overWindow:[dvdWindow windowNumber]]; 731 732 [overlays addObject:ret]; 733 [ret release]; 734 735 return ret; 736 } 737 738 - (CMPDVDBlurredMenu *)addBlurredMenuOverlayWithItems:(NSArray *)items 739 { 740 CMPDVDBlurredMenu *ret = [[CMPDVDBlurredMenu alloc] initWithItems:items contentRect:[dvdWindow frame] overWindow:[dvdWindow windowNumber]]; 741 742 [overlays addObject:ret]; 743 [ret release]; 744 745 return ret; 746 } 747 748 - (void)closeOverlay:(CMPDVDOverlayWindow *)overlay 749 { 750 [self closeOverlay:overlay withFade:[NSNumber numberWithFloat:0]]; 751 } 752 753 - (void)closeOverlay:(CMPDVDOverlayWindow *)overlay withFade:(NSNumber *)fadeTimeNumber 754 { 755 [overlay closeWithFadeTime:fadeTimeNumber]; 756 [overlays removeObject:overlay]; 757 } 758 759 - (void)closeAllOverlays 760 { 761 [overlays makeObjectsPerformSelector:@selector(close)]; 762 [overlays removeAllObjects]; 763 } 764 765 - (void)closeAllOverlaysWithFadeTime:(float)fadeTime 766 { 767 if(fadeTime > 0.0f) 768 [overlays makeObjectsPerformSelector:@selector(closeWithFadeTime:) withObject:[NSNumber numberWithFloat:fadeTime]]; 769 else 770 [overlays makeObjectsPerformSelector:@selector(close)]; 771 [overlays removeAllObjects]; 145 return overlayAction; 772 146 } 773 147 … … 778 152 // OSStatus theErr = CGSReleaseWindow(conn, dvdWindowID); 779 153 // NSLog(@"CGSReleaseWindow: %d", theErr); 780 [self closeAllOverlays];781 154 [dvdWindow close]; 155 [overlayAction closeWithError:error]; 782 156 783 157 return [screenRelease closeWithError:error];
