Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to play audio in the background  RSS feed

 
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is a good way to play streaming audio in the background so that audio continues to play while the user switches between activities of the app, but stops whenever, for example, the user has an incoming phone call?
 
Ranch Hand
Posts: 132
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use a Service to play audio cause it will call the AUdio Service in Android
 
Daniel Trebbien
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Michael Rivera wrote:use a Service to play audio cause it will call the AUdio Service in Android



Do you know of a good tutorial for this?
 
Ranch Hand
Posts: 136
Android Chrome Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Daniel,

You can use AsyncTask to continue playing audio even if user switches or move to another screen.

Thanks & Regards
Pratik Goswami
 
Rancher
Posts: 42975
76
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You can use AsyncTask to continue playing audio even if user switches or move to another screen.


That's not a good idea, as AsyncTask's are part of the Activity, and thus eligible for termination whenever Android feels like it. Services are better suited for longer-running tasks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!