Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 05-23-2009, 10:03 PM   #9 (permalink)
uncharteddev
Registered Member
 
Join Date: May 2009
Posts: 18
uncharteddev is on a distinguished road
Send a message via AIM to uncharteddev
Default Almost.....

Im getting a couple of errors here. That i cant quite figure out. Error: expected specifier-qualifier-list before [ token.

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <AVFoundation/AVAudioPlayer.h>

@interface MainView :UIView {
// the player
AVAudioPlayer* theAudio;
}
- (IBAction)myActionid)sender;

@end



And here it's saying that I havent declared theAudio. (First use in this Function. I had some other errors but I got those out of the way. These are the only two I couldnt figure out.

@implementation MainView
- (IBAction)myAction1id)sender {
if (theAudio == nil) {











Quote:
Originally Posted by deansx View Post
Ahh, then you've already got myAction hooked up to a button in your view? If so, I'd do the code for more like this (Note that I'm not compiling this, so I might have some syntax errors, sorry...):

THE .h file


Code:
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <AVFoundation/AVAudioPlayer.h>

@interface MainView :UIView {
    // the player
    AVAudioPlayer* theAudio;
}
- (IBAction)myAction:(id)sender;

@end
The source file:

Code:
#import "MainView.h"


@implementation MainView
- (IBAction)myAction:(id)sender {
   if (theAudio == nil) {
      // Set up the player.
      NSString *path = [[NSBundle mainBundle] pathForResource:@"boom" ofType:@"wav"];
      theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPathath] error:NULL];
      theAudio.delegate = self;
      [theAudio play];
   }
   else if ([theAudio isPlaying]) {
      // there's no point in stopping it, if it's not playing...
      [theAudio stop];
   }
   /* Uncomment this if you want the button to start the sound again...
   else {
      [theAudio play];
   }
   */
}	
@end
... at least I hope that this is close. To what you want. I didn't realize that you were using myAction as the target for the button. Also, note that this board seems to be automatically replacing colon open paren with a frowny face...
uncharteddev is offline   Reply With Quote
 

» Advertisements
» Online Users: 468
17 members and 451 guests
bignoggins, buggen, ClerurcifeDer, Clouds, dana0550, Duncan C, iAppDeveloper, ipodphone, krisk, linkmx, ryantcb, sacha1996, Sami Gh, stanny, Steven.C, Studder, yomo710
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,638
Threads: 94,102
Posts: 402,827
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Studder
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:48 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.