Android :: Mediaplayer - Stop Button And That Stops Audio From Playing
Nov 18, 2009
I have a activity which is called from another activity as an intent... This activity loads and starts playing a audio file. All is good - that much works. The activity also has a "stop" button and that stops the audio from playing - that is also fine.
But how do I stop the file from playing if the user uses the back button to leave the activity without clicking on the "Stop" button?
View 3 Replies
Apr 23, 2010
I am maintaining a streaming music player, and I'm running into a similar problem as http://www.last.fm/group/Last.fm+Android/forum/114391/_/593575
My player stop after roughly 1-2 minutes, and there are no log messages except for "I/AudioHardwareQSD( 52): AudioHardware pcm playback is going to standby" just after the playback stops.
This happens when I run it on the Nexus One over 3G. It does not happen over Wifi, and it does not happen on my HTC Hero with android 1.5 over 3G.
Do you guys have any hints on how to debug this? Is it e.g. possible to monitor the memory available to the media player object?
View 5 Replies
View Related
Nov 27, 2009
I am trying to make a very simple radio player for Android and I cannot get the audio streaming to work. In my latest attempt it plays for about 1 second and stops for some streams and it doesnt work at all for some other streams. Logcat doesn't give much useful information to me. I am testing on HTC Hero (Android 1.5).
If I hook the completion and buffer events I see the audio gets a complete event but it keeps buffering. Is there anything wrong with the code below? Should I be able to stream the the audio streams below? Is there a complete example somewhere of a working radio streaming?................
View 5 Replies
View Related
Aug 21, 2010
Invoked device native player to play audio file, it opens android native player on top of the application but when selecting to back out or return to the application, device automatically stops playing the current media.
Sample code:
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file),"audio/*");
startActivity(intent);
How can I implement so that Device should continue to play audio in the background when selecting to back out or return to the application
View 1 Replies
View Related
Oct 12, 2010
I have Acvtivity that creates view and mediaplayer. I want to use OnCompletion event to make that view clickable. But it throws exception, I don't know why. Probably, mediaplayer runs in another thread and cannot access elements from main ui thread?
View 1 Replies
View Related
Jan 6, 2010
Why does my MediaPlayer
MediaPlayer mp = MediaPlayer.create(this, R.raw.somemusic); mp.setLooping(true); mp.start();
stop, wenn I change the layout?
setContentView(R.layout.screenoptions);
and also suddenly in my game, the sound stops. What could be the reason?
And which one is better? MediaPlayer or SoundPool?
View 2 Replies
View Related
Aug 9, 2010
I have followed the steps to create my media player object but I cant understand why it is not playing the music track. I used the following code...
but no sound is playing through the emulator, and furthermore when i check the method mp.isPlaying() it returns false. What have I missed?
View 2 Replies
View Related
Oct 31, 2010
How do I get the default ringtone to play? I've tried using SoundPool (preferred method) and MediaPlayer to play it but I'm getting nowhere. I've done so many dumb things, I'll just include the last fail. In the following snippet: String ringtone = Settings.System.DEFAULT_RINGTONE_URI.getPath(); SoundPool ringPhone = new SoundPool(1, AudioManager.STREAM_RING, 0); int soundID = ringPhone.load Settings.System.DEFAULT_RINGTONE_URI.getPath(), 1); ringPhone.play(soundID, 0.99f, 0.99f, 1, 0, 1.0f);
loads but plays nothing. When I display Settings.System.DEFAULT_RINGTONE_URI.getPath(), it's returning /system/ ringtone
View 2 Replies
View Related
Jul 19, 2010
is there a way to find the 'noise produced' by a currently playing sound (MediaPlayer) -Like in many music editor software you import a song and it does a graphical layout of the song -like a graph with it higher up at louder bits. Hard to explain. But there must be a way to do this on android...
View 1 Replies
View Related
Jul 16, 2010
Getting reports that mp3 files <= 0.34 secs in length, are not played (or, at least, inaudible) on the Droid X. Works fine on other devices I've tried (e.g. Nexus One, Hero, G1)
All files longer than 0.34 secs are working fine. I've tested this with about 100 files (mixture of short and long) and the correlation is 100%.
View 4 Replies
View Related
Dec 27, 2009
I've been trying to stream mp3's over http using Android's built in MediaPlayer class. The documentation would suggest to me that this should be as easy as :
MediaPlayer mp = new MediaPlayer();
mp.setDataSource(URL_OF_FILE);
mp.prepare();
mp.start();
However I am getting the following repeatedly. I have tried different URLs as well. Please don't tell me that streaming doesn't work on mp3's.
E/PlayerDriver( 31): Command PLAYER_SET_DATA_SOURCE completed with an error or info PVMFErrNotSupported
W/PlayerDriver( 31): PVMFInfoErrorHandlingComplete
E/MediaPlayer( 198): error (1, -4)
E/MediaPlayer( 198): start called in state 0
E/MediaPlayer( 198): error (-38, 0)
E/MediaPlayer( 198): Error (1,-4)
E/MediaPlayer( 198): Error (-38,0)
View 8 Replies
View Related
Apr 27, 2010
Does anyone know the filepath for an Archos? I'm trying to get some media/audio to play, and it just won't find it...
public void onClick(View v1) {
final MediaPlayer mp = new MediaPlayer();
try {
mp.setDataSource("ARCHOS5:/Music/manowar.mp3");
mp.start();
Toast.makeText(Textbox.this, "Working", Toast.LENGTH_LONG).show();
mp.setLooping(true);
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();............................
View 1 Replies
View Related
Jul 21, 2009
I develop a music play app, whe app framework is:
list.java->play.java
eg: in the list.java there have two mp3 files : 1.mp3,2.mp3 when first time choose 1.mp3, then play ok, then back to list.java from play.java, and now the 1.mp3 is still playing, and then i click 2.mp3 in the list.java, and go to play.java, but it play 1.mp3 and 2.mp3 simultaneously? but i have used the mediaplayer.stop(); mediaplayer.release(); and it always play 1.mp3 and 2.mp3 simultaneously? i want stop 1.mp3 and play 2.mp3.
View 7 Replies
View Related
Sep 17, 2010
My android app creates a MediaPlayer() and plays a looping song. I need to have it stop playing when the user leaves the app. I also need to get at the volume buttons somehow, to let users adjust the songs volume...
CODE:..................
View 1 Replies
View Related
Nov 8, 2010
In my music app, i would like to play live streaming like radio broadcasting with mediaplayer as Mediaplayer mp = new Mediaplayer(); mp.setDataSource(LiveStreamingURL); mp.prepare(); mp.start(); but after playing for few seconds it is stopped. I dont know how to overcome it. Give me your suggestions for this.
View 3 Replies
View Related
Feb 8, 2010
I want to create an Android application that is a client for an Internet radio station. And I want it look native to Android? But im confused with Android API logic and documentation. What i've got is that I need MediaPlayer and MediaController classes. Am I right, and is there any good example of AUDIO player for Android?
Especially, I'm very interested how to use MediaPlayer and MediaController classes together.
UPD:
Finally I've got the code, that does exactly what I want:
CODE:..............
View 1 Replies
View Related
Aug 21, 2010
I'm trying to create a way to adjust volume settings for each of the different streams (media, notification, ringtone, etc) and have a way to preview the output sound level of each stream. I believe I have the correct implementation, but when I set the output stream type, there is no sound that plays.
Here is the code that correctly plays the user's selected alarm sound:
CODE:.................
That commented out line is what is causing me problems. I would like to hear the alarm sound at the volume levels of the different audio streams, but when I include that line for STREAM_ALARM or any other audio stream, no sound at all plays.
View 1 Replies
View Related
Apr 8, 2009
Some audio files return 0 from MediaPlayer.getDuration(), even though they're perfectly valid files that play ok and that players on Windows can find the duration of. There seem to be two different cases here: certain file types such as .wma and .wav always return 0 duration, and others only do so sometimes. I haven't been able to find any pattern in the latter case, but it does seem consistent per file. The music player displays 0:00 duration for these, so it's not just my code.
View 3 Replies
View Related
May 27, 2010
I am having the following problem: I am using Android's MediaPlayer to play an mp3 through an HTTP connection. The audio is played correctly, but the MediaPlayer returns an incorrect duration (calling mediaPlayer.getDuration() ). Depending on the mp3 the duration is either shorter or longer. The code that plays the audio is the following:
mediaPlayer = new MediaPlayer(); mediaPlayer.setOnCompletionListener(this); mediaPlayer.setOnErrorListener(this); mediaPlayer.setOnPreparedListener(this); mediaPlayer.setOnBufferingUpdateListener(this); mediaPlayer.setDataSource("a valid URL"); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mediaPlayer.prepareAsync();............................
View 2 Replies
View Related
Oct 13, 2009
Is it now possible mit sdk1.6 the audio decoder to access/use without using MediaPlayer ?
I saw : New version of OpenCore
Android 1.6 includes the updated OpenCore 2 media engine, which has:
* Support for OpenMAX encoders* Support for additional audio codecs in AuthorEngine* Improved buffering model supports shared buffers allocated in the decoder. but dont know how!
View 3 Replies
View Related
Nov 20, 2009
I know other Hero users are having the same problem, and so far Slacker support has not fixed. One the screen sleeps it will finish the current song but not play a next song until you unlock the screen. I even have an app that keeps the screen from locking but allows it to go black and that causes the same issue. Anyone have a suggestion? This makes it where I can only use Slacker with the screen on which make the app almost worthless.
View 1 Replies
View Related
Feb 16, 2010
Can anyone tell me how to stop media player that was started in a previous activity?For ex. In activity-1 button pressed that did - mp.start(); then activity-2 starts for different layout with new buttons, then when button pressed, mp.stop is called, but does not stop the media from the first activity.
View 4 Replies
View Related
Jun 3, 2010
I'm playing around with the MediaPlayer class to reproduce some sounds/music. I am playing raw resources (res/raw) and it looks kind of easy.
To play a raw resource, the MediaPlayer has to be initialized like this:
CODE:.................
Until here there is no problem. The sound is played, and everything works fine. My problem appears when I want to add more options to my application. Specifically when I add the "Stop" button/option.
Basically, what I want to do is...when I press "Stop", the music stops. And when I press "Start", the song/sound starts over. (pretty basic!)
To stop the media player, you only have to call stop(). But to play the sound again, the media player has to be reseted and prepared.
CODE:...............
The problem is that the method setDataSource() only accepts as params a file path, Content Provider URI, streaming media URL path, or File Descriptor.
So, since this method doesn't accept a resource identifier, I don't know how to set the data source in order to call prepare(). In addition, I don't understand why you can't use a Resouce identifier to set the data source, but you can use a resource identifier when initializing the MediaPlayer.
I guess that I'm missing something. I wonder if I am mixing concepts, and the method stop() doesn't have to be called in the "Stop" button.
View 4 Replies
View Related
Aug 22, 2010
I see calling the stop function of MediaPlayer simply does nothing. The playback goes on.
I looked in the documentation and I found: "Stops playback after playback has been stopped or paused."
So, I tried to pause() it before stopping, but the MediaPlayer then pauses and resumes the playback. The only thing I can see is that the buffering stops. But the playback continues. Is this the expected behavior? Could the problem be related to the fact that I call the methods of the MediaPlayer object from different threads than the creator by synchronizing with Semaphores?
View 6 Replies
View Related
May 3, 2010
For those of you using Pandora have you experienced an issue that after two to three songs Pandora just stops playing as long as your phone is stationary. If you have a phone and use Pandora can you do a test that you turn up Pandora put it down on the table and let it play for at least three songs and let me know if you have an issue. Now it needs to be on the network and not WIFI and the phone MUST be stationary.
View 24 Replies
View Related
Jun 16, 2009
I have the following native source code that is supposed to display video. It plays 3gp file ok and I can hear the audio, but the video is not shown.
CODE:..............
View 4 Replies
View Related
Aug 1, 2010
When I am listening to the music app, or btunes, or mix zing; about one in four times I turn the screen off, the music stops playing. I've tried turning of my task killer, but to no avail. At first, I had a second issue as well: the music would play for only about 15 mins then stop, however, I managed to figure out that that was the 'Data-Off' timer I had set for the battery's 'Smart Mode' (though I'm not sure what data has to do with playing music stored locally). Nevertheless, swapping to 'Performance Mode' solved that. But for the life of me, I cannot figure out why a quarter of the time I turn the screen off, it kills the music.
View 2 Replies
View Related
Jun 15, 2010
So I was doing a bunch of tricks for the battery and now when ever my phone locks pandora will not play until I unlock it again.. Any Ideas? Seems like some setting I turned off doesn't allow data to flow when its locked or something.
View 4 Replies
View Related
Sep 20, 2010
Just installed froyo on my T-Mobile Desire, and have been using flash to watch iplayer stuff. The problem is, if you want to listen to iplayer radio it stops playing when the screen is turned off, or if you switch to a different window. This is obviously to stop flash playing when its not used, but is there a way to maybe add Safe websites, or just turn that function off completely.
View 1 Replies
View Related
Jul 16, 2010
This doesn't always happen but when it does, Slacker stops playing after every 2 or so songs. I get a message box that reads "Warning! Unable to find active data or WiFi connection. Would you like to quit the application?" and gives me Yes or No options. Clicking No returns me to the Stations list where selecting any station returns me to the one previously playing and starts the next song when I hit Play.
View 4 Replies
View Related