hertzhound_io library
File helpers for dart:io platforms (Flutter on Android, iOS, macOS,
Windows and Linux; Dart servers and CLIs).
- sniffFile and sniffFileSync identify a file on disk, reading only the bytes the parsers need.
- PlaybackAliases gives a mislabelled file a correctly named copy for players that choose a demuxer from the extension.
Everything in package:hertzhound/hertzhound.dart is
re-exported, so one import is enough.
Classes
- AudioProbe
- What a file's bytes say it is.
- PlaybackAliases
-
Correctly named copies of mislabelled audio files, for players that pick
a demuxer from the file extension (ExoPlayer and AVPlayer both do, and
just_audiooffers no way to override it for a local file). - PlaybackFile
- The path to hand a player, and whether it is a copy owned by PlaybackAliases.
Enums
- AliasOutcome
- What PlaybackAliases.prepare did.
- AudioFormat
- An audio container, identified from the bytes rather than from a name.
- DurationAccuracy
- How far a AudioProbe.duration can be trusted.
- ProbeNote
- Something worth knowing about how a file was read.
Functions
-
extensionOf(
String nameOrPath) → String? -
The lowercase extension of
nameOrPathwithout the dot, or null when it has none. -
sniffBytes(
List< int> bytes, {int? fileLength}) → AudioProbe -
Identifies the audio in
bytesand reads its duration from the header. -
sniffFile(
String path) → Future< AudioProbe> -
Identifies the audio file at
path, reading only the bytes the parsers need (usually a few KiB, never more than a few MiB however the file is built). -
sniffFileSync(
String path) → AudioProbe - Synchronous sniffFile.
-
sniffReader(
ReadAt readAt, {int? length}) → Future< AudioProbe> - Like sniffReaderSync, for an asynchronous source such as a file opened for random access or a server that honours HTTP range requests.
-
sniffReaderSync(
ReadAtSync readAt, {required int? length}) → AudioProbe -
Like sniffBytes, but reads through
readAtso only the bytes each parser needs are touched.lengthis the total size, or null when it is unknown. -
sniffStream(
Stream< List< stream, {int? length, int maxBytes = 1024 * 1024}) → Future<int> >AudioProbe> -
Identifies the audio at the start of
stream, reading at mostmaxBytes, then cancels the subscription.
Typedefs
-
ReadAt
= Future<
List< Function(int offset, int length)int> > -
Reads up to
lengthbytes atoffset, asynchronously: a seek in a file, an HTTP range request, a blob slice. May complete with fewer bytes, or none, at the end of the data. -
ReadAtSync
= List<
int> Function(int offset, int length) -
Reads up to
lengthbytes atoffset, synchronously. May return fewer bytes, or none, at the end of the data. Must not throw for an offset past the end.