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 > iPhone SDK Development Forums > iPhone SDK Tools & Utilities

Reply
 
LinkBack Thread Tools Display Modes
Old 04-14-2011, 10:28 AM   #1 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 16
8bitninja is on a distinguished road
Unhappy Problem with wav loops that stop working after awhile.

So, my problem is that after turning on and off my sound looping button several times, it eventually stops producing sound. I'm kind of at a dead end with this. So, if theres any new terms that you could sugest I look up or anything that could help me find my way would be greatly appreciated. Thanks again and I'll post my code below.


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

@interface MainView : UIView {

IBOutlet UIButton *soundbutton1;
IBOutlet UIButton *soundbutton2;

AVAudioPlayer*sound1;

}
-(IBAction)start;
-(IBAction)stop;

@end


///MainView.m

@implementation MainView


-(IBAction)start{

soundbutton1.hidden = TRUE;
soundbutton2.hidden = FALSE;


NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/sound1.wav", [[NSBundle mainBundle] resourcePath]]];

NSError *error;
sound1 = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
sound1.numberOfLoops = -1;

if (sound1 == nil)
NSLog([error description]);
else
[sound1 play];



}

-(IBAction)stop{

soundbutton1.hidden = FALSE;
soundbutton2.hidden = TRUE;

[sound1 stop];

}

@end

8bitninja is offline   Reply With Quote
Old 04-14-2011, 04:13 PM   #2 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 16
8bitninja is on a distinguished road
Default One problem solved.

Ok, so i found that if I add [sound1 release]; to my stop loop action it totally fixes the stoping problem, like so.


-(IBAction)stop{

soundbutton1.hidden = FALSE;
soundbutton2.hidden = TRUE;

[sound1 stop];
[sound1 release];


}
But now the problem I'm having, is whenever I press my back button my app crashes. here is the code.


-(IBAction)goback{
[UIView beginAnimations:Nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFl ipFromLeft forView:self cache:YES];
[view2 removeFromSuperview];
[self addSubview:view1];
[UIView commitAnimations];

soundbutton1.hidden = FALSE;
soundbutton2.hidden = TRUE;

[sound1 stop];
[sound1 release];

}
Any tips would be very much appreciated, Thanks.
8bitninja is offline   Reply With Quote
Reply

Bookmarks

Tags
ipad, loop, sdk, sound, xcode.

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 420
11 members and 409 guests
AppleDev, chemistry, Emy, Gi-lo, ipodphone, mistergreen2011, pipposanta, QuantumDoja, Retouchable, SLIC
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,129
Posts: 402,924
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:26 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0