AudioAssetMedia class
Represents audio assets from the Flutter asset bundle.
Stores audio metadata including optional duration information. Supports conversion to file (by saving) and in-memory representation.
Example:
final audio = await AudioAssetMedia.load(
'assets/audio/song.mp3',
duration: Duration(minutes: 3, seconds: 45),
);
- Inheritance
-
- Object
- MediaSource<
AudioType> - AssetMediaSource<
AudioType> - AudioAssetMedia
Properties
- assetPath → String
-
The asset path in the Flutter asset bundle (e.g., 'assets/video.mp4').
finalinherited
- bundle → AssetBundle?
-
Optional custom asset bundle. If null, rootBundle is used.
finalinherited
- extension → String
-
Extracts the file extension from the name.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- metadata → AudioType
-
Metadata about the media type (e.g., VideoType, AudioType).
finalinherited
- mimeType → String?
-
The MIME type of the media, if available.
finalinherited
- name → String
-
The name or identifier of the media.
finalinherited
-
props
→ List<
Object?> -
Includes the asset path and bundle in equality comparisons.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → FileSize?
-
The size of the media, if known.
finalinherited
- stringify → bool?
-
If set to
true, thetoStringmethod will be overridden to output this instance'sprops.no setterinherited
Methods
-
convertToMemory(
) → Future< MemoryMediaSource< AudioType> > -
Converts this audio asset to an in-memory representation.
override
-
fold<
T> ({T file(FileMediaSource< AudioType> fileMedia)?, T memory(MemoryMediaSource<AudioType> memoryMedia)?, T network(NetworkMediaSource<AudioType> networkMedia)?, T asset(AssetMediaSource<AudioType> assetMedia)?, T thumbnail(ThumbnailMediaSource<AudioType, dynamic> thumbnailMedia)?, required T orElse()}) → T -
Performs pattern matching on media sources using a fold-like pattern.
inherited
-
isAnyType(
List< Type> list) → bool -
Checks if this media source's runtime type is in the given list.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
saveTo(
String path) → Future< AudioFileMedia> -
Saves this audio asset to the file system.
override
-
saveToFolder(
String folderPath) → Future< FileMediaSource< AudioType> > -
Saves this asset to a folder, preserving the original filename.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
load(
String assetPath, {AssetBundle? bundle, String? name, Duration? duration, String? mimeType, FileSize? size}) → Future< AudioAssetMedia> - Loads an audio asset from the Flutter asset bundle.