How to keep music playing in the background? - java

So I made a music streaming website streaming from YouTube the other day.
Now with WebView and the YouTube app I made the app 'native'.
Is there anyway to make the app not stop when you put your phone on standby , and maybe add music controller?

Related

How i can lock my exoplayer for prevent App quit when pop up appear

i have a problem with ExoPlayer , im using it for play hosted embed video , but i always have popup on my app and it make left the app , how i can lock the app on player and make not quit the app ? , im using android studio

how to detect if another app is playing audio

I am making a music player app and I want my app to stop music automatically when a video plays
and i am searching for a long time and I didn't find any thing

Is there any way in android through which i can play two audio at the same time in android ? one on my app and one on another background app

Is there any way in android through which i can play two audio at the same time in Android?
For example if a song is playing in background say on spotify and I have to play some audio in my app , then both should be played( maybe dimming spotify's audio) instead of pausing spotify ?
Normally what happens is if we play audio on one app , the other app's audio get's paused, how to make them play simultaneously.

How to add a music player to my app?

So I made a website someday, and now via webview and the YouTube Api I made it possible to listen to the music on my phone.
But... as soon as I close my app it stops playing the music.
How can I possibly add a music player and make it so the music keeps playing after the phone goes on standby mode?
Thank you very much!
Even thought I haven't deal with Youtube API for Android, I think that what you are trying to do is impossible. Even the Youtube App doesn't keep music playing after the phone goes on standby mode. That's their policy about music videos on Youtube.

how to work with a MediaPlayer perfectly in android

I am working in an online radio streaming project, where I am playing audio with mediaplayer from an URL. The music is playing and working fine. But I am stuck with the play,pause functionality regarding to the state of the player activity. I want such that when the app will be exited by home button press then music will keep playing, but when a phone call rings then the music will be paused and after the phon call the music will resume. And also when user opens another app then the music will continue playing in background. (as the default music player of android works)
But still what I did results almost my desired destiny, but something is missing, like I have started the music in onResume and stopped the music in onDestroy.By doing this the music keeps playing in background when I press home button, but when a phone call comes and recieved it continues playing which creates a disgusting situation, but when another app is turned on then the music goes off. How should I manage the MediaPlayer that will work like what I want? Any suggession?
Note: I am not using any service here, just an AsyncTask class to play the music.
The topic of MediaPlayer as background service is covered in multiple sources such as this one.
http://www.codeproject.com/Articles/258176/Adding-Background-Music-to-Android-App
You can also find this in the Android official documentation here
http://developer.android.com/guide/topics/media/mediaplayer.html
Hope that helps.

Categories