Cannot get SeekBar to track down lenght of song while playing.

Search This thread
Mar 9, 2015
43
4
0
Denver
I cannot get seekbar to track down the length of the audio feed.
How can I get mediaplayer to track with the seekbar/scrobbler.


Code:
package com.example.root.ilanthium;
import android.os.Bundle;
import android.widget.SeekBar;

public class SeekBarActivity extends MainActivity {
 [user=439709]@override[/user]
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.file_activity);
        SeekBar seekBar = (SeekBar) findViewById(R.id.seek);

        seekBar.setMax(mp.getDuration());

        seekBar.setOnSeekBarChangeListener(new android.widget.SeekBar.OnSeekBarChangeListener() {
 [user=439709]@override[/user]
            public void onProgressChanged(android.widget.SeekBar seekBar, int progress, boolean fromUser) {
                if(fromUser) {
                    seekBar.setProgress(progress);
                    mp.seekTo(progress);
                }
            }

 [user=439709]@override[/user]
            public void onStartTrackingTouch(android.widget.SeekBar seekBar) {

            }

 [user=439709]@override[/user]
            public void onStopTrackingTouch(android.widget.SeekBar seekBar) {

            }
        });
    }


}
 
Last edited:
Mar 9, 2015
43
4
0
Denver
I cannot get seekbar to track down the length of the audio feed.
How can I get mediaplayer to track with the seekbar/scrobbler.


Code:
package com.example.root.ilanthium;
import android.os.Bundle;
import android.widget.SeekBar;

public class SeekBarActivity extends MainActivity {
 [user=439709]@override[/user]
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.file_activity);
        SeekBar seekBar = (SeekBar) findViewById(R.id.seek);

        seekBar.setMax(mp.getDuration());

        seekBar.setOnSeekBarChangeListener(new android.widget.SeekBar.OnSeekBarChangeListener() {
 [user=439709]@override[/user]
            public void onProgressChanged(android.widget.SeekBar seekBar, int progress, boolean fromUser) {
                if(fromUser) {
                    seekBar.setProgress(progress);
                    mp.seekTo(progress);
                }
            }

 [user=439709]@override[/user]
            public void onStartTrackingTouch(android.widget.SeekBar seekBar) {

            }

 [user=439709]@override[/user]
            public void onStopTrackingTouch(android.widget.SeekBar seekBar) {

            }
        });
    }


}





SEE THIS THREAD
https://stackoverflow.com/questions...a-player-seekbar-not-seeking-through-songfile

This issue has been solved.