I try to implement a simple media player to play an audio stream from an external URL. Pretty simple I guess. Tried to implement this sample from Androïd dev site http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/media/MediaPlayerDemo_Audio.html
It works just fine with 2.1.
Then, with 2.2 it gets weird. Starts just well, but takes almost 10 seconds to stop.
With 2.3, it's not better. This time might take up to a minute to start playing, but stops OK.
Does anyone have a clue why ? I also did try the prepareAsync way with the listner, but it never get called. Any help would be appreciated at this point. Thanks !
Register setOnInfoListener() and control start buffering, end buffering and so on.
Look at the android documentation link
Related
I'm trying to make a radio app. Everything is ok, except playing radios. I'm getting play link from a page with Jsoup. When i press play, (in real device)it takes 40-50 seconds to start playing. But in genymotion device (Google Nexus 4- 4.4.4- API 19) it takes just 3-4 second. I couldn't find what is wrong.
I'm new on Android and I couldn't find a solution for days. Thanks id advance.
I really recommend you to use google exo player instead of default android player for streaming. its too fast and you will never have problems like this.
https://github.com/google/ExoPlayer
You must try it without emulator, as they themselves are slow.
Also give below links a read.
https://developer.android.com/reference/android/media/AudioManager.html
https://developer.android.com/guide/topics/media/mediaplayer.html
For Best performance native is good:
https://developer.android.com/ndk/guides/audio/index.html
So I have an app that plays a video.
And I have a time sync server for setting the datetime of the device. It seems that whenever I call SystemClock.setCurrentTimeMillis(millis) the video stops.
I am using android.media.MediaPlayer.MediaPlayer() object to play the video?
Has anyone else experienced this? I was planning on creating a watchdog thread that just monitors the current duration. But just wanted to know if anyone had come across this already?
Yes, I came across the same situation on some devices. Probably hardware libs use the system time clock in the in decoding or av sync implementation; it happens. Only solution on those devices was to stop/restart the MediaPlayer. But it probably depends on the implementation of the lower levels.
I'm having problems playing audio streaming. The application has been tested with differents APIs.
The media player in gingerbread(API 10) takes about 30-40 seconds on preparing state, however on API 7 takes only about 5-10 seconds on preparing state. Anyone know how to fix it?
I have looked in differents forums but don't get an answer.
Thanks in advanced.
The problem has to do with the fact that the buffering in Gingerbread is based upon fixed bytes rather than anything that has to do with the time it takes to play the stream. If the stream is low-fidelity, it will take a very long time to buffer. There is no fix other than to write your own streaming player.
Thanks. Find enclosed an example. ¿Could be ok to improve the performance?
http://blog.infidian.com/2009/12/27/android-streaming-mediaplayer-tutorial-updated-to-v1-5-cupcake/
I'm having problems with seeking video.
My application should resume video from place where it was stopped last time. So I do this:
videoView.seekTo(bookmark);
videoView.start(); However when it plays I hear sounds form beginning of video for about 1-2 sec. And only after that video seeks to the right position. This behavior is reproducible on HTC Nexus One, HTC G1, HTC evo. But on Samsung galaxy tab all plays normally. Anybody had similar problems? Is this bug HTC-specific? Thanks in advance.
It is definitely not specific to your phone. I am having the same issue on an HTC Incredible. The seekTo works but there is an audio glitch from the beginning of the clip. Based on the results trying to implement the custom VideoView I guess I won't go to the trouble. I am now going to see if I can mute the very beginning of the clip. I'll report back here if I succeed.
Well, I have given up on this. The only way I have found to mute the beginning of the clip is to mute the phone entirely, which would mute the background music as well. I will assume that this will be fixed sometime in the future since this is a known issue:
http://code.google.com/p/android/issues/detail?id=9135
Issue 9135: MediaPlayer/VideoView and SeekTo before initial playback starts from beginning for few millisecs
I guess that can be a reason:
from api doc
Although the asynchronuous seekTo(int) call returns right way, the actual seek operation may take a while to finish, especially for audio/video being streamed. When the actual seek operation completes, the internal player engine calls a user supplied OnSeekComplete.onSeekComplete() if an OnSeekCompleteListener has been registered beforehand via setOnSeekCompleteListener(OnSeekCompleteListener).
now Videoview does not have OnSeekCompleteListener exposed and it sucks, but Videoview is just a wrapper class for Mediaplayer and SurfaceView
This is a tough one :/
I'm making a music-based Android game a la Audiosurf. It works all nice except a few seconds before end of a song (that is being played with a normal MediaPlayer) the music stops aprubtly and the whole game (including UI) freezes for several seconds.
Each time that happens I see an "AudioHardware pcm playback is going to standby"-error in logcat.
Googling has led me to the conclusion that
this could be a HTC Hero specific issue (cannot be reproduced on emulator or other devices)
this message is normally logged when a http stream isn't fast enough for MediaPlayer
Audio in Android sucks in general
As I am decoding the mp3 with the NDK + libmpg123 for audio analysis already I might aswell just play the audio myself (using a very ugly interface between NDK C code and an AudioTrack in Java).
Is there a fix/workaround for this bug or should I really go that way? (I only have limited time left to complete this project)
I appreciate every hint!
You might be stopping the music when you've buffered it all in your C code. Since the AudioTrack has a delay in it, you may need to wait longer for it to finish.
I'd need more detail about your code to help, though.