Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

how to implement seekbar for music in java

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

how to implement 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);
    }
});
Comment

how to implement 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);
                }
            }
    });
Comment

PREVIOUS NEXT
Code Example
Java :: java write number with variable decimal 
Java :: nonnull annotation in java 
Java :: how to use asynx task to make api connection java 
Java :: data structure in java 
Java :: java function that returns the index of the largest value in an array 
Java :: spring boot thymeleaf bindingresult 
Java :: retrofit with api key post 
Java :: acceder a elementos de list java 
Java :: linearview 2 items next to each other 
Java :: date.settime java 
Java :: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type project and qualifiers [@Default] 
Java :: jbutton scroll list full width size 
Java :: install the app from assest of other app 
Java :: java program on stack for beginners 
Java :: java remove numbers from set 
Java :: java static nested class 
Java :: Scanner library showing element not found exception 
Java :: difference between string vs stringbuffer 
Java :: how to count an replace string in java 
Java :: How to convert Javascript return value to String in Android 
Java :: how to save rich text format in database using java 
Java :: java resultset.absolute 
Java :: cpp live code 
Java :: java Sum of all the factors of a number 
Java :: The Unit Circle Codehs 
Java :: rstudio boxplot coloring 
Java :: kano magic wand 
Java :: como detener un void java 
Java :: jframe open another frame using button actionlistener 
Java :: JAVA for-each Loop Sytnax 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =