rendered paste body#import "Sampler.h"
typedef enum {
kUIControlEventMouseDown = 1 << 0,
kUIControlEventMouseMovedInside = 1 << 2,
kUIControlEventMouseMovedOutside = 1 << 3,
kUIControlEventMouseUpInside = 1 << 6,
kUIControlEventMouseUpOutside = 1 << 7,
kUIControlAllEvents = (kUIControlEventMouseDown | kUIControlEventMouseMovedInside | kUIControlEventMouseMovedOutside | kUIControlEventMouseUpInside | kUIControlEventMouseUpOutside)
} UIControlEventMasks;
enum {
kFACEUP = 0,
kNORMAL = 1,
kUPSIDEDOWN = 2,
kLANDL = 3,
kLANDR = 4,
kFACEDOWN = 6
};
@implementation Sampler
- (void) playPauseButtonPressed
{
NSLog(@"Play-pause button pressed");
[playPauseButton setBackground:pauseButtonImg forState:0];
BOOL ok = [av play:nil];
}
- (void) navigationBar: (UINavigationBar*) navBar buttonClicked: (int) button
{
switch (button)
{
case 0:
NSLog(@"Go to playlist :)");
break;
case 1:
NSLog(@"Termination Requested by user");
[av pause];
[item release];
[av release];
[self terminate];
break;
default:
NSLog(@"This should never happen");
}
}
- (void) applicationDidFinishLaunching: (id) unused
{
/* RGBA - Red Blue Green Alpha color defintions */
float black[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
float white[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
struct CGRect rect = [UIHardware fullScreenApplicationContentRect];
rect.origin.x = rect.origin.y = 0;
/* Initialize the main window */
UIWindow* window = [[UIWindow alloc] initWithContentRect: rect];
[window orderFront: self];
[window makeKey: self];
[window _setHidden: false];
/* Initialize the main view */
UIView* mainView = [[[UIView alloc] initWithFrame: rect] autorelease];
[window setContentView: mainView];
[mainView setBackgroundColor: CGColorCreate(CGColorSpaceCreateDeviceRGB(), black)];
UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 48.0f)];
[navBar setBarStyle: 1];
[navBar showButtonsWithLeftTitle:@"Exit" rightTitle:@".-" leftBack: true];
[navBar setDelegate: self];
UINavigationBar *btmBar = [[UINavigationBar alloc] initWithFrame: CGRectMake(0.0f, 365.0f, 320.0f, 150.0f)];
[btmBar setBarStyle: 1];
[mainView addSubview:navBar];
[mainView addSubview:btmBar];
UIImage* playButtonImg = [UIImage imageNamed:@"play_button.png"];
UIImage* pauseButtonImg = [UIImage imageNamed:@"pause_button.png"];
UIPushButton* playPauseButton = [[UIPushButton alloc] initWithTitle:@"" autosizesToFit:NO];
[playPauseButton setFrame: CGRectMake(140.0, 370.0, 40.0, 40.0)];
[playPauseButton setShowPressFeedback:YES];
[playPauseButton setEnabled:YES];
[playPauseButton setBackground:playButtonImg forState:0];
[playPauseButton addTarget: self action:@selector(playPauseButtonPressed) forEvents:kUIControlEventMouseUpInside];
av = [[AVController alloc] init];
item = [[AVItem alloc] initWithPath:@"/private/var/root/Media/iTunes_Control/Music/F49/YVXX.mp3" error:&error];
[av setCurrentItem:item preservingRate:NO];
[mainView addSubview:playPauseButton];
}
@end