BASS is really easy to use!

xiaoxiao2021-03-06  42

You can play your own file at will;

Below is an instance of playing files in Delphi7 with bass.dll.

(Like the classification title, you wrote a very dish, please include your pointing.)

Description:

To play a certain piece of data named WDF;

At the beginning of the offset OFFSET, read the size of the size to MemoryStream,

Then call Bass to play;

(This is currently the version of Bass, the old version did not tried, huh, huh)

Function bassmp3 (WDF: String; Offset, Size: longword; mem: boolean): boolean

Var fs: tfilestream;

f: pchar;

Volume: Integer;

P: POINTER;

Begin

Volume: = 40;

IF (MEM) THEN

Begin

BASS_FREE; // free first;

Freeandnil (MP3MS); // Freeandnil (MS);

Fs: = TfileStream.create (WDF, FMopenRead, FMSharedenynne);

fs.seek (offset, sofrombeginning);

Mp3ms: = TmemoryStream.create; // ms: = tmemorystream.create;

Mp3ms.copyfrom (fs, size); // ms.copyfrom (fs, size);

P: = mp3ms.memory; // p: = ms.memory;

Freeandnil (fs);

Bass_init (1,22050,0,0,0, nil); // if Bass_init (1,22050,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, nil) The logs ('init mariled');

BASS_SETVOLUME (Volume); // if Bass_setVolume (Volume) THEN LOGS (Format ('Volume Set to% D', [Volume])) Else LogMSG ('set volume failed ";

HBS: = Bass_StreamCreateFile (MEM, P, 0, SIZE, BASS_STREAM_AUTOFREE);

BASS_CHANNELPLAY (HBS, FALSE); // IF (BASS_CHANNELPLAY (HBS, FALSE)) The Logs ('Playing ...') Else Logs;

// While (bass_) Do Bass_ChannelPlay (HBS, FALSE);

end

END;

转载请注明原文地址:https://www.9cbs.com/read-56302.html

New Post(0)