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

Your First iPhone App
($1.99)

iPhone Code Generator
($9.99)

Calcuccino Programmers' Calculator
($2.99)

DataFon(Build Apps on Windows)
(free)

Infinote Pinboard for Todos and Notes
(free)

picplz
(free)

poG
($2.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 05-23-2009, 11:37 PM   #26 (permalink)
Objective-C Code Monkey
 
deansx's Avatar
 
Join Date: May 2009
Location: Mountain View, CA
Posts: 127
Default

.m file

Code:

#import "StopSoundViewController.h"

@implementation StopSoundViewController




// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	theAudio = nil;
}

- (IBAction) soundButtonPressed:(UIButton *)button {
	NSLog(@"SoundButton Pressed");
	if (theAudio == nil) {
		// Set up the player.
		NSLog(@"Set up theAudio");
		NSString *path = [[NSBundle mainBundle] pathForResource:@"boom" ofType:@"wav"];
		theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
		theAudio.delegate = self;
		[theAudio play];
	}
	else if ([theAudio isPlaying]) {
		// there's no point in stopping it, if it's not playing...
		NSLog(@"Stopping theAudio");
		[theAudio stop];
	}
	else {
		NSLog(@"Starting theAudio, again");
		[theAudio play];
	}
	
}

- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag {
	NSLog(@"Player Finished Playing");
}

/* if an error occurs while decoding it will be reported to the delegate. */
- (void)audioPlayerDecodeErrorDidOccur:(AVAudioPlayer *)player error:(NSError *)error {
	NSLog(@"Error Decode...");
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
}


- (void)dealloc {
    [super dealloc];
	// I know that I haven't done this.  This is just a sample.
}

@end
deansx is offline   Reply With Quote
Old 05-23-2009, 11:44 PM   #27 (permalink)
Objective-C Code Monkey
 
deansx's Avatar
 
Join Date: May 2009
Location: Mountain View, CA
Posts: 127
Default

Since your sound is named "boom" it's probably not an issue for you, but stopping sounds can introduce a pretty noticeable click when the play is interrupted. I've done a couple of posts on this on our blog.

Most recently:

But I Want to Play That Same Sound Again, Right Now -- Mobile Perspectives

and awhile ago:

Adventures in Sound Land -- Mobile Perspectives
deansx is offline   Reply With Quote
Old 07-24-2010, 04:13 PM   #28 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 14
Default avaudio framework

is there a way to get avaudio framework to play a listen.pls (shoutcast stream)
i know that the native quicktime player will play it on the iphone but i do not know how to make it browse to the url onload of my program

i have made a very crude iphone internet radio app using embed but no one on a iphone wants to click start when a program loads

i have a html fire embeded into a view so it can load the webpage and it works fine.

any help would be great

bill
HopeMedia 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
» Stats
Members: 51,375
Threads: 52,830
Posts: 225,477
Top Poster: BrianSlick (3,576)
Welcome to our newest member, darrentousignant
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:28 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0