?
Solved

CD Trackbar Fast Forward

Posted on 1998-09-04
4
Medium Priority
?
264 Views
Last Modified: 2010-05-18
Hello,
How would i use a track bar to fast forward through a cd track. I would like to have a trackbar and when you move it it fast forwards porportionaly through the cd track.
Thanks  
0
Comment
Question by:spat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 5

Expert Comment

by:inter
ID: 1338662
Hi,
First place a TMediaPlayer on a form and adjust its setting(I am sure you have already done this). Then all we have to do is to be able to SEEK to a specified position. In this we should set our positioning system. i.e. we may measure the media as minutes, tracks, seconds etc...Here is a procedure for seeking specified track, minute,second(add MMSystem to your uses clause)

     procedure SeekToTrack(M : TMediaPlayer; Trac, Minute, Second: Byte);
          begin
           with M do
           if DeviceType = dtCDAudio then
           begin
             // we set the time to Track Minute Second Frame Format
             TimeFormat := tfTMSF;
             // This macro makes up a position from vars Frame is 0
             // for CDs
             Position := mci_Make_TMSF(Trac, Minute, Second,0);
           end;
          end;

This is a very general routine as you see...Just before playing we should measure the tracks and setup our trackbar accordingly as follows(you should set up and open MediaPlayer1 as properly before)

..
medialplayer1.TimeFormat := tfTMSF;
trackbar1.min := 0;
trackbar1.max := mci_TMSF_Track(mediaplayer1.endpos); //extract number of tracks
.
Now in trackbar1change method do the following:

procedure TForm1.trackbar1change(sender:tobject);
begin
  mediaplayer1.pause;
  seektotrack(mediaplayer1,trackbar1.position,0,0); //seek to begining of the track
  mediaplayer1.play;
end;

Regards, Igor
end;
0
 

Author Comment

by:spat
ID: 1338663
Hello again,
I could only get your code to seek from track to track. What i want it to do is to seek through the contents of an already playing track (going trom 2:45 to 2:50) using the track bar.
Thanks  
0
 
LVL 5

Accepted Solution

by:
inter earned 800 total points
ID: 1338664
Hi,
It is also easy man watch the following:

The media players tracklength array gives the length of tracks in specified units. So after seeking to a specified track as above we can setup our trackbar as follows:

// say you have your trackno in TrackNo
medialplayer1.TimeFormat := tfTMSF;
trackbar1.min := 0;
// express trackbar scale as seconds
with mediaplayer1 do
  trackbar1.max := mci_TMSF_Minute(tracklength(TrackNo))*60+ mci_TMSF_Second(tracklength(TrackNo));
//now we setup our track bar on the second basis

NOW IN THE TRACKBAR CHANGE CODE

 mediaplayer1.pause;
//seek to given TrackNo and minute second
 seektotrack(mediaplayer1,TrackNo,trackbar1.position div 60,trackbar.position mod 60,0);
 mediaplayer1.play;

Regards, Igor
0
 

Author Comment

by:spat
ID: 1338665
thank you this helped alot
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question