human: 如何处理七牛云的实时音视频QNLocalAudioTrack

gpt: [实时音视频](https://developer.qiniu.com/rtc) > API 文档 > Android >QNLocalAudioTrack

#  QNLocalAudioTrack

最近更新时间: 2023-10-25 15:08:20

本地音频 Track 基类

Hierarchy

  * [QNTrack](https://developer.qiniu.com/rtc/8660/QNLocalAudioTrack/8693/QNTrack)
    * [QNLocalTrack](https://developer.qiniu.com/rtc/8660/QNLocalAudioTrack/8662/QNLocalTrack)
      * [QNLocalVideoTrack](https://developer.qiniu.com/rtc/8660/QNLocalAudioTrack/8663/QNLocalVideoTrack)
        * [QNCameraVideoTrack](https://developer.qiniu.com/rtc/8660/QNLocalAudioTrack/8640/QNCameraVideoTrack)
        * [QNScreenVideoTrack](https://developer.qiniu.com/rtc/8660/QNLocalAudioTrack/8687/QNScreenVideoTrack)
        * [QNCustomVideoTrack](https://developer.qiniu.com/rtc/8660/QNLocalAudioTrack/8649/QNCustomVideoTrack)
      * QNLocalAudioTrack 
        * [QNMicrophoneAudioTrack](https://developer.qiniu.com/rtc/8660/QNLocalAudioTrack/8667/QNMicrophoneAudioTrack)
        * [QNCustomAudioTrack](https://developer.qiniu.com/rtc/8660/QNLocalAudioTrack/8646/QNCustomAudioTrack)
    * [QNRemoteTrack](https://developer.qiniu.com/rtc/8660/QNLocalAudioTrack/8676/QNRemoteTrack)
      * [QNRemoteVideoTrack](https://developer.qiniu.com/rtc/8660/QNLocalAudioTrack/8680/QNRemoteVideoTrack)
      * [QNRemoteAudioTrack](https://developer.qiniu.com/rtc/8660/QNLocalAudioTrack/8674/QNRemoteAudioTrack)

Index

Core Methods

  * getTrackID
  * getUserID
  * getTag
  * isAudio
  * isVideo
  * isMuted
  * setMuted
  * destroy
  * setVolume
  * getVolumeLevel
  * setAudioFrameListener
  * addAudioFilter
  * removeAudioFilter

Core Methods

getTrackID

  * String getTrackID()
  * 获取 TrackID，仅当发布成功后，才可以获取到有效的 TrackID

Returns String

getUserID

  * String getUserID()
  * 获取 UserID

Returns String

getTag

  * String getTag()
  * 获取 Tag

Returns String

isAudio

  * boolean isAudio()
  * 是否为音频 Track

Returns boolean

isVideo

  * boolean isVideo()
  * 是否为视频 Track

Returns boolean

isMuted

  * boolean isMuted()
  * 该 Track 是否处于静默状态

Returns boolean

setMuted

  * void setMuted(boolean muted)
  * 设置是否静默该 track，静默后，SDK 将会发送静默帧数据

当静默状态改变后，远端用户将会收到
[QNTrackInfoChangedListener.onMuteStateChanged](https://developer.qiniu.com/rtc/8660/QNLocalAudioTrack/8820)
的回调

Parameters

    * muted: boolean 

是否静默

destroy

  * void destroy()
  * 销毁本地创建的 Track

setVolume

  * void setVolume(double volume)
  * 设置当前音频输入设备采集的音量大小

> 音量值在 0.0 - 1.0 之间为软件缩小；1.0 为原始音量；大于 1.0 且小于 10.0 为软件放大
>
> 在需要放大时，应从 1.x 开始设置，用最小的放大值来取得合适的播放效果，过大将会导致音频音调异常
>
> 该设置可以用于适度对采集音量做放大或者缩小

Parameters

    * volume: double 

采集音量大小，[0.0 - 10.0]，默认值为 1.0

getVolumeLevel

  * float getVolumeLevel()
  * 获取当前音频输入设备采集的音量大小

> 可通过定时调用该方法获取音量值的方式来判断当前用户是否在讲话
>
> 在安静的环境下，获取到 0.0x 大小的数值为预期现象，您可根据您的需求自行决定判断的阈值

Returns float

setAudioFrameListener

  * void setAudioFrameListener([QNAudioFrameListener](https://developer.qiniu.com/rtc/8660/QNLocalAudioTrack/8630/QNAudioFrameListener) listener)
  * 设置音频数据监听

Parameters

    * listener: QNAudioFrameListener 

音频数据监听接口

addAudioFilter

  * boolean addAudioFilter(QNAudioFilter filter)
  * 设置音频处理器

>
> 可通过该接口添加音乐混音控制器([QNAudioMusicMixer](https://developer.qiniu.com/rtc/8660/QNLocalAudioTrack/11921/QNAudioMusicMixer))、音效混音控制器([QNAudioEffectMixer](https://developer.qiniu.com/rtc/8660/QNLocalAudioTrack/11923/QNAudioEffectMixer))和音源混音控制器([QNAudioSourceMixer](https://developer.qiniu.com/rtc/8660/QNLocalAudioTrack/12212/QNAudioSourceMixer))

Parameters

    * filter: QNAudioFilter 

音频处理器

Returns 添加成功返回 true，失败返回 false

removeAudioFilter

  * boolean removeAudioFilter(QNAudioFilter filter)
  * 移除音频处理器

>
> 可通过该接口移除音乐混音控制器([QNAudioMusicMixer](https://developer.qiniu.com/rtc/8660/QNLocalAudioTrack/11921/QNAudioMusicMixer))、音效混音控制器([QNAudioEffectMixer](https://developer.qiniu.com/rtc/8660/QNLocalAudioTrack/11923/QNAudioEffectMixer))和音源混音控制器([QNAudioSourceMixer](https://developer.qiniu.com/rtc/8660/QNLocalAudioTrack/12212/QNAudioSourceMixer))

Parameters

    * filter: QNAudioFilter 

音频处理器

Returns 移除成功返回 true，失败返回 false

以上内容是否对您有帮助？