Show
Ignore:
Timestamp:
02/23/10 22:36:05 (2 years ago)
Author:
gbooker
Message:

Added Zoom, and it's overlay along with some simpler methods for determining bounds.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/PlayerFramework/CommonMediaPlayer/Media Players/DVD Framework/CMPDVDPlayer.m

    r1163 r1166  
    684684} 
    685685 
     686- (void)setZoomLevel:(CMPDVDZoomLevel)level 
     687{ 
     688        zoomLevel = level; 
     689        [self updateVideoBounds]; 
     690} 
     691 
     692- (CMPDVDZoomLevel)zoomLevel 
     693{ 
     694        return zoomLevel; 
     695} 
     696 
    686697static BOOL pauseOnPlay = NO; 
    687698- (void)initiatePlaybackWithResume:(BOOL *)resume; 
     
    730741        //NSLog(@"Stopping"); 
    731742        DVDUnregisterEventCallBack(eventCallbackID); 
     743        [stopTimer invalidate]; 
     744        stopTimer = nil; 
    732745        eventCallbackID = 0; 
    733746        DVDStop(); 
     
    868881} 
    869882 
    870 - (int)aspectRatios 
    871 { 
    872         DVDAspectRatio aspectRatio = kDVDAspectRatioUninitialized; 
    873         DVDGetAspectRatio (&aspectRatio); 
    874          
    875          
    876         switch (aspectRatio) { 
    877                 case kDVDAspectRatio4x3: 
    878                 case kDVDAspectRatio4x3PanAndScan: 
    879                         return 0; //4:3 
    880                         break; 
    881                 case kDVDAspectRatio16x9: 
    882                 case kDVDAspectRatioLetterBox: 
    883                         return 1; //16:9 
    884                         break; 
    885         } 
    886          
    887         return 0; 
    888 } 
    889  
    890 - (void)update1080iBoundsWithSize:(NSSize)nativeSize 
    891 { 
    892         int aspect = [self aspectRatios]; 
    893          
    894         //float var = (nativeSize.width/nativeSize.height); 
    895         //NSRect frame = [win frame]; 
    896         CGDirectDisplayID display = [(BRDisplayManager *)[BRDisplayManager sharedInstance] display]; 
    897     CGRect frame = CGDisplayBounds( display ); 
    898     frame.size.width = CGDisplayPixelsWide( display ); 
    899     frame.size.height = CGDisplayPixelsHigh( display ); 
    900          
    901         CGSize currentSize; 
    902         currentSize.width = frame.size.width; 
    903         currentSize.height = frame.size.height; 
    904         Rect qdRect; 
    905          
    906         switch (aspect) 
    907         { 
    908                 case 0: //4:3 
    909                         //NSLog(@"4:3"); 
    910                         qdRect.left = 125; 
    911                         qdRect.right = 1155; 
    912                         qdRect.top = 0; 
    913                         qdRect.bottom = 1080; 
    914                          
    915                         break; 
    916                          
    917                 case 1: //16:9 
    918                         //NSLog(@"16:9"); 
    919                         qdRect.left = 0; 
    920                         qdRect.right = frame.size.width; 
    921                         qdRect.top = 0; 
    922                         qdRect.bottom = 1080; 
    923                         break; 
    924                          
    925         } 
    926         DVDSetVideoBounds(&qdRect); 
    927 } 
    928  
    929883- (NSSize)size 
    930884{ 
     
    973927         
    974928        NSSize currentSize; 
    975         currentSize.width = frame.size.width; 
    976         currentSize.height = frame.size.height; 
    977          
    978929        if([shortString isEqualToString:@"1080i"]) 
    979930        { 
    980                 //NSLog(@"width = %f", (float)frame.size.width); 
    981                 //NSLog(@"height = %f", (float)frame.size.height); 
    982                 [self update1080iBoundsWithSize:nativeSize]; 
    983                 return; 
    984         } 
    985          
    986         //NSRect content = [[win contentView] bounds]; 
     931                currentSize.width = 1280; 
     932                currentSize.height = 1080; 
     933        } 
     934        else 
     935        { 
     936                currentSize.width = frame.size.width; 
     937                currentSize.height = frame.size.height; 
     938        } 
     939         
     940        NSRect rect; 
     941        if(NSEqualSizes(currentSize, nativeSize)) 
     942        { 
     943                rect.size = currentSize; 
     944        } 
     945        else if(currentSize.width/currentSize.height > nativeSize.width/nativeSize.height) 
     946        { 
     947                float resizeScale = currentSize.height/nativeSize.height; 
     948                rect.size.width = nativeSize.width * resizeScale; 
     949                rect.size.height = currentSize.height; 
     950        } 
     951        else 
     952        { 
     953                float resizeScale = currentSize.width/nativeSize.width; 
     954                frame.size.height = nativeSize.height * resizeScale; 
     955                frame.size.width = currentSize.width; 
     956        } 
     957         
     958        switch (zoomLevel) { 
     959                case CMPDVDZoomLetterBoxInFullFrame: 
     960                        rect.size.width *= 4.0f/3.0f; 
     961                        rect.size.height *= 4.0f/3.0f; 
     962                        break; 
     963                case CMPDVDZoom2x: 
     964                        rect.size.width *= 2.0f; 
     965                        rect.size.height *= 2.0f; 
     966                        break; 
     967                default: 
     968                        break; 
     969        } 
     970         
     971        rect.origin.x = (currentSize.width - rect.size.width)/2; 
     972        rect.origin.y = (currentSize.height - rect.size.height)/2; 
    987973         
    988974        Rect qdRect; 
    989         float resizeScale = 1.0; 
    990         if(NSEqualSizes(currentSize , nativeSize)) 
    991         { 
    992                 //NSLog(@"one"); 
    993                 qdRect.left = 0; 
    994                 qdRect.right = frame.size.width; 
    995                 qdRect.bottom = frame.size.height; 
    996                 qdRect.top = 0; 
    997         } 
    998         else if(currentSize.width/currentSize.height > nativeSize.width/nativeSize.height) 
    999         { 
    1000                 //NSLog(@"two"); 
    1001                 resizeScale = currentSize.height/nativeSize.height; 
    1002                 //NSLog(@"resizeScale: %f", resizeScale); 
    1003                 qdRect.left = currentSize.width/2 - (nativeSize.width * resizeScale)/2; 
    1004                 //NSLog(@"qdRect.left: %d", qdRect.left); 
    1005                 qdRect.right = currentSize.width/2 + (nativeSize.width * resizeScale)/2; 
    1006                 qdRect.bottom = frame.size.height; 
    1007                 qdRect.top = 0; 
    1008                 //NSLog(@"qdRect.left: %d right: %d top: %d bottom: %d", qdRect.left,qdRect.right,qdRect.top, qdRect.bottom); 
    1009         } 
    1010         else 
    1011         { 
    1012                 //NSLog(@"three"); 
    1013                 resizeScale = currentSize.width/nativeSize.width; 
    1014                 qdRect.left = 0; 
    1015                 qdRect.right = frame.size.width; 
    1016                 qdRect.bottom = frame.size.height - currentSize.height/2 + (nativeSize.height * resizeScale)/2; 
    1017                 qdRect.top = frame.size.height - currentSize.height/2 - (nativeSize.height * resizeScale)/2; 
    1018         } 
    1019          
    1020         //qdRect.left = 0; 
    1021         //qdRect.right = frame.size.width; 
    1022         //qdRect.bottom = frame.size.height; 
    1023         //qdRect.top = 0; 
    1024          
    1025         //NSLog(@"4: DVDSetVideoBounds"); 
     975        qdRect.left = rect.origin.x; 
     976        qdRect.right = rect.origin.x + rect.size.width; 
     977        qdRect.top = rect.origin.y; 
     978        qdRect.bottom = rect.origin.y + rect.size.height; 
     979         
    1026980        DVDSetVideoBounds(&qdRect); 
    1027         //[self display]; 
    1028         //if(result) { 
    1029         //NSLog(@"DVDSetVideoBounds returned %d", result); 
    1030         //} 
    1031          
    1032         //currentScale = currentSize.height/nativeSize.height; 
    1033981} 
    1034982