I'am currently working a mobile application for radio streaming. The problem is when I exit the application the audio stops playing. any idea about this? I really need a help. thank you
You can use service to do that.
Follow the link
Just play the song using foreground service showing music player notification in the notification panel.
You have to create a Service and run it on the foreground. Here is the link to a comprehensive implementation.
Related
I have an application which uses exoplayer to play videos.
When the user is on player page and presses the power button to close the screen I want the audio to keep playing in the background and notification should be visible to user with controls of play, pause , video metadata etc similar to what we have for every music playing app.
I can keep the audio of video playing from exoplayer using setPlayWhenReady(true).
But I am stuck in for notification. Should I be using MediaBrowserServiceCompat or I will have to create custom notification to handle it?
I think what you should do is to create ForegroundService and create notification as you mentioned to have the ForegroundService working. I think this post might help you:
https://androidwave.com/foreground-service-android-example/
Use a foreground service to implement something like this.This can help you
I have an app with a playlist and a media player UI.
The issue I am having is when I am playing music, and I re-enter the activity (using a menu), it restarts the media file (because it is calling the onCreate method from the top).
I need to implement the mediaplayer as a servive instead but I have no idea on how to do this! Everywhere I look online is just non-relevant and super confusing articles/code.
Can anyone assist with helpful tutorials or articles related to this?
My code can be found here: https://github.com/becausewesley/MusicalStructureApp
THANKS IN ADVANCE!!
This article Creating Media player service shows step by step on how you can implement a service to create a Mediaplayer application to run in the background. Hope this helps!
I've developed a music player app where i need to pause music when user gets a call through his skype app. I've tried AudioFocus and phone state listener concepts but it is not working for skype. Can somebody help me out on this.
Thanks in advance.
This link show you how it done with phone call. Sometimes it will help you.
Stopping & Starting music on incoming calls
I am working on live radio app.
I parse list of channels and show in list view , My problem is when i click on particular channel first time than it plays that channel according to assign link. but when you go out of application and come back and again you click on same channel (Which is playing currently ) it restart the media-player and start playing it again.
so to solve this problem i used manifest "singleTask" to solve this problem.But now when i try to click another link ( other than currently playing) than it wont play the current selected channel from Listview item and its assign link..
So can anybody please tell me How can i have code for activity and service to solve this problem , I am student so i don't have much experience.
Also I am checking for internet if you are connected to internet than it parse the json otherwise it will show message but it only check once when you start your application So how can i check net connection background?
Thank you
You need to set up a Service to play music in background.
There is a sample project called RandomMusicPlayer embedded with the SDK which could help you a lot to achieve it. (In Eclipse: New Project > Android > Android Sample Project)
Move your player to the Service, bind it in activity a send commands from your activity, there is plenty tutorials for this.
Similar question
Service activity communication
Service media player
I want to play music in my app, that i can do. But the problem is how can i continue playing music even if the app is not in foreground. The musiv should stop only when the user select stop button, or pauses it.
Thanks,
Any help will be most appreciated.
You should use service to play music. Refer to this.
try using Services or Async Task
Try using a Service. That link gives a tutorial on how to use a background process. Hope this helps.
as the others said you could use Service
Or you could just make the song play in background thread, and make user back-key to back to their home screen via moveTaskToBack(true);