# WavMuxer

Artifact: [androidx.media3:media3-muxer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/muxer/WavMuxer.java+class:androidx.media3.muxer.WavMuxer)

*** ** * ** ***

<br />

```
@UnstableApi
public final class WavMuxer implements Muxer
```

<br />

*** ** * ** ***

A muxer for creating a WAV container file.

This muxer supports muxing of `https://developer.android.com/reference/androidx/media3/common/MimeTypes#AUDIO_RAW()` with PCM encodings.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/muxer/WavMuxer#WavMuxer(androidx.media3.muxer.SeekableMuxerOutput)(https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput seekableMuxerOutput)` Creates an instance. |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/media3/muxer/WavMuxer#addMetadataEntry(androidx.media3.common.Metadata.Entry)(https://developer.android.com/reference/androidx/media3/common/Metadata.Entry metadataEntry)` Adds `https://developer.android.com/reference/androidx/media3/common/Metadata.Entry` about the output file. |
| `int` | `https://developer.android.com/reference/androidx/media3/muxer/WavMuxer#addTrack(androidx.media3.common.Format)(https://developer.android.com/reference/androidx/media3/common/Format format)` Adds a track of the given media format. |
| `void` | `https://developer.android.com/reference/androidx/media3/muxer/WavMuxer#close()()` Closes the file. |
| `void` | `https://developer.android.com/reference/androidx/media3/muxer/WavMuxer#writeSampleData(int,java.nio.ByteBuffer,androidx.media3.muxer.BufferInfo)( int trackId, https://developer.android.com/reference/java/nio/ByteBuffer.html byteBuffer, https://developer.android.com/reference/androidx/media3/muxer/BufferInfo bufferInfo )` Writes encoded sample data. |

### Inherited methods

From [java.lang.AutoCloseable](https://developer.android.com/reference/java/lang/AutoCloseable.html) `abstract void` `https://developer.android.com/reference/java/lang/AutoCloseable.html#close()()`

## Public constructors

### WavMuxer

```
public WavMuxer(SeekableMuxerOutput seekableMuxerOutput)
```

Creates an instance.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput seekableMuxerOutput` | The `https://developer.android.com/reference/androidx/media3/muxer/SeekableMuxerOutput` to write the media data to. It will be automatically `https://developer.android.com/reference/java/nio/channels/Channel.html#close()` by the muxer when `https://developer.android.com/reference/androidx/media3/muxer/WavMuxer#close()` is called. |

## Public methods

### addMetadataEntry

```
public void addMetadataEntry(Metadata.Entry metadataEntry)
```

Adds `https://developer.android.com/reference/androidx/media3/common/Metadata.Entry` about the output file.

### addTrack

```
public int addTrack(Format format)
```

Adds a track of the given media format.

All tracks must be added before any samples are written to any track.

Only a single audio track is supported.

### close

```
public void close()
```

Closes the file.

The muxer cannot be used anymore once this method returns.

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/muxer/MuxerException` | If the muxer fails to finish writing the output. |

### writeSampleData

```
public void writeSampleData(
    int trackId,
    ByteBuffer byteBuffer,
    BufferInfo bufferInfo
)
```

Writes encoded sample data.

The `bufferInfo` is ignored.

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/muxer/MuxerException` |   |