not sure if this is possible, I have an icecast server configured and streaming music, and I want to create a web player using Java (or grails). I managed to get the java web app playing the music icecast is streaming, using something like this:
AudioInputStream stream = AudioSystem.getAudioInputStream(new URL("http://localhost:8000/musicstation"))
and after a few more lines the music is playing, the problem is that if I close the tab with the web app the music keeps playing, I have to stop the application to stop playing, but when I start it again and try to play again, it's like the icecast server continued playing the song in the background, I mean, it didn't stop or paused, because of this I cannot implement a pause action, since if I pause, what it actually be paused will be the web app playing the song, but in the background icecast will continue transmitting the song, so that when I play again after paused, the song won't continue from the point it was paused.
Is using AudioInputStream the correct way to implement an icecast audio client?
I hope I could explain myself.
thanks
Icecast obviously continues to "play", since it is a live streaming server. If you want to implement a pause mechanism, you need to buffer what you get from Icecast and play the buffer.
Related
In my app, I would like to play audio. As long as my app is actively running, no other audio from any other apps should be played. I.e. no push audio notifications (e.g. WhatsApp), no call ringtones, no SMS, or anything else. Only my app should be able to play unmuted audio.
So whenever my app is running, the whole OS and the background apps should be muted, even if my app is currently not playing any audio. Is that possible?
I have a VideoView without any audio playing every time I start my app. I have noticed that when it starts playing, music playing from other apps in the background pauses. Is there any solution to this? Thank you!
Playing video while background music playing is not recommended:
To ensure a great user experience, it’s also important that your app manages the audio focus to ensure multiple apps aren’t playing audio at the same time.
You can check this for more information.
When you start play video using VideoView, you app request the audio focus, this mean the background app which is playing music lose the audio focus. The background app's behavior depends on the code in AudioManager.OnAudioFocusChangeListener.OnAudioFocusChangeListener method. You can not change it.
More information, see Managing Audio Focus.
As far as I know, with the YouTube API for Android, the player automatically stops when it's out of view. For example, when the app is closed or when another view is positioned on top of the player.
But I've seen this application: https://play.google.com/store/apps/details?id=com.mixerbox.mixerbox that seems to have found a workaround for this. In this app, when you close it, the video doesn't stops and continues playing in the background.
Anyone know how this can be achieved?
To play only the audio of a YouTube video violates the YouTube API Terms of Service:
Your API Client will not, and You will not encourage or create functionality for Your users or other third parties to:
9. promote separately the audio or video components of any YouTube audiovisual content made available through the YouTube API;
For educational purposes take a look at the Services developer guide.
A Service is an application component that can perform long-running operations in the background and does not provide a user interface. Another application component can start a service and it will continue to run in the background even if the user switches to another application. Additionally, a component can bind to a service to interact with it and even perform interprocess communication (IPC). For example, a service might handle network transactions, play music, perform file I/O, or interact with a content provider, all from the background
The MixerBox app you mention most likely has a Service that it delegates the play back of the video's audio to when its' Activity's onPause() callback is executed by the system. That is how MixerBox allows you to navigate away from the application and you can still here the audio playing from the video.
In my application I am doing live audio streaming using Android media player. I want to capture the sound stream played by MediaPlayer. Is there is way to record using Android MediaPlayer instead of MediaRecorder? Any suggestions?
While it is a non-trivial undertaking, you can write your own "MediaPlayer" that implements whatever streaming protocol you are using and writes the stream to a file instead of the speaker.
I have searched, but can not find the answer I'm looking for.
I want to create a service and be able to call a function to play an audio file.
I have 5 different intents that will be using the service to play 5 different audio files (one each) and I have a stop button in each one. Whichever stop button is pressed I want it to stop all audio that has been called from the service.
Does any one have an example code which I can use? (Something close to what I'm looking for.)
I'm building a media player to understand how Android works, and I have a service that queues audio files to play them. You can get the full source code from github.
The service is in /src/com/augusto/mymediaplayer/services
I'm not using Intens, but binding the service to the Activities that use it, but changing it to receive intents shouldn't be that hard. Just in case, this service runs ok on Android 1.6+.
I think that to change it to receive intents, you'll need to change onStart() and do a switch on the intent.
I know that this doesn't answer your question 100% but it's a place to start :).