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-23-2010, 12:01 PM   #1 (permalink)
Registered Member
 
cordoprod's Avatar
 
Join Date: Aug 2009
Location: Norway
Age: 18
Posts: 111
cordoprod is on a distinguished road
Default Playing a radio stream in the background iOS 4

Hello,
I'm using Matt Gallaghers AudioStreamer in my radio app.
It's just a stream that starts when the app launches, and stops when it quits. No play, pause, next or back controls.-
Therefore i dont need the iPod controls.

I've searched for it but i can't find a working way to implement this.
All i want is that the stream keeps playing if the user presses the home button.
__________________
 MacBook Pro 15,4" 2,4GHz 4GB 250GB.
 Mac Mini 2,53GHz 4GB 320GB.
 iPhone 3GS Black 32GB.
cordoprod is offline   Reply With Quote
Old 07-24-2010, 06:41 AM   #2 (permalink)
Registered Member
 
cordoprod's Avatar
 
Join Date: Aug 2009
Location: Norway
Age: 18
Posts: 111
cordoprod is on a distinguished road
Default

Bump
__________________
 MacBook Pro 15,4" 2,4GHz 4GB 250GB.
 Mac Mini 2,53GHz 4GB 320GB.
 iPhone 3GS Black 32GB.
cordoprod is offline   Reply With Quote
Old 07-24-2010, 08:42 AM   #3 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

Quote:
Originally Posted by cordoprod View Post
Bump
what you say about read doc?
iOS Application Programming Guide: Executing Code in the Background
__________________
dany_dev is offline   Reply With Quote
Old 07-24-2010, 08:48 AM   #4 (permalink)
Registered Member
 
cordoprod's Avatar
 
Join Date: Aug 2009
Location: Norway
Age: 18
Posts: 111
cordoprod is on a distinguished road
Default

I've already done that, but I can't seem to find a way to implement Matt's AudioStreamer to multitasking.
__________________
 MacBook Pro 15,4" 2,4GHz 4GB 250GB.
 Mac Mini 2,53GHz 4GB 320GB.
 iPhone 3GS Black 32GB.
cordoprod is offline   Reply With Quote
Old 07-24-2010, 09:29 AM   #5 (permalink)
Use [code] tags please
 
Join Date: Jun 2009
Location: Jacksonville, FL
Posts: 410
timle8n1 is on a distinguished road
Default

Quote:
Originally Posted by cordoprod View Post
I've already done that, but I can't seem to find a way to implement Matt's AudioStreamer to multitasking.
Seems to me you can add the audio task to the UIBackgroundModes property and wrap the call to start and stop in the audio in beginBackgroundTaskWithExpirationHandler and endBackgroundTask.
timle8n1 is offline   Reply With Quote
Old 07-24-2010, 09:32 AM   #6 (permalink)
Registered Member
 
cordoprod's Avatar
 
Join Date: Aug 2009
Location: Norway
Age: 18
Posts: 111
cordoprod is on a distinguished road
Default

Ok, so I tried adding UIBackgroundModes and audio to Info.plist.
Still no luck. Doesn't work. Are there more stuff I need to implement to make it work?
__________________
 MacBook Pro 15,4" 2,4GHz 4GB 250GB.
 Mac Mini 2,53GHz 4GB 320GB.
 iPhone 3GS Black 32GB.
cordoprod is offline   Reply With Quote
Old 07-24-2010, 09:34 AM   #7 (permalink)
Obj-C Learner
 
Join Date: Apr 2009
Location: Manchester, UK
Posts: 1,030
ZunePod is on a distinguished road
Send a message via MSN to ZunePod Send a message via Yahoo to ZunePod
Default

Everything is in the article.
__________________
Will code for food
ZunePod is offline   Reply With Quote
Old 07-24-2010, 09:44 AM   #8 (permalink)
Use [code] tags please
 
Join Date: Jun 2009
Location: Jacksonville, FL
Posts: 410
timle8n1 is on a distinguished road
Default

Quote:
Originally Posted by cordoprod View Post
Ok, so I tried adding UIBackgroundModes and audio to Info.plist.
Still no luck. Doesn't work. Are there more stuff I need to implement to make it work?
Did you even read my entire sentence much less the manual on backgrounding tasks?
timle8n1 is offline   Reply With Quote
Old 07-24-2010, 05:32 PM   #9 (permalink)
StM
Registered Member
 
Join Date: Jul 2010
Posts: 5
StM is on a distinguished road
Default

Quote:
Originally Posted by timle8n1 View Post
Seems to me you can add the audio task to the UIBackgroundModes property and wrap the call to start and stop in the audio in beginBackgroundTaskWithExpirationHandler and endBackgroundTask.
Thats limited for playing 10 minutes on the background. The UIBackgroundModes isnt working for some reason.
StM is offline   Reply With Quote
Old 07-24-2010, 07:53 PM   #10 (permalink)
StM
Registered Member
 
Join Date: Jul 2010
Posts: 5
StM is on a distinguished road
Default

