Solved

CD Trackbar Fast Forward

Posted on 1998-09-04
4
252 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
  • 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 200 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now