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

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

Draw This
($0.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 07-28-2009, 07:35 PM   #1 (permalink)
GeoffMilburn
Registered Member
 
Join Date: May 2009
Posts: 15
GeoffMilburn is on a distinguished road
Smile AVAudioPlayer stop

I'm trying to stop a sound with a button but cannot get it to work no matter what iv tried here is an example one of the things I have tried.

HEADER:

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

@interface MainView : UIView {
}

-(IBAction)sound1;
-(IBAction)stop;

@end

MAIN:

#import "MainView.h"

@implementation MainView

- (IBAction)sound1 {

NSString *path = [[NSBundle mainBundle] pathForResource:@"sound" ofType:@"wav"];
AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPathath] error:NULL];
theAudio.delegate = self;
[theAudio play];

}

- (IBAction) stop {

NSString *path = [[NSBundle mainBundle] pathForResource:@"sound" ofType:@"wav"];
AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPathath] error:NULL];
theAudio.delegate = self;
[theAudio stop];

}

@end

I know there is a simple way to do this but I'm completely lost.
Please help!
GeoffMilburn is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,015
Threads: 93,863
Posts: 401,917
Top Poster: BrianSlick (7,962)
Welcome to our newest member, udrescubogdan
Powered by vBadvanced CMPS v3.1.0

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