It looks Audio Queue's dont support background playing for some reason... I can't find out why it doesnt work to move to the background and i do it exactly as in the WWDC session or as stated in the docs..
StM is offline   Reply With Quote
Old 07-24-2010, 08:39 PM   #11 (permalink)
Use [code] tags please
 
Join Date: Jun 2009
Location: Jacksonville, FL
Posts: 410
timle8n1 is on a distinguished road
Default

Quote:
Originally Posted by cordoprod View Post
Hello,
I'm using Matt Gallaghers AudioStreamer in my radio app.
It's just a stream that starts when the app launches, and stops when it quits. No play, pause, next or back controls.-
Therefore i dont need the iPod controls.

I've searched for it but i can't find a working way to implement this.
All i want is that the stream keeps playing if the user presses the home button.
Looks like AudioStreamer uses Audiotoolbox not AVAudioSession therefore I do not believe it supports multitasking audio. This library supports Mac and iPhone.

AudioStreamer.h
Code:
#include <AudioToolbox/AudioToolbox.h>
...
AudioSessionInitialize (
...
timle8n1 is offline   Reply With Quote
Old 07-25-2010, 05:33 AM   #12 (permalink)
StM
Registered Member
 
Join Date: Jul 2010
Posts: 5
StM is on a distinguished road
Default

I added in my code AVAudioSession and i added the correct key in the plist but it still doesnt work.
StM is offline   Reply With Quote
Old 07-25-2010, 05:41 AM   #13 (permalink)
Registered Member
 
Join Date: Oct 2009
Location: Amsterdam, The Netherlands
Posts: 782
TUX2K is on a distinguished road
Default

I used the following code:
Code:
	 UIDevice *thisDevice = [UIDevice currentDevice];
	 
	 if([thisDevice respondsToSelector:@selector(isMultitaskingSupported)]
		 && thisDevice.multitaskingSupported)
	 {
		 UIBackgroundTaskIdentifier backgroundTask = [application beginBackgroundTaskWithExpirationHandler:^{
			 /* just fail if this happens. */
			 NSLog(@"BackgroundTask Expiration Handler is called");
			 [application endBackgroundTask:backgroundTask];
		 }];
	 }
Place it in the didFinishLaunchingWithOptions.
This will work in the simulator, I don't have a iPhone 3gs or 4 so i'm unable te test it on a real device.
TUX2K is offline   Reply With Quote
Old 07-25-2010, 05:45 AM   #14 (permalink)
StM
Registered Member
 
Join Date: Jul 2010
Posts: 5
StM is on a distinguished road
Default

Thats limited to 10 minutes on the background, after that the app is quit by the OS.
StM is offline   Reply With Quote
Old 07-28-2010, 08:47 AM   #15 (permalink)
Registered Member
 
Join Date: Oct 2009
Location: Amsterdam, The Netherlands
Posts: 782
TUX2K is on a distinguished road
Default

This seems to work:
DigitalDJ's AudioStreamer at master - GitHub

Plays in the background, does not work in the simulator!!
TUX2K is offline   Reply With Quote
Old 09-12-2010, 04:06 PM   #16 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 138
rrichar is on a distinguished road
Default

Can someone post example code on how DigitalDJ's AudioStreamer at master - GitHub works ?
rrichar is offline   Reply With Quote
Old 03-24-2011, 02:03 AM   #17 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 1
firstapple is on a distinguished road
Default Hi,

Quote:
Originally Posted by cordoprod View Post
Hello,
I'm using Matt Gallaghers AudioStreamer in my radio app.
It's just a stream that starts when the app launches, and stops when it quits. No play, pause, next or back controls.-
Therefore i dont need the iPod controls.

I've searched for it but i can't find a working way to implement this.
All i want is that the stream keeps playing if the user presses the home button.
Hi,
am also exactly looking for same. is there any sample code for this streaming
firstapple is offline   Reply With Quote
Old 01-19-2012, 06:57 AM   #18 (permalink)
Registered Member
 
Join Date: Oct 2011
Posts: 8
Owais is on a distinguished road
Default

Quote:
Originally Posted by TUX2K View Post
I used the following code:
Code:
	 UIDevice *thisDevice = [UIDevice currentDevice];
	 
	 if([thisDevice respondsToSelector:@selector(isMultitaskingSupported)]
		 && thisDevice.multitaskingSupported)
	 {
		 UIBackgroundTaskIdentifier backgroundTask = [application beginBackgroundTaskWithExpirationHandler:^{
			 /* just fail if this happens. */
			 NSLog(@"BackgroundTask Expiration Handler is called");
			 [application endBackgroundTask:backgroundTask];
		 }];
	 }
Place it in the didFinishLaunchingWithOptions.
This will work in the simulator, I don't have a iPhone 3gs or 4 so i'm unable te test it on a real device.




This code work only in Simulator can u please tell me code for iphon...
Thankx in Advance
Owais 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: 344
14 members and 330 guests
alexP, appservice, bignoggins, EXOPTENDAELAX, flamingliquid, guusleijsten, Hamad, mariano_donati, Objective Zero, ohmniac, Paul Slocum, Rudy, v1n2e7t
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:43 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0