Author Topic: Easy One (i hope)  (Read 3457 times)

fusion

  • Guest
Easy One (i hope)
« on: 1 Jul '03 - 05:48 »
Right now I am using a listbox to show a directory of songs and when one of them is dblclicked it begins to play that song and using the code below everything works fine when using the full pathname to the files but if I try to extract the filename part of the path and click on it then the song does not play so I was wondering how I could modify the below code so that it will work when using just the filename and not the complete path. BTW I am using delphi to code this project.

This is the code I am using on the listbox's dblclick event

Code: [Select]

Bass_StreamFree(strhand);
strhand := Bass_StreamCreateFile(FALSE, pChar(listbox1.Items.Strings[listbox1.ItemIndex]), 0, 0,BASS_MP3_SETPOS);
Bass_StreamPlay(strhand, FALSE, 0);

fusion

  • Guest
Re: Easy One (i hope)
« Reply #1 on: 1 Jul '03 - 05:53 »
nvm I figured it out

D5M

  • Guest
Re: Easy One (i hope)
« Reply #2 on: 1 Jul '03 - 06:26 »
Hi,,,

U must extract the Directory and extract the filename then in Listbox U
join of them.
its a simple....!!

U Extract to both in (listbox1.Items.Strings[listbox1.ItemIndex]).

where U Extract to both U use this code

var
ExFile, ExDir : String;
begin
..........
ExFile := ExtractFilename(listbox1.Items.Strings[listbox1.ItemIndex]).
ExDir := ExtractDirectory(listbox1.Items.Strings[listbox1.ItemIndex]).
..........
end;

Then on the listbox's dblclick event :=
....
strhand := Bass_StreamCreateFile(FALSE, pChar(ExDir +'\'+ ExFile), 0,
0,BASS_MP3_SETPOS);
.....

I hope this help....:-)


D5M

fusion

  • Guest
Re: Easy One (i hope)
« Reply #3 on: 1 Jul '03 - 06:33 »
Thx but as I said I figured it out like 10 seconds after I posted here is the code I used.

Code: [Select]

Bass_StreamFree(strhand);
strhand := Bass_StreamCreateFile(FALSE, pChar ('dirpath' + listbox1.Items.Strings[listbox1.ItemIndex]), 0, 0,BASS_MP3_SETPOS);
Bass_StreamPlay(strhand, FALSE, 0);


I just added the directory path to the code and concatated it with what I already had. I knew it was simple just my brain was not working at the moment when I posted :P