25 - (void)viewDidLoad { |
25 - (void)viewDidLoad { |
26 [super viewDidLoad]; |
26 [super viewDidLoad]; |
27 srandom(time(NULL)); |
27 srandom(time(NULL)); |
28 |
28 |
29 openal_init(20); |
29 openal_init(20); |
|
30 voiceBeingPlayed = -1; |
|
31 |
|
32 // load all the voices names and store them into voiceArray |
|
33 // it's here and not in viewWillAppear because user cannot add/remove them |
|
34 NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:VOICES_DIRECTORY() error:NULL]; |
|
35 self.voiceArray = array; |
30 } |
36 } |
31 |
37 |
32 - (void)viewWillAppear:(BOOL)animated { |
38 - (void)viewWillAppear:(BOOL)animated { |
33 [super viewWillAppear:animated]; |
39 [super viewWillAppear:animated]; |
34 |
40 |
35 // this moves the tableview to the top |
41 // this moves the tableview to the top |
36 [self.tableView setContentOffset:CGPointMake(0,0) animated:NO]; |
42 [self.tableView setContentOffset:CGPointMake(0,0) animated:NO]; |
37 voiceBeingPlayed = -1; |
|
38 |
|
39 // load all the voices names and store them into voiceArray |
|
40 NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:VOICES_DIRECTORY() error:NULL]; |
|
41 self.voiceArray = array; |
|
42 } |
43 } |
43 |
44 |
44 /* |
45 -(void) viewWillDisappear:(BOOL)animated { |
45 - (void)viewDidAppear:(BOOL)animated { |
|
46 [super viewDidAppear:animated]; |
|
47 } |
|
48 */ |
|
49 |
|
50 - (void)viewWillDisappear:(BOOL)animated { |
|
51 [super viewWillDisappear:animated]; |
46 [super viewWillDisappear:animated]; |
52 if(voiceBeingPlayed >= 0) { |
47 if(voiceBeingPlayed >= 0) { |
53 openal_stopsound(voiceBeingPlayed); |
48 openal_stopsound(voiceBeingPlayed); |
54 voiceBeingPlayed = -1; |
49 voiceBeingPlayed = -1; |
55 } |
50 } |