10/17/2008

UIActivityIndicatorView

Create an ActivityIndicator programmatically

//Initalizing
UIActivityIndicatorView *myActivityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];

//Center to view
myActivityIndicator.center = self.view.center;
myActivityIndicator. autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;

//Add to view
[[self view] addSubview:myActivityIndicator];

9/17/2008

QTKit - Change Volume via IB Slider

To change the volume of a movie with a slider from the interface:

//MyControl.h
#import Cocoa/Cocoa.h
#import QTKit/QTKit.h

@interface MyControler : NSObject {
IBOutlet QTMovieView *MyMovieView
IBOutlet NSSlider *MyVolumeSlider
}
-(IBAction) changeVolume:(id)sender;

@end


//MyControl.m
#import MyControl.h
#import QTKit/QTKit.h

implementation MyControl

-(IBAction) changeVolume:(id)sender
{
float volumeValue = [sender floatValue];
[[MyMovieView movie] setVolume:volumeValue];
}



The Slider in the interface must be set to MaxValue 1 and MinValue 0, while the volumeValue is a float value.


9/16/2008

QTKit - Movie duration

Get movie duration:

//as String
-(void) movieDuration(QTMovie *)movie{
QTTime mDuration = [movie duration];
NSString *wholeDuration = (QTStringFromTime( mDuration ));
return wholeDuration;
}


wholeDuration will be displayed in format d:hh:mm:ss:timeValue:timeScale
To get format hh:mm:ss as string to display:

-(void) movieDuration(QTMovie *)movie{
NSRange durationRange = NSMakeRange(2,8);
QTTime mDuration = [movie duration];
NSString *wholeDuration = (QTStringFromTime( mDuration ));
wholeDuration = [wholeDuration substringWithRange:durationRange];
return wholeDuration;
}



//as Value
-(void) movieDuration(QTMovie *)movie{
QTTime mDuration = [movie duration];
long long wholeDuration = (mDuration.timeValue);
return wholeDuration;
}


wholeDuration will be displayed in format timeValue
  • duration = QTTime movie duration, see QTMovie docs for more information.
  • timeValue = Duration of the movieclip in format frames

QTKit - Current frame

Get the current frame from a movie:

-(void) currentMovieFrame:(QTMovie *)movie {
QTTime currentTime = [movie currentTime];
long long currentFrame=(currentTime.timeValue/currentTime.timeScale)*currentTime.timeScale/100;
return currentFrame;
}

  • currentTime = QTTime movie current time duration, see QTMovie docs for more information.
  • timeValue = Duration of the movieclip in format frames
  • timeScale = Framerate of the movieclip in format 2997, 2400 etc.

9/15/2008

SANBREEZE Dev Blog now open...

Welcome to SANBREEZE Development Blog.

This blog is an resource place for all cocoa developers on Xcode for Mac OS X and iPhone OS. We want post codes with comments and tips & tricks to help you with your projects.
You can post comments or questions and answers for all codes to make discussions with other developers.