Class AudioExtractor
-
- All Implemented Interfaces:
public class AudioExtractor
Extracts audio from media files into EmbeddedAudioSource that is usable for creating SoundAnnotation.
Supported formats depend on the device (see https://developer.android.com/guide/topics/media/media-formats).
-
-
Constructor Summary
Constructors Constructor Description AudioExtractor(Context context, Uri contentUri)
Creates audio extractor for media file at contentUri
.
-
Method Summary
Modifier and Type Method Description int
getAudioTracksCount()
Number of audio tracks in the media file. long
getSelectedTrackDuration()
Returns selected track duration in milliseconds. synchronized void
selectAudioTrack(int audioTrackIndex)
Selects audio track for decoding. EmbeddedAudioSource
extractAudioTrack()
Extracts selected audio track as an EmbeddedAudioSource that can be set on . Single<EmbeddedAudioSource>
extractAudioTrackAsync()
Extracts selected audio track as an EmbeddedAudioSource that can be set on , asynchronously. -
-
Method Detail
-
getAudioTracksCount
int getAudioTracksCount()
Number of audio tracks in the media file.
- Returns:
Number of audio tracks in the media file.
-
getSelectedTrackDuration
long getSelectedTrackDuration()
Returns selected track duration in milliseconds.
- Returns:
Duration of the selected track in milliseconds or 0 if the duration could not be retrieved or no track has been selected via selectAudioTrack.
-
selectAudioTrack
synchronized void selectAudioTrack(int audioTrackIndex)
Selects audio track for decoding.
- Parameters:
audioTrackIndex
- Audio track index, must be >= 0 and smaller than getAudioTracksCount.
-
extractAudioTrack
@NonNull() EmbeddedAudioSource extractAudioTrack()
Extracts selected audio track as an EmbeddedAudioSource that can be set on . Defaults to decoding first audio track if track has not been selected via selectAudioTrack.
- Returns:
Decoded audio source.
-
extractAudioTrackAsync
@NonNull() Single<EmbeddedAudioSource> extractAudioTrackAsync()
Extracts selected audio track as an EmbeddedAudioSource that can be set on , asynchronously. Defaults to decoding first audio track if track has not been selected via selectAudioTrack.
- Returns:
Single emitting audio source with extracted track data or error if track could not be extracted.
-
-
-
-