Hello, I am trying to program audio to play in a app that I am making, in which you use a pop-up button to select which audio file will play. The only problem is that when the app loads, song1 plays, and when you press "play" (which plays the audio selected in the pop-up menu) it only plays song2, regardless of your choice. I am just starting to learn how pop-up buttons work, but if someone could tell me whats wrong so I can fix it, it would be very much appreciated.
Sorry for posting the whole code, I thought it may be easier to figure out the problem.
Code:
@implementation MusicBoardVideoController
int movie;
int moviePathStr;
- (void)awakeFromNib
{
NSString* moviePathStr = [[NSBundle mainBundle] pathForResource:@"songone" ofType:@"mp3"];
QTMovie* movie = [[QTMovie alloc] initWithFile:moviePathStr error:nil];
if (movie != nil)
{
[movie setAttribute:[NSNumber numberWithBool:NO] forKey:QTMovieEditableAttribute];
[movie setAttribute:[NSNumber numberWithBool:NO] forKey:QTMovieLoopsAttribute];
[movie setAttribute:[NSNumber numberWithFloat:5.0] forKey:QTMovieVolumeAttribute];
[(QTMovieView*)[self view] setMovie:movie];
[(QTMovieView*)[self view] setPreservesAspectRatio:YES];
[[(QTMovieView*)[self view] movie] play];
[movie release];
}
}
- (IBAction)pause:(id)sender {
[audioView pause:self];
}
- (IBAction)play:(id)sender {
movie = [musicPopup selectedTag];
switch (movie) {
case 0:
{
{
NSString* moviePathStr = [[NSBundle mainBundle] pathForResource:@"songone" ofType:@"mp3"];
QTMovie* movie = [[QTMovie alloc] initWithFile:moviePathStr error:nil];
if (movie != nil)
{
[movie setAttribute:[NSNumber numberWithBool:NO] forKey:QTMovieEditableAttribute];
[movie setAttribute:[NSNumber numberWithBool:NO] forKey:QTMovieLoopsAttribute];
[movie setAttribute:[NSNumber numberWithFloat:5.0] forKey:QTMovieVolumeAttribute];
[(QTMovieView*)[self view] setMovie:movie];
[(QTMovieView*)[self view] setPreservesAspectRatio:YES];
[[(QTMovieView*)[self view] movie] play];
[movie release];
}
}
}
case 1:
{
{
NSString* moviePathStr = [[NSBundle mainBundle] pathForResource:@"songtwo" ofType:@"mp3"];
QTMovie* movie = [[QTMovie alloc] initWithFile:moviePathStr error:nil];
if (movie != nil)
{
[movie setAttribute:[NSNumber numberWithBool:NO] forKey:QTMovieEditableAttribute];
[movie setAttribute:[NSNumber numberWithBool:NO] forKey:QTMovieLoopsAttribute];
[movie setAttribute:[NSNumber numberWithFloat:5.0] forKey:QTMovieVolumeAttribute];
[(QTMovieView*)[self view] setMovie:movie];
[(QTMovieView*)[self view] setPreservesAspectRatio:YES];
[[(QTMovieView*)[self view] movie] play];
[movie release];
}
}
}
}
}
@end
Sorry for posting the whole code, I thought it may be easier to figure out the problem.
Last edited: