Skip to content

Latest commit

 

History

History
46 lines (31 loc) · 1.48 KB

README.md

File metadata and controls

46 lines (31 loc) · 1.48 KB

FlxPartialSound

Haxelib for haxeflixel for loading partial data from an audio file

Usage

// will load audio asset "assets/music/music.mp3" from bytes near 10% (0.1) of the audio lenght, 
// until the bytes around 50% (0.5) of the audio length
// which will return a Future<AudioBuffer>
var soundRequest = FlxPartialSound.partialLoadFromFile('assets/music/music.mp3', 0.1, 0.5);

// once it finishes loading, we can play it with flixel
soundRequest.onComplete(function(buffer:AudioBuffer)
{
	FlxG.sound.play(Sound.fromAudioBuffer(buffer));
});

Requires lime and flixel

TODO

See the Github Issues

Restrictions

Loading via percentage values

You need to load it via "percentage" values since:

  • Varying bitrates aren't supported, so it just gets the first "frame" of MP3 data it finds
  • sample rate also isn't supported yet.

So while it would be nice to supply it via milliseconds, that would require:

  • requesting the audio file
  • getting the file type (MP3 or OGG)
  • getting the sample rate data from the byte data
  • getting the bitrate data from the byte data

Further reading and research material