diff --git a/AppDelegate.h b/AppDelegate.h index 9603467..25a2dad 100644 --- a/AppDelegate.h +++ b/AppDelegate.h @@ -19,6 +19,8 @@ @property (weak) IBOutlet NSLevelIndicator *currentTimeBar; @property (weak) IBOutlet NSTextField *currentTimeLabel; @property (weak) IBOutlet NSTextField *currentTrackLabel; +@property (weak) IBOutlet NSTextField *loopCountLabel; +@property (weak) IBOutlet NSStepper *loopCountStepper; @property (assign) BOOL paused; @@ -26,9 +28,15 @@ @property (assign) QTTime endTime; @property (assign) QTTime currentTime; @property (assign) long timeScale; +@property (assign) int loopCount; + +//The value where we'll start looping infinitely +@property (assign) int loopInfiniteCount; + @property (retain) QTMovie *music; - (void)checkTime:(NSTimer*)theTimer; +- (IBAction)loopStepperStep:(id)sender; - (IBAction)playButtonClick:(id)sender; - (IBAction)startSliderSet:(id)sender; - (IBAction)endSliderSet:(id)sender; diff --git a/AppDelegate.m b/AppDelegate.m index b18dd8e..1ed37dc 100644 --- a/AppDelegate.m +++ b/AppDelegate.m @@ -19,7 +19,11 @@ @implementation AppDelegate @synthesize currentTimeBar; @synthesize playButton; @synthesize currentTrackLabel; +@synthesize loopCountLabel; +@synthesize loopCountStepper; +@synthesize loopCount; +@synthesize loopInfiniteCount; @synthesize timeScale; @synthesize startTime; @synthesize endTime; @@ -27,17 +31,36 @@ @implementation AppDelegate @synthesize music; @synthesize paused; +-(void) setTheLoopCount:(int)theLoopCount{ + //Sets the property and updates the label + [self setLoopCount:theLoopCount]; + if([self loopCount] < [self loopInfiniteCount]) { + [loopCountLabel setStringValue:[NSString stringWithFormat:@"x%d",self.loopCount]]; + } + else { + [loopCountLabel setStringValue:@"∞"]; + } + //Finally update the stepper so it's synchronized + [loopCountStepper setIntValue:[self loopCount]]; +} - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { [[self window] setTitleBarHeight:30.0]; [[self window] setTrafficLightButtonsLeftMargin:7.0]; + [self setLoopInfiniteCount:31]; + [self setTheLoopCount:10]; + [[self loopCountStepper] setMaxValue:(double)[self loopInfiniteCount]]; } -(void) checkTime:(NSTimer*)theTimer{ currentTime = [music currentTime]; - if(currentTime.timeValue >= endTime.timeValue && startTime.timeValue < endTime.timeValue){ + if(currentTime.timeValue >= endTime.timeValue && startTime.timeValue < endTime.timeValue && [self loopCount] > 0){ + if([self loopCount] < [self loopInfiniteCount]) { + //[self loopInfiniteCount] is the magic infinite number + [self setTheLoopCount:[self loopCount]-1]; + } [music setCurrentTime:startTime]; } @@ -139,6 +162,10 @@ - (IBAction)playButtonClick:(id)sender { } } +- (IBAction)loopStepperStep:(id)sender { + [self setTheLoopCount:[loopCountStepper intValue]]; +} + - (IBAction)openFile:(id)sender { NSOpenPanel *openPanel = [NSOpenPanel openPanel]; NSInteger tvarNSInteger = [openPanel runModal]; diff --git a/en.lproj/MainMenu.xib b/en.lproj/MainMenu.xib index 1ba0f69..29e7a0a 100644 --- a/en.lproj/MainMenu.xib +++ b/en.lproj/MainMenu.xib @@ -11,6 +11,7 @@ 1938 + NSStepper NSMenuItem NSMenu NSTextFieldCell @@ -22,6 +23,7 @@ NSSlider NSSliderCell NSCustomObject + NSStepperCell NSView NSWindowTemplate NSTextField @@ -337,12 +339,12 @@ {{8, 82}, {40, 40}} - + _NS:687 YES 67239424 - 134250496 + 32768 LucidaGrande @@ -351,11 +353,11 @@ _NS:687 - 922501375 - 130 + -2038677249 + 6 NSImage - NSRightFacingTriangleTemplate + NSGoRightTemplate @@ -366,7 +368,7 @@ 268 - {{59, 86}, {245, 34}} + {{121, 86}, {215, 34}} @@ -492,13 +494,53 @@ NO + + + 268 + {{84, 89}, {19, 27}} + + + + _NS:3914 + YES + + 917024 + 0 + _NS:3914 + + 10 + 31 + 1 + YES + + + + + 268 + {{42, 95}, {38, 17}} + + + + _NS:3944 + YES + + 68288064 + 71304192 + x10 + + _NS:3944 + + + + + {400, 380} - {{0, 0}, {2560, 1440}} + {{0, 0}, {1440, 878}} {10000000000000, 10000000000000} YES @@ -684,6 +726,30 @@ 613 + + + loopCountLabel + + + + 620 + + + + loopCountStepper + + + + 621 + + + + loopStepperStep: + + + + 622 + @@ -890,6 +956,8 @@ + + @@ -1010,6 +1078,32 @@ + + 614 + + + + + + + + 615 + + + + + 617 + + + + + + + + 618 + + + @@ -1058,6 +1152,10 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1069,7 +1167,7 @@ - 613 + 622 @@ -1079,6 +1177,7 @@ id id + id id id id @@ -1092,6 +1191,10 @@ endSliderSet: id + + loopStepperStep: + id + openFile: id @@ -1110,6 +1213,8 @@ NSTextField NSTextField NSSlider + NSTextField + NSStepper NSButton NSSlider INAppStoreWindow @@ -1131,6 +1236,14 @@ endSlider NSSlider + + loopCountLabel + NSTextField + + + loopCountStepper + NSStepper + playButton NSButton @@ -1164,9 +1277,9 @@ YES 3 + {9, 9} {11, 11} {10, 3} - {9, 9} {300, 300}