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 Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-30-2010, 12:18 AM   #26 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Leak:

Code:
self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
Leak:

Code:
self.audioPlayer2 = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL2 error:nil]
Questionable:

Code:
-(IBAction) stage_3 {
	//View Switch
	Stage_3 *screen = [[Stage_3 alloc] initWithNibName:nil bundle:nil];
	screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
	[self presentModalViewController:screen animated:YES];
	[screen release];
	//Audio-Make sure the audio is at the start of the stream.
	self.audioPlayer.currentTime = 0;
	
	[self.audioPlayer play];	
}
So you are going to a new view controller, but playing the music here in the old view controller? Why? Either make each view controller worry about its own music - and this would mean stopping the music in the old view controller when you go to the new one - or make a single, common audio player.

This is a good example of what I was talking about before. You are leaving these audio players alive, even though the view isn't on the screen. So, get rid of them, like I said all the way back in post #4.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 07-30-2010, 12:25 AM   #27 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 106
AdamSubach is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
Leak:

Code:
self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
Leak:

Code:
self.audioPlayer2 = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL2 error:nil]
Questionable:

Code:
-(IBAction) stage_3 {
	//View Switch
	Stage_3 *screen = [[Stage_3 alloc] initWithNibName:nil bundle:nil];
	screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
	[self presentModalViewController:screen animated:YES];
	[screen release];
	//Audio-Make sure the audio is at the start of the stream.
	self.audioPlayer.currentTime = 0;
	
	[self.audioPlayer play];	
}
So you are going to a new view controller, but playing the music here in the old view controller? Why? Either make each view controller worry about its own music - and this would mean stopping the music in the old view controller when you go to the new one - or make a single, common audio player.

This is a good example of what I was talking about before. You are leaving these audio players alive, even though the view isn't on the screen. So, get rid of them, like I said all the way back in post #4.

How would I create a single audioPlayer? If you mean code a single audioplayer then #import them into the rest of my views?

"By the way thank you so much for all your help"
AdamSubach is offline   Reply With Quote
Old 07-30-2010, 12:30 AM   #28 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

You could either move it to your app delegate or create your own singleton class.

It really depends on what the music is supposed to do. If each view controller plays a different song, then you can leave it pretty much as it is. Just stop playing music in the old controller, and clear out the property. You can build a new player when you return to the old controller.

If you just have background music that plays the entire time no matter what the user does, then all you need is a single player, and that player should not be in a view controller.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 07-30-2010, 12:25 PM   #29 (permalink)
justdan
 
Join Date: Jan 2009
Location: Dallas
Posts: 38
justdan0227 is on a distinguished road
Default

Quote:
Originally Posted by AdamSubach View Post
Not that im seeing...

Check to be sure that the NIB you are loading has all of the controls still in it that you linked back to your header file. I found this the hard way after renaming a control in my H and then not relinking it in my NIB. The NIB would fail on load.
justdan0227 is offline   Reply With Quote
Reply

Bookmarks

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: 339
16 members and 323 guests
appservice, bignoggins, dermotos, Domele, EXOPTENDAELAX, guusleijsten, Hamad, heshiming, linkmx, mariano_donati, Objective Zero, Paul Slocum, Rudy, Sloshmonster, teebee74
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,653
Threads: 94,115
Posts: 402,888
Top Poster: BrianSlick (7,990)
Welcome to our newest member, ohmniac
Powered by vBadvanced CMPS v3.1.0

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