Hello everyone.
I've developed a class for asynchronous playback of MP3 files in memory. For example, this can be useful for playing background music from resources, or play from the network avoiding writing in the file. You can play multiple files at once, but some playback settings (volume, pan) for all players will be shared. This class is designed so that correctly handles the situation stop environment by buttons "Stop", "Pause" and exit on the End-statement. There is one restriction on the order of termination of objects. Because all objects use the same shared resource of a window and of a heap, then the destruction of objects must be in the order in which they were created, otherwise inevitable crashes. For one object no restriction. By tags: processed correctly only ID3v1 and ID3v2 tags, other tags are not recognized and the file is not likely to be played.
Methods:
Properties:
I've developed a class for asynchronous playback of MP3 files in memory. For example, this can be useful for playing background music from resources, or play from the network avoiding writing in the file. You can play multiple files at once, but some playback settings (volume, pan) for all players will be shared. This class is designed so that correctly handles the situation stop environment by buttons "Stop", "Pause" and exit on the End-statement. There is one restriction on the order of termination of objects. Because all objects use the same shared resource of a window and of a heap, then the destruction of objects must be in the order in which they were created, otherwise inevitable crashes. For one object no restriction. By tags: processed correctly only ID3v1 and ID3v2 tags, other tags are not recognized and the file is not likely to be played.
Methods:
- Initialize - initialize the player, the first parameter is a pointer to an MP3 file. The second parameter specifies the size of the data. The third parameter specifies whether you want to copy the file into an internal buffer inside the object and play the file from there;
- Play - starts playing, the parameter "looped" when first playing determines whether the file is played circularly;
- Pause - pauses playback, playback will start following the current position;
- StopPlaying - stops playback;
- SetPositionMs - sets the current playback position (ms);
- GetPositionMs - returns the current playback position (ms);
- GetDurationMs - returns the length of the file in milliseconds;
- GetBitrate - returns the bitrate at the time of playback (kbps);
- IsPlaying - determines whether a file is played;
Properties:
- Volume - sets / returns the current playback volume (0 ... 1);
- Pan - sets / returns the current panorama playback ((left channel) -1 ... 1 (right channel)).