“Como implementar SeekBar for Music in Java” Respostas de código

Como implementar SeekBar for Music in Java

private Handler mHandler = new Handler();
//Make sure you update Seekbar on UI thread
MainActivity.this.runOnUiThread(new Runnable() {

    @Override
    public void run() {
        if(mMediaPlayer != null){
            int mCurrentPosition = mMediaPlayer.getCurrentPosition() / 1000;
            mSeekBar.setProgress(mCurrentPosition);
        }
        mHandler.postDelayed(this, 1000);
    }
});
Motionless Millipede

Como implementar SeekBar for Music in Java

mSeekBar.setMax(mFileDuration/1000); // where mFileDuration is mMediaPlayer.getDuration();
Motionless Millipede

Como implementar SeekBar for Music in Java

mSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {                
                if(mMediaPlayer != null && fromUser){
                    mMediaPlayer.seekTo(progress * 1000);
                }
            }
    });
Motionless Millipede

Respostas semelhantes a “Como implementar SeekBar for Music in Java”

Perguntas semelhantes a “Como implementar SeekBar for Music in Java”

Mais respostas relacionadas para “Como implementar SeekBar for Music in Java” em Java

Procure respostas de código populares por idioma

Procurar outros idiomas de código