Question

I am working in an app with both recorder and player and it almost completed. In most of the devices Samsung,Motorolla, Sony the app is so stable and working perfectly. When i tried it in htc I came across a serious issue.

When the audio starts playing am updating it to the seekbar. This works perfectly in all other devices, but when it comes to htc(Desire HD, Android 2.3.3) the progess is moving faster and a lag there in mediaplayer playing. I serched a lot and read a lot of posts. Is audio latency a problem in Android 2.3.3 or its a problem of htc. Do any one have idea about this? Can any one help me with a good clarification?

Was it helpful?

Solution

Settting the progressbar max to 500 and implemting this timer will solve the problem. I tried and it worked for me

    InsideMMduration = mMediaPlayer.getDuration();
    amoungToupdate = InsideMMduration / 500;
    // TimerTask for updating the SeekBar while playing.
    task = new TimerTask() {
        @Override
        public void run() {
            Graphbar.post(new Runnable() {
                @Override
                public void run() {

                    if (mMediaPlayer != null) {
                        if (playButtonState == MediaMode.PLAY) {
                            if (mMediaPlayer.isPlaying()) {
                                if (!(amoungToupdate
                                        * Graphbar.getProgress() >= InsideMMduration)) {
                                    int tempP = Graphbar.getProgress();
                                    tempP += 1;
                                    Graphbar.setProgress(tempP);
                                    enableRewindandForward();
                                }

                            }
                        }
                    }
                }
            });
        }
    };
    timer = new Timer();
    timer.schedule(task, 0, amoungToupdate);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top