Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - How to mark timestamps on a SeekBar

I will be working on an app that records button presses, where I can play back that session on a SeekBar. Each event will be timestamped from the value of a Chronometer. When playing back, on each of those recorded events I will play a sound. That part shouldn't be a problem.

Now, what I would like to figure out is how I can mark the timestamps on the SeekBar by drawing red bars at the positions where each event occurred. I would like the red bars to be drawn prior to playback.

Since I haven't started this app yet, I don't have any code at this time.

like image 737
Pink Jazz Avatar asked Nov 01 '22 01:11

Pink Jazz


1 Answers

If I were to this, I would use the following procedures:

  1. Grab a handle to the seekbar view in my java code and save the width.
  2. The width represents your timescale starting at 0 to whenever the user stops acting on the view. Lets call that stop value T (seconds).
  3. After the recording completes, divide the width into seconds based on T.
  4. Each time stamp will map to an x-coordinate based on #3. Draw a red vertical line centered over that seekbar view at x. If you draw it on top, it might mess up seekbar interaction.

I know this isn't code but hopefully it will give you a good idea on how to solve this problem.

like image 137
Cookster Avatar answered Nov 11 '22 12:11

Cookster