Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6114537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:59:10+00:00 2026-05-23T14:59:10+00:00

I currently have a media player that is streaming a mp3. I have a

  • 0

I currently have a media player that is streaming a mp3. I have a seekbar, hwoever, it is not working. I have tried it with an actual raw file and that seems to work. I think the seekbar is not getting the duration of the song. any ideas?

Code:

public class SeekMe extends Activity implements Runnable{
    /** Called when the activity is first created. */
    MediaPlayer mp; 
    Button playButton;
    Button stopButton;
    SeekBar seekMe; 
    int total;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    playButton = (Button)findViewById(R.id.play);
    stopButton = (Button)findViewById(R.id.stop);
    seekMe = (SeekBar)findViewById(R.id.seekBar1);

    final MediaPlayer mp = new MediaPlayer();

    try {
        mp.setDataSource("http://dl.dropbox.com/u/24535120/Week%20of%20May%201/Swanky%20Tunes%20%26%20Hard%20Rock%20Sofa%20-%20Smolengrad%20%28Original%20Mix%29.mp3");
        mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
        mp.prepareAsync();
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    mp.setOnPreparedListener(new OnPreparedListener(){

        @Override
        public void onPrepared(MediaPlayer arg0) {
            // TODO Auto-generated method stub
            total = mp.getDuration();
        }

    });

    seekMe.setProgress(0);


    playButton.setOnClickListener(new OnClickListener(){

        @Override
        public void onClick(View arg0) {
            mp.start();
            seekMe.setMax(total);

        }

    });

    stopButton.setOnClickListener(new OnClickListener(){

        @Override
        public void onClick(View arg0){
            mp.pause();
        }
    });

    seekMe.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress,
                boolean fromUser) {
            // TODO Auto-generated method stub

            if(fromUser){
                mp.seekTo(progress);
                seekMe.setProgress(progress);
            }

        }
    });

    Thread currentThread = new Thread(this);
    currentThread.start();


}

@Override
public void run() {
    // TODO Auto-generated method stub

    try{
        while(mp != null){
            int currentPosition = mp.getCurrentPosition();
            Message msg = new Message();
            msg.what = currentPosition;
            threadHandler.sendMessage(msg);
        }
        Thread.sleep(100);
    }catch (InterruptedException e){
        e.printStackTrace();
    }
}

private Handler threadHandler = new Handler(){
    public void handleMessage(Message msg){
        seekMe.setProgress(msg.what);
    }
};

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:59:11+00:00Added an answer on May 23, 2026 at 2:59 pm

    Have you tried calling the default music player with the url of the mp3 file?

    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setDataAndType(Uri.parse(url), "audio/*");
    context.startActivity(i);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently have a media player that is streaming an mp3 file. When that
I currently developed a media player using directshow.net. The videos have a small timestamp
I currently have a set of media files in the raw folder of the
I'm working on a website that hosts music, pictures, and videos. I currently have
I have a generalized media player web app that I wish to be able
I currently have a streaming mediaplayer that runs in a service . Whenever I
If I have an mp3 file in the raw folder of res called twelve_chimes.mp3
I have a simple ASP.NET page that uses the VLC media player to play
I’m working on a media player app that will play music in the background
I have a cd , dvd. book media program. Currently, i am trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.