public class AudioSwiftSession
extends java.lang.Object
Currently, this class is available for smart TVs only and supports only 16-bit, 48000 Hz, and dual-channel PCM data.
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
boolean |
close() |
Closes this
AudioSwiftSession instance to release audio resources. |
static AudioSwiftSession |
create(ohos.media.audio.AudioStreamInfo info) |
Creates an
AudioSwiftSession instance based on a specified AudioStreamInfo instance. |
AudioSwiftTrack |
getTrack() |
Obtains the
AudioSwiftTrack instance as the audio input track, which is used for PCM data writing. |
boolean |
open() |
Opens this
AudioSwiftSession instance and initializes audio resources. |
boolean |
start() |
Starts this
AudioSwiftSession instance. |
boolean |
stop() |
Stops this
AudioSwiftSession instance. |
protected boolean |
write(byte[] data,
int offset,
int size) |
Writes PCM data.
|
public static AudioSwiftSession create(ohos.media.audio.AudioStreamInfo info) throws java.lang.IllegalArgumentException
AudioSwiftSession instance based on a specified AudioStreamInfo instance.info - Indicates the AudioStreamInfo instance, which stores information
about the audio stream to play, such as the sampling rate, PCM type, and channels.AudioSwiftSession instance.java.lang.IllegalArgumentException - Throws this exception if info is invalid.public AudioSwiftTrack getTrack()
AudioSwiftTrack instance as the audio input track, which is used for PCM data writing.AudioSwiftTrack instance.public boolean open()
AudioSwiftSession instance and initializes audio resources.true if the operation is successful; returns false otherwise.public boolean start()
AudioSwiftSession instance. PCM data can be written only after the session is started.
true if the operation is successful; returns false otherwise.public boolean stop()
AudioSwiftSession instance. PCM data writing fails after the session is stopped.
You can write data again after calling start().
true if the operation is successful; returns false otherwise.public boolean close()
AudioSwiftSession instance to release audio resources.true if the operation is successful; returns false otherwise.protected boolean write(byte[] data,
int offset,
int size)
This method can be called only after the session is started by AudioSwiftSession#start().
Currently, only 16-bit, 48000 Hz, and dual-channel PCM data is supported.
data - Indicates the PCM data to write.offset - Indicates the offset (in bytes) where the data writing starts.size - Indicates the length (in bytes) of the PCM data to write.true if the operation is successful; returns false otherwise.