Solved

CD Trackbar Fast Forward

Posted on 1998-09-04
4
259 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Mydac connection data base issue 3 157
indy Tmemory stream non latin charcter issue 2 110
Delphi 2 59
Firemonkey webbrowser scrollbars ? 1 38
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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

773 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