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-25-2008, 11:36 PM   #1 (permalink)
New Member
 
Join Date: Jul 2008
Posts: 7
catfacts is on a distinguished road
Question How to play MP3 Audio Stream

Hi, I want to play an audio stream as soon as my appliction loads. But what I need to know is how to acutally play the stream. I think it requires the AudioToolbox.framework and CoreAudio and AudioFileStreamOpen but I don't know how. All I need it to do is start playing when the app opens and stop when it closes, buffer would be nice but isnt needed right now. I'm a bit of a noob so be nice and explain in detail please.
catfacts is offline   Reply With Quote
Old 07-25-2008, 11:45 PM   #2 (permalink)
Senior Member
 
MaCeXpErTo's Avatar
 
Join Date: Jul 2008
Posts: 149
MaCeXpErTo is on a distinguished road
Default

Quote:
Originally Posted by catfacts View Post
Hi, I want to play an audio stream as soon as my appliction loads. But what I need to know is how to acutally play the stream. I think it requires the AudioToolbox.framework and CoreAudio and AudioFileStreamOpen but I don't know how. All I need it to do is start playing when the app opens and stop when it closes, buffer would be nice but isnt needed right now. I'm a bit of a noob so be nice and explain in detail please.
To play streamed audio, you connect to a network stream using the CFNetwork interfaces from Core Foundation, such as those in CFHTTPMessage. You then parse the network packets into audio packets using Audio File Stream Services (AudioToolbox/AudioFileStream.h). Finally, you play the audio packets using Audio Queue Services (AudioToolbox/AudioQueue.h). You can also use Audio File Stream Services to parse audio packets from an on-disk file.

To Play the audio when the app opens just use - (void)awakeFromNib {

Maybe someone else can go into more detail.
MaCeXpErTo is offline   Reply With Quote
Old 07-26-2008, 12:21 AM   #3 (permalink)
New Member
 
Join Date: Jul 2008
Posts: 7
catfacts is on a distinguished road
Default

That is quite helpful and my be enough. I was looking for a code example but I will try to research this more (UGH ive been doing research for 5+ hours straight, honest) but this is a lot more stuff than people have give me to put together before, thanks!
catfacts is offline   Reply With Quote
Old 07-26-2008, 01:15 AM   #4 (permalink)
New Member
 
Join Date: Jul 2008
Posts: 7
catfacts is on a distinguished road
Default

Ok I tried
Code:
-(void)awakeFromNIB
{
	NSString *streamURL = @"http://66.225.205.8:80/";
	AudioFileStreamOpen(0, nil, nil, ".mp3", CFReadStreamRead(CFReadStreamOpen(streamURL), 8, 800));
}
But it isnt working. That is the correct URL BTW, so uh yea help plz!
catfacts is offline   Reply With Quote
Old 07-26-2008, 01:14 PM   #5 (permalink)
Senior Member
 
MaCeXpErTo's Avatar
 
Join Date: Jul 2008
Posts: 149
MaCeXpErTo is on a distinguished road
Default

Quote:
Originally Posted by catfacts View Post
Ok I tried
Code:
-(void)awakeFromNIB
{
	NSString *streamURL = @"http://66.225.205.8:80/";
	AudioFileStreamOpen(0, nil, nil, ".mp3", CFReadStreamRead(CFReadStreamOpen(streamURL), 8, 800));
}
But it isnt working. That is the correct URL BTW, so uh yea help plz!
The awakeFromNIB should be - (void)awakeFromNib {

NOT capital NIB

And maybe put @interface NSObject(UINibLoadingAdditions) before the awakeFromNib
__________________
"I love this place"

Last edited by MaCeXpErTo; 07-26-2008 at 01:18 PM.
MaCeXpErTo is offline   Reply With Quote
Old 07-26-2008, 03:09 PM   #6 (permalink)
New Member
 
Join Date: Jul 2008
Posts: 7
catfacts is on a distinguished road
Default

Code:
-(void)awakeFromNib
{
		NSString *streamURL = @"http://66.225.205.8:80/";
		AudioFileStreamOpen(0, nil, nil, ".mp3", CFReadStreamRead(CFReadStreamOpen(streamURL), 8, 800));
}
I get the errors...
Code:
warning: passing argument 1 of 'CFReadStreamOpen' from incompatible pointer type
warning: passing argument 1 of 'CFReadStreamRead' makes pointer from integer without a cast
warning: passing argument 2 of 'CFReadStreamRead' makes pinter from integer without a cast
warning: passing argument 4 of 'AudioFileStreamOpen' makes integer from pointer without a cast
warning: passing argument 5 of 'AudioFileStreamOpen' makes pointer from integer without a cast
so i think i messed up some of these arguments.
catfacts is offline   Reply With Quote
Old 08-03-2008, 01:43 PM   #7 (permalink)
ToM
InsiderApps.com
 
Join Date: Jul 2008
Posts: 101
ToM is on a distinguished road
Default

Quote:
Originally Posted by catfacts View Post
Code:
-(void)awakeFromNib
{
		NSString *streamURL = @"http://66.225.205.8:80/";
		AudioFileStreamOpen(0, nil, nil, ".mp3", CFReadStreamRead(CFReadStreamOpen(streamURL), 8, 800));
}
I get the errors...
Code:
warning: passing argument 1 of 'CFReadStreamOpen' from incompatible pointer type
warning: passing argument 1 of 'CFReadStreamRead' makes pointer from integer without a cast
warning: passing argument 2 of 'CFReadStreamRead' makes pinter from integer without a cast
warning: passing argument 4 of 'AudioFileStreamOpen' makes integer from pointer without a cast
warning: passing argument 5 of 'AudioFileStreamOpen' makes pointer from integer without a cast
so i think i messed up some of these arguments.

I think it may be due to the / after the URL. Not entirely sure though, give it a go without the /.
ToM is offline   Reply With Quote
Old 08-16-2008, 05:45 PM   #8 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: London
Posts: 21
hypercrypt is on a distinguished road
Default

Did you get this to work?
hypercrypt is offline   Reply With Quote
Old 08-16-2008, 09:21 PM   #9 (permalink)
ToM
InsiderApps.com
 
Join Date: Jul 2008
Posts: 101
ToM is on a distinguished road
Default

I had a go, and still failed to get it to work.

Anyone who has had success with this, could you have a look at the code and identify what's wrong with it? I'm also looking for this.
ToM is offline   Reply With Quote
Old 08-16-2008, 10:50 PM   #10 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 2
etejkowski is on a distinguished road
Default

These errors:

"…makes pointer from integer without a cast"

might mean that you need to define the numbers as NSInteger instead of just plugging in values. e.g.

NSInteger someNumber;
someNumber = 800;

or maybe you need an NSNumber

Last edited by etejkowski; 08-18-2008 at 10:09 AM.
etejkowski is offline   Reply With Quote
Old 09-06-2008, 10:13 AM   #11 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 27
superuser is on a distinguished road
Send a message via AIM to superuser
Default

More on this would be very helpful.
superuser is offline   Reply With Quote
Old 09-06-2008, 10:23 AM   #12 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: London
Posts: 21
hypercrypt is on a distinguished road
Default

Yep, if anyone knows anything...
hypercrypt is offline   Reply With Quote
Old 09-09-2008, 10:59 AM   #13 (permalink)
ToM
InsiderApps.com
 
Join Date: Jul 2008
Posts: 101
ToM is on a distinguished road
Default

Agreed, I really need some help on this, too.
ToM is offline   Reply With Quote
Old 10-02-2008, 12:45 PM   #14 (permalink)
New Member
 
Join Date: Oct 2008
Posts: 1
callajd is on a distinguished road
Default

Anyone make any progress here? I'm eager to hear if anyone found a solution.

Thanks,
jeff.
callajd is offline   Reply With Quote
Old 12-05-2008, 10:37 AM   #15 (permalink)
ToM
InsiderApps.com
 
Join Date: Jul 2008
Posts: 101
ToM is on a distinguished road
Default

Take a gander at this:

Cocoa with Love: Streaming and playing an MP3 stream
ToM is offline   Reply With Quote
Old 11-29-2009, 08:09 PM   #16 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 1
Vlajbert is on a distinguished road
Default

I'm still learning this stuff but I believe the 8 should be a pointer to a buffer not an int.

CFReadStreamRead(CFReadStreamOpen(streamURL), 8, 800)
Vlajbert is offline   Reply With Quote
Old 03-15-2010, 02:21 AM   #17 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 22
iphonemobdev is on a distinguished road
Default Found modified code working with call interruption

I got that sample code which working with call interruption, plz grab from here.

Smart SDKs Tips Blog Archive iPhone Audio Streamer – Working code with call interruption
iphonemobdev is offline   Reply With Quote
Old 03-20-2010, 02:25 AM   #18 (permalink)
Banned
 
Join Date: Jan 2010
Location: Shanghai,China
Posts: 6
ForrestShi is on a distinguished road
Thumbs up

Quote:
Originally Posted by iphonemobdev View Post
I got that sample code which working with call interruption, plz grab from here.

Smart SDKs Tips Blog Archive iPhone Audio Streamer – Working code with call interruption
I have tested with this sample, very awesome ! Thanks very much.

Currently I have several ideas for audio/music apps on iPhone, hope to know more guys who are interested on this topic also.

Welcome to contact : forrest.shi@@gmail.com

or SKype : forrest.shi
ForrestShi is offline   Reply With Quote
Old 03-21-2010, 03:56 PM   #19 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 8
mixer555 is on a distinguished road
Default

Hello guys, please advice me how to get SONG TITLE from streaming source?
mixer555 is offline   Reply With Quote
Old 02-25-2012, 10:17 PM   #20 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 29
Fit4him is on a distinguished road
Default

Quote:
Originally Posted by mixer555 View Post
Hello guys, please advice me how to get SONG TITLE from streaming source?
I have searched for my days on how to keep streaming when the screen locks with AudioToolBox

Any ideas

Allen
Fit4him is offline   Reply With Quote
Old 02-28-2012, 11:32 AM   #21 (permalink)
Registered Member
 
Join Date: Feb 2012
Posts: 1
Shorty is on a distinguished road
Default

Quote:
Originally Posted by Fit4him View Post
I have searched for my days on how to keep streaming when the screen locks with AudioToolBox

Any ideas

Allen
I just added the key "UIBackgroundModes" with value "audio" to the info.plist and the example from iphonemobdev now continues in background or screen locked.
Shorty 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: 338
6 members and 332 guests
givensur, ipodphone, jbro, mer10, n00b, yomo710
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,881
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

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