用于 Adobe® Flash® Platform 的 ActionScript® 3.0 参考
主页  |  隐藏包列表和类列表 |   |   |  新增内容  |  索引  |  附录  |  为什么显示为英语?
过滤条件: AIR 30.0 和更早版本, Flash Player 30.0 和更早版本, Flash Lite 4
Flex 4.6 和更早版本, Flash Pro CS6 和更早版本
隐藏过滤条件
flash.media 

Microphone  - AS3

x

顶级
adobe.utils
air.desktop
air.net
air.update
air.update.events
coldfusion.air
coldfusion.air.errors
coldfusion.air.events
coldfusion.service
coldfusion.service.events
coldfusion.service.mxml
com.adobe.acm.solutions.authoring.domain.extensions
com.adobe.acm.solutions.ccr.domain.extensions
com.adobe.consulting.pst.vo
com.adobe.dct.component
com.adobe.dct.component.datadictionary
com.adobe.dct.component.datadictionaryElement
com.adobe.dct.component.dataElementsPanel
com.adobe.dct.component.toolbars
com.adobe.dct.event
com.adobe.dct.exp
com.adobe.dct.model
com.adobe.dct.service
com.adobe.dct.service.provider
com.adobe.dct.transfer
com.adobe.dct.util
com.adobe.dct.view
com.adobe.ep.taskmanagement.domain
com.adobe.ep.taskmanagement.event
com.adobe.ep.taskmanagement.filter
com.adobe.ep.taskmanagement.services
com.adobe.ep.taskmanagement.util
com.adobe.ep.ux.attachmentlist.component
com.adobe.ep.ux.attachmentlist.domain
com.adobe.ep.ux.attachmentlist.domain.events
com.adobe.ep.ux.attachmentlist.domain.renderers
com.adobe.ep.ux.attachmentlist.skin
com.adobe.ep.ux.attachmentlist.skin.renderers
com.adobe.ep.ux.content.event
com.adobe.ep.ux.content.factory
com.adobe.ep.ux.content.handlers
com.adobe.ep.ux.content.managers
com.adobe.ep.ux.content.model.asset
com.adobe.ep.ux.content.model.preview
com.adobe.ep.ux.content.model.relation
com.adobe.ep.ux.content.model.search
com.adobe.ep.ux.content.model.toolbar
com.adobe.ep.ux.content.search
com.adobe.ep.ux.content.services
com.adobe.ep.ux.content.services.load
com.adobe.ep.ux.content.services.permissions
com.adobe.ep.ux.content.services.preview
com.adobe.ep.ux.content.services.providers
com.adobe.ep.ux.content.services.query
com.adobe.ep.ux.content.services.relationships
com.adobe.ep.ux.content.services.search.lccontent
com.adobe.ep.ux.content.services.version
com.adobe.ep.ux.content.view
com.adobe.ep.ux.content.view.components.activate
com.adobe.ep.ux.content.view.components.grid
com.adobe.ep.ux.content.view.components.grid.hover
com.adobe.ep.ux.content.view.components.grid.hover.component
com.adobe.ep.ux.content.view.components.grid.renderers
com.adobe.ep.ux.content.view.components.relationships
com.adobe.ep.ux.content.view.components.review
com.adobe.ep.ux.content.view.components.search.renderers
com.adobe.ep.ux.content.view.components.searchpod
com.adobe.ep.ux.content.view.components.toolbar
com.adobe.ep.ux.content.view.components.toolbar.controlRenderers
com.adobe.ep.ux.content.view.components.version
com.adobe.ep.ux.documentsubmit.component
com.adobe.ep.ux.documentsubmit.domain
com.adobe.ep.ux.documentsubmit.skin
com.adobe.ep.ux.taskaction.component
com.adobe.ep.ux.taskaction.domain
com.adobe.ep.ux.taskaction.domain.events
com.adobe.ep.ux.taskaction.skin
com.adobe.ep.ux.taskdetails.component
com.adobe.ep.ux.taskdetails.domain
com.adobe.ep.ux.taskdetails.skin
com.adobe.ep.ux.tasklist.component
com.adobe.ep.ux.tasklist.domain
com.adobe.ep.ux.tasklist.skin
com.adobe.ep.ux.webdocumentviewer.domain
com.adobe.exm.expression
com.adobe.exm.expression.error
com.adobe.exm.expression.event
com.adobe.exm.expression.impl
com.adobe.fiber.runtime.lib
com.adobe.fiber.services
com.adobe.fiber.services.wrapper
com.adobe.fiber.styles
com.adobe.fiber.util
com.adobe.fiber.valueobjects
com.adobe.gravity.binding
com.adobe.gravity.context
com.adobe.gravity.flex.bundleloader
com.adobe.gravity.flex.progress
com.adobe.gravity.flex.serviceloader
com.adobe.gravity.framework
com.adobe.gravity.init
com.adobe.gravity.service.bundleloader
com.adobe.gravity.service.logging
com.adobe.gravity.service.manifest
com.adobe.gravity.service.progress
com.adobe.gravity.tracker
com.adobe.gravity.ui
com.adobe.gravity.utility
com.adobe.gravity.utility.async
com.adobe.gravity.utility.error
com.adobe.gravity.utility.events
com.adobe.gravity.utility.factory
com.adobe.gravity.utility.flex.async
com.adobe.gravity.utility.logging
com.adobe.gravity.utility.message
com.adobe.gravity.utility.sequence
com.adobe.gravity.utility.url
com.adobe.guides.control
com.adobe.guides.domain
com.adobe.guides.i18n
com.adobe.guides.spark.components.skins
com.adobe.guides.spark.components.skins.mx
com.adobe.guides.spark.headers.components
com.adobe.guides.spark.headers.skins
com.adobe.guides.spark.layouts.components
com.adobe.guides.spark.layouts.skins
com.adobe.guides.spark.navigators.components
com.adobe.guides.spark.navigators.renderers
com.adobe.guides.spark.navigators.skins
com.adobe.guides.spark.util
com.adobe.guides.spark.wrappers.components
com.adobe.guides.spark.wrappers.skins
com.adobe.guides.submit
com.adobe.icc.dc.domain
com.adobe.icc.dc.domain.factory
com.adobe.icc.editors.events
com.adobe.icc.editors.handlers
com.adobe.icc.editors.managers
com.adobe.icc.editors.model
com.adobe.icc.editors.model.config
com.adobe.icc.editors.model.el
com.adobe.icc.editors.model.el.operands
com.adobe.icc.editors.model.el.operators
com.adobe.icc.enum
com.adobe.icc.external.dc
com.adobe.icc.obj
com.adobe.icc.services
com.adobe.icc.services.category
com.adobe.icc.services.config
com.adobe.icc.services.download
com.adobe.icc.services.export
com.adobe.icc.services.external
com.adobe.icc.services.formbridge
com.adobe.icc.services.fragmentlayout
com.adobe.icc.services.layout
com.adobe.icc.services.letter
com.adobe.icc.services.locator
com.adobe.icc.services.module
com.adobe.icc.services.render
com.adobe.icc.services.submit
com.adobe.icc.services.user
com.adobe.icc.token
com.adobe.icc.vo
com.adobe.icc.vo.render
com.adobe.icomm.assetplacement.controller
com.adobe.icomm.assetplacement.controller.utils
com.adobe.icomm.assetplacement.data
com.adobe.icomm.assetplacement.model
com.adobe.livecycle.assetmanager.client
com.adobe.livecycle.assetmanager.client.event
com.adobe.livecycle.assetmanager.client.handler
com.adobe.livecycle.assetmanager.client.managers
com.adobe.livecycle.assetmanager.client.model
com.adobe.livecycle.assetmanager.client.model.cms
com.adobe.livecycle.assetmanager.client.service
com.adobe.livecycle.assetmanager.client.service.search
com.adobe.livecycle.assetmanager.client.service.search.cms
com.adobe.livecycle.assetmanager.client.utils
com.adobe.livecycle.content
com.adobe.livecycle.rca.model
com.adobe.livecycle.rca.model.constant
com.adobe.livecycle.rca.model.document
com.adobe.livecycle.rca.model.participant
com.adobe.livecycle.rca.model.reminder
com.adobe.livecycle.rca.model.stage
com.adobe.livecycle.rca.service
com.adobe.livecycle.rca.service.core
com.adobe.livecycle.rca.service.core.delegate
com.adobe.livecycle.rca.service.process
com.adobe.livecycle.rca.service.process.delegate
com.adobe.livecycle.rca.token
com.adobe.livecycle.ria.security.api
com.adobe.livecycle.ria.security.service
com.adobe.mosaic.layouts
com.adobe.mosaic.layouts.dragAndDrop
com.adobe.mosaic.layouts.interfaces
com.adobe.mosaic.mxml
com.adobe.mosaic.om.constants
com.adobe.mosaic.om.events
com.adobe.mosaic.om.impl
com.adobe.mosaic.om.interfaces
com.adobe.mosaic.skinning
com.adobe.mosaic.sparklib.editors
com.adobe.mosaic.sparklib.optionMenu
com.adobe.mosaic.sparklib.scrollableMenu
com.adobe.mosaic.sparklib.scrollableMenu.skins
com.adobe.mosaic.sparklib.tabLayout
com.adobe.mosaic.sparklib.tabLayout.events
com.adobe.mosaic.sparklib.tabLayout.layouts
com.adobe.mosaic.sparklib.tabLayout.skins
com.adobe.mosaic.sparklib.text
com.adobe.mosaic.sparklib.util
com.adobe.solutions.acm.authoring.presentation
com.adobe.solutions.acm.authoring.presentation.actionbar
com.adobe.solutions.acm.authoring.presentation.common
com.adobe.solutions.acm.authoring.presentation.events
com.adobe.solutions.acm.authoring.presentation.fragment
com.adobe.solutions.acm.authoring.presentation.letter
com.adobe.solutions.acm.authoring.presentation.letter.data
com.adobe.solutions.acm.authoring.presentation.preview
com.adobe.solutions.acm.authoring.presentation.rte
com.adobe.solutions.acm.ccr.presentation
com.adobe.solutions.acm.ccr.presentation.contentcapture
com.adobe.solutions.acm.ccr.presentation.contentcapture.events
com.adobe.solutions.acm.ccr.presentation.contentcapture.preview
com.adobe.solutions.acm.ccr.presentation.datacapture
com.adobe.solutions.acm.ccr.presentation.datacapture.renderers
com.adobe.solutions.acm.ccr.presentation.pdf
com.adobe.solutions.exm
com.adobe.solutions.exm.authoring
com.adobe.solutions.exm.authoring.components.controls
com.adobe.solutions.exm.authoring.components.toolbars
com.adobe.solutions.exm.authoring.domain
com.adobe.solutions.exm.authoring.domain.expression
com.adobe.solutions.exm.authoring.domain.impl
com.adobe.solutions.exm.authoring.domain.method
com.adobe.solutions.exm.authoring.domain.variable
com.adobe.solutions.exm.authoring.enum
com.adobe.solutions.exm.authoring.events
com.adobe.solutions.exm.authoring.model
com.adobe.solutions.exm.authoring.renderer
com.adobe.solutions.exm.authoring.view
com.adobe.solutions.exm.expression
com.adobe.solutions.exm.impl
com.adobe.solutions.exm.impl.method
com.adobe.solutions.exm.method
com.adobe.solutions.exm.mock
com.adobe.solutions.exm.mock.method
com.adobe.solutions.exm.runtime
com.adobe.solutions.exm.runtime.impl
com.adobe.solutions.exm.variable
com.adobe.solutions.prm.constant
com.adobe.solutions.prm.domain
com.adobe.solutions.prm.domain.factory
com.adobe.solutions.prm.domain.impl
com.adobe.solutions.prm.domain.manager
com.adobe.solutions.prm.presentation.asset
com.adobe.solutions.prm.presentation.constant
com.adobe.solutions.prm.presentation.document
com.adobe.solutions.prm.presentation.event
com.adobe.solutions.prm.presentation.file
com.adobe.solutions.prm.presentation.project
com.adobe.solutions.prm.presentation.team
com.adobe.solutions.prm.presentation.util
com.adobe.solutions.prm.service
com.adobe.solutions.prm.services.impl
com.adobe.solutions.prm.vo
com.adobe.solutions.rca.constant
com.adobe.solutions.rca.domain
com.adobe.solutions.rca.domain.common
com.adobe.solutions.rca.domain.factory
com.adobe.solutions.rca.domain.impl
com.adobe.solutions.rca.domain.impl.manager
com.adobe.solutions.rca.domain.manager
com.adobe.solutions.rca.presentation
com.adobe.solutions.rca.presentation.comment
com.adobe.solutions.rca.presentation.constant
com.adobe.solutions.rca.presentation.event
com.adobe.solutions.rca.presentation.gantt
com.adobe.solutions.rca.presentation.gantt.ruler
com.adobe.solutions.rca.presentation.template
com.adobe.solutions.rca.presentation.template.audit
com.adobe.solutions.rca.presentation.template.definition
com.adobe.solutions.rca.presentation.template.documents
com.adobe.solutions.rca.presentation.template.stages
com.adobe.solutions.rca.presentation.util
com.adobe.solutions.rca.service
com.adobe.solutions.rca.services.impl
com.adobe.solutions.rca.vo
com.adobe.solutions.rca.vo.um
com.adobe.viewsource
fl.accessibility
fl.containers
fl.controls
fl.controls.dataGridClasses
fl.controls.listClasses
fl.controls.progressBarClasses
fl.core
fl.data
fl.display
fl.events
fl.ik
fl.lang
fl.livepreview
fl.managers
fl.motion
fl.motion.easing
fl.rsl
fl.text
fl.transitions
fl.transitions.easing
fl.video
flash.accessibility
flash.concurrent
flash.crypto
flash.data
flash.desktop
flash.display
flash.display3D
flash.display3D.textures
flash.errors
flash.events
flash.external
flash.filesystem
flash.filters
flash.geom
flash.globalization
flash.html
flash.media
flash.net
flash.net.dns
flash.net.drm
flash.notifications
flash.permissions
flash.printing
flash.profiler
flash.sampler
flash.security
flash.sensors
flash.system
flash.text
flash.text.engine
flash.text.ime
flash.ui
flash.utils
flash.xml
flashx.textLayout
flashx.textLayout.compose
flashx.textLayout.container
flashx.textLayout.conversion
flashx.textLayout.edit
flashx.textLayout.elements
flashx.textLayout.events
flashx.textLayout.factory
flashx.textLayout.formats
flashx.textLayout.operations
flashx.textLayout.utils
flashx.undo
ga.controls
ga.layouts
ga.model
ga.uiComponents
ga.util
ga.views
ga.wrappers
lc.foundation
lc.foundation.domain
lc.foundation.events
lc.foundation.ui
lc.foundation.util
lc.preloader
lc.procmgmt
lc.procmgmt.commands
lc.procmgmt.domain
lc.procmgmt.events
lc.procmgmt.formbridge
lc.procmgmt.impl
lc.procmgmt.ui.attachments
lc.procmgmt.ui.controls
lc.procmgmt.ui.controls.card
lc.procmgmt.ui.controls.renderer
lc.procmgmt.ui.help
lc.procmgmt.ui.layout
lc.procmgmt.ui.presentationmodel
lc.procmgmt.ui.process
lc.procmgmt.ui.search
lc.procmgmt.ui.startpoint
lc.procmgmt.ui.task
lc.procmgmt.ui.task.form
lc.procmgmt.ui.task.form.commands
lc.procmgmt.ui.tracking
mx.accessibility
mx.automation
mx.automation.air
mx.automation.delegates
mx.automation.delegates.advancedDataGrid
mx.automation.delegates.charts
mx.automation.delegates.containers
mx.automation.delegates.controls
mx.automation.delegates.controls.dataGridClasses
mx.automation.delegates.controls.fileSystemClasses
mx.automation.delegates.core
mx.automation.delegates.flashflexkit
mx.automation.events
mx.binding
mx.binding.utils
mx.charts
mx.charts.chartClasses
mx.charts.effects
mx.charts.effects.effectClasses
mx.charts.events
mx.charts.renderers
mx.charts.series
mx.charts.series.items
mx.charts.series.renderData
mx.charts.styles
mx.collections
mx.collections.errors
mx.containers
mx.containers.accordionClasses
mx.containers.dividedBoxClasses
mx.containers.errors
mx.containers.utilityClasses
mx.controls
mx.controls.advancedDataGridClasses
mx.controls.dataGridClasses
mx.controls.listClasses
mx.controls.menuClasses
mx.controls.olapDataGridClasses
mx.controls.scrollClasses
mx.controls.sliderClasses
mx.controls.textClasses
mx.controls.treeClasses
mx.controls.videoClasses
mx.core
mx.core.windowClasses
mx.data
mx.data.crypto
mx.data.errors
mx.data.events
mx.data.messages
mx.data.mxml
mx.data.offline.errors
mx.data.utils
mx.effects
mx.effects.easing
mx.effects.effectClasses
mx.events
mx.filters
mx.flash
mx.formatters
mx.geom
mx.graphics
mx.graphics.codec
mx.graphics.shaderClasses
mx.logging
mx.logging.errors
mx.logging.targets
mx.managers
mx.messaging
mx.messaging.channels
mx.messaging.config
mx.messaging.errors
mx.messaging.events
mx.messaging.management
mx.messaging.messages
mx.modules
mx.netmon
mx.olap
mx.olap.aggregators
mx.preloaders
mx.printing
mx.resources
mx.rpc
mx.rpc.events
mx.rpc.http
mx.rpc.http.mxml
mx.rpc.livecycle
mx.rpc.mxml
mx.rpc.remoting
mx.rpc.remoting.mxml
mx.rpc.soap
mx.rpc.soap.mxml
mx.rpc.wsdl
mx.rpc.xml
mx.skins
mx.skins.halo
mx.skins.spark
mx.skins.wireframe
mx.skins.wireframe.windowChrome
mx.states
mx.styles
mx.utils
mx.validators
org.osmf.containers
org.osmf.display
org.osmf.elements
org.osmf.events
org.osmf.layout
org.osmf.logging
org.osmf.media
org.osmf.metadata
org.osmf.net
org.osmf.net.dvr
org.osmf.net.httpstreaming
org.osmf.net.metrics
org.osmf.net.qos
org.osmf.net.rtmpstreaming
org.osmf.net.rules
org.osmf.traits
org.osmf.utils
spark.accessibility
spark.automation.delegates
spark.automation.delegates.components
spark.automation.delegates.components.gridClasses
spark.automation.delegates.components.mediaClasses
spark.automation.delegates.components.supportClasses
spark.automation.delegates.skins.spark
spark.automation.events
spark.collections
spark.components
spark.components.calendarClasses
spark.components.gridClasses
spark.components.mediaClasses
spark.components.supportClasses
spark.components.windowClasses
spark.core
spark.effects
spark.effects.animation
spark.effects.easing
spark.effects.interpolation
spark.effects.supportClasses
spark.events
spark.filters
spark.formatters
spark.formatters.supportClasses
spark.globalization
spark.globalization.supportClasses
spark.layouts
spark.layouts.supportClasses
spark.managers
spark.modules
spark.preloaders
spark.primitives
spark.primitives.supportClasses
spark.skins
spark.skins.mobile
spark.skins.mobile.supportClasses
spark.skins.spark
spark.skins.spark.mediaClasses.fullScreen
spark.skins.spark.mediaClasses.normal
spark.skins.spark.windowChrome
spark.skins.wireframe
spark.skins.wireframe.mediaClasses
spark.skins.wireframe.mediaClasses.fullScreen
spark.transitions
spark.utils
spark.validators
spark.validators.supportClasses
xd.core.axm.enterprise.view.components
xd.core.axm.enterprise.view.skins
xd.core.axm.view.components
xd.core.axm.view.components.support

语言元素

全局常量
全局函数
运算符
语句、关键字和指令
特殊类型

附录

新增内容
编译器错误
编译器警告
运行时错误
迁移到 ActionScript 3
支持的字符集
仅适用于 MXML 的标签
Motion XML 元素
Timed Text 标记
不推荐使用的元素的列表
AccessibilityImplementation 常量
如何使用 ActionScript 示例
法律声明
flash.media
public final class Microphone
继承Microphone Inheritance EventDispatcher Inheritance Object

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9

使用 Microphone 类监视音频或从麦克风捕获音频。

要访问设备麦克风,可以使用 Microphone.getMicrophone() 方法。不过此方法只是返回一个麦克风,无法消除回音。若要消除回音,需要使用 Microphone.getEnhancedMicrophone() 方法获得一个麦克风实例。此方法将返回一个对移动设备启用了回音消除功能的设备麦克风。使用回音消除功能可创建不需要耳机的实时音频/视频应用程序。

创建实时聊天应用程序

若要创建实时聊天应用程序,请捕获音频并将其发送到 Flash Media Server。使用 NetConnection 和 NetStream 类可将音频流发送到 Flash Media Server。Flash Media Server 可将音频广播到其他客户端。若要创建不需要耳机的聊天应用程序,请使用回音消除功能。回音消除功能可防止反馈回路 — 当音频进入麦克风,离开扬声器,并再次进入麦克风时,将产生反馈回路。若要使用回音消除功能,请调用 Microphone.getEnhancedMicrophone() 方法以获得对 Microphone 实例的引用。将 Microphone.enhancedOptions 设置为 MicrophoneEnhancedOptions 类的实例可配置设置。

在本地播放麦克风音频

调用 Microphone setLoopback() 方法将麦克风音频直接传送到本地计算机或设备音频输出。未控制的音频反馈始终是个问题,每当音频输出可以由麦克风输入拾取时都可能发生。setUseEchoSuppression() 方法可以减少(但无法消除)反馈放大的风险。

捕获麦克风音频以便进行本地录制或处理

要捕获麦克风音频,请侦听由 Microphone 实例调度的 sampleData 事件。为此事件调度的 SampleDataEvent 对象包含音频数据。

有关捕获视频的信息,请参阅 Camera 类。

运行时麦克风支持

在移动浏览器中运行的 Flash Player 不支持 Microphone 类。

AIR 配置文件支持:桌面操作系统、iOS 和 Android 移动设备均支持 Microphone 类。AIR for TV 设备不支持此功能。有关在多个配置文件之间支持 API 的详细信息,请参阅 AIR 配置文件支持

您可以使用 Microphone.isSupported 属性在运行时测试是否受支持。注意,在 AIR for TV 设备上,Microphone.isSupportedtrue,但是 Microphone.getMicrophone() 始终返回 null

隐私控制

Flash Player 显示一个“隐私”对话框,让用户选择是允许还是拒绝访问麦克风。您的应用程序窗口大小必须至少是 215 x 138 像素,这是显示对话框要求的最小大小,否则自动拒绝访问。

在 AIR 应用程序沙箱中运行的内容不需要访问麦克风的权限,并且不显示对话框。在应用程序沙箱外运行的 AIR 内容要求权限,并显示“隐私”对话框。

查看示例

了解详细信息

相关 API 元素



公共属性
 属性由以下参数定义
  activityLevel : Number
[只读] 麦克风正在检测的音量。
Microphone
  codec : String
用于压缩音频的编解码器。
Microphone
 Inheritedconstructor : Object
对类对象或给定对象实例的构造函数的引用。
Object
  enableVAD : Boolean
启用 Speex 语音活动检测。
Microphone
  encodeQuality : int
使用 Speex 编解码器时的编码语音品质。
Microphone
  enhancedOptions : MicrophoneEnhancedOptions
控制增强的麦克风选项。
Microphone
  framesPerPacket : int
在一个包(消息)中传输的 Speex 语音帧的数目。
Microphone
  gain : Number
麦克风放大信号的程度。
Microphone
  index : int
[只读] 麦克风的索引,它反映在 Microphone.names 返回的数组中。
Microphone
  isSupported : Boolean
[静态] [只读] 如果当前平台支持 Microphone 类,则 isSupported 属性设置为 true,否则设置为 false。
Microphone
  muted : Boolean
[只读] 指定用户是已经拒绝对麦克风的访问 (true) 还是已经允许对麦克风的访问 (false)。
Microphone
  name : String
[只读] 当前声音捕获设备的名称,它由声音捕获硬件返回。
Microphone
  names : Array
[静态] [只读] 包含所有可用声音捕获设备名称的字符串数组。
Microphone
  noiseSuppressionLevel : int
Speex 编码器使用的最大噪音衰减分贝数(负数)。
Microphone
      permissionStatus : String
[静态] [只读] 确定应用程序是否已被授予麦克风使用权限。
Microphone
  rate : int
麦克风捕获声音时使用的速率,单位是 kHz。
Microphone
  silenceLevel : Number
[只读] 激活麦克风并调度 activity 事件所需的音量。
Microphone
  silenceTimeout : int
[只读] 麦克风停止检测声音的时间和调度 activity 事件的时间之间相差的毫秒数。
Microphone
  soundTransform : flash.media:SoundTransform
在此麦克风对象处于环回模式时,控制它的声音。
Microphone
  useEchoSuppression : Boolean
[只读] 如果启用了回音抑制,则设置为 true;否则,设置为 false。
Microphone
公共方法
 方法由以下参数定义
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
使用 EventDispatcher 对象注册事件侦听器对象,以使侦听器能够接收事件通知。
EventDispatcher
 Inherited
将事件调度到事件流中。
EventDispatcher
  
[静态] 返回对可以执行回音消除功能的增强的 Microphone 对象的引用。
Microphone
  
[静态] 返回对用于捕获音频的 Microphone 对象的引用。
Microphone
 Inherited
检查 EventDispatcher 对象是否为特定事件类型注册了任何侦听器。
EventDispatcher
 Inherited
表示对象是否已经定义了指定的属性。
Object
 Inherited
表示 Object 类的实例是否在指定为参数的对象的原型链中。
Object
 Inherited
表示指定的属性是否存在、是否可枚举。
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
从 EventDispatcher 对象中删除侦听器。
EventDispatcher
  
为应用程序申请麦克风权限。
Microphone
  
setLoopBack(state:Boolean = true):void
将麦克风捕获的音频传送到本地扬声器。
Microphone
 Inherited
设置循环操作动态属性的可用性。
Object
  
setSilenceLevel(silenceLevel:Number, timeout:int = -1):void
设置可认定为有声的最低音量输入水平,以及实际静音前需经历的无声时间长度(可选)。
Microphone
  
setUseEchoSuppression(useEchoSuppression:Boolean):void
指定是否使用音频编解码器的回音抑制功能。
Microphone
 Inherited
返回此对象的字符串表示形式,其格式设置遵守区域设置特定的约定。
Object
 Inherited
返回指定对象的字符串表示形式。
Object
 Inherited
返回指定对象的原始值。
Object
 Inherited
检查是否用此 EventDispatcher 对象或其任何祖代为指定事件类型注册了事件侦听器。
EventDispatcher
事件
 事件 摘要 由以下参数定义
 Inherited[广播事件] Flash Player 或 AIR 应用程序获得操作系统焦点并变为活动状态时将调度此事件。EventDispatcher
 Inherited[广播事件] Flash Player 或 AIR 应用程序失去操作系统焦点并变为非活动状态时将调度此事件。EventDispatcher
属性详细信息

activityLevel

属性
activityLevel:Number  [只读]

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9

麦克风正在检测的音量。值的范围为 0(未检测到声音)到 100(检测到非常大的声音)。此属性的值有助于确定向 Microphone.setSilenceLevel() 方法传递的适当值。

如果麦克风 muted 属性为 true,此属性的值始终为 -1。



实现
    public function get activityLevel():Number

引发
PermissionError — 应用程序不具备麦克风使用权限。

相关 API 元素

codec

属性 
codec:String

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5

用于压缩音频的编解码器。可用编解码器为 Nellymoser(默认值)和 Speex。枚举类 SoundCodec 包含各种对 codec 属性有效的值。

如果使用 Nellymoser 编解码器,可使用 Microphone.rate() 设置采样率。如果使用 Speex 编解码器,则采样率会设置为 16 kHz。

Speex 具有语音活动检测功能 (VAD),在未检测到语音时将自动减小带宽。使用 Speex 编解码器时,Adobe 建议将静音级别设置为 0。要设置静音级别,请使用 Microphone.setSilenceLevel() 方法。



实现
    public function get codec():String
    public function set codec(value:String):void

引发
PermissionError — 应用程序不具备麦克风使用权限。

相关 API 元素

enableVAD

属性 
enableVAD:Boolean

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

启用 Speex 语音活动检测。



实现
    public function get enableVAD():Boolean
    public function set enableVAD(value:Boolean):void

引发
PermissionError — 应用程序不具备麦克风使用权限。

encodeQuality

属性 
encodeQuality:int

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5

使用 Speex 编解码器时的编码语音品质。可能值为从 0 到 10 的值。默认值为 6。数字越大,表示品质越高,但需要更多的带宽,如下表所示。列出的比特率值表示净比特率,并不包括信息分包开销。

品质值所需的比特率(KB/秒)
0 3.95
15.75
27.75
39.80
412.8
516.8
620.6
723.8
827.8
934.2
1042.2



实现
    public function get encodeQuality():int
    public function set encodeQuality(value:int):void

引发
PermissionError — 应用程序不具备麦克风使用权限。

相关 API 元素

enhancedOptions

属性 
enhancedOptions:MicrophoneEnhancedOptions

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.3, AIR 2.7

控制增强的麦克风选项。有关详细信息,请参阅 MicrophoneEnhancedOptions 类。对于非增强的 Microphone 实例,此属性被忽略。



实现
    public function get enhancedOptions():MicrophoneEnhancedOptions
    public function set enhancedOptions(value:MicrophoneEnhancedOptions):void

引发
PermissionError — 应用程序不具备麦克风使用权限。

相关 API 元素

framesPerPacket

属性 
framesPerPacket:int

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5

在一个包(消息)中传输的 Speex 语音帧的数目。每帧长 20 ms。默认值为每个包两帧。

消息中包含的 Speex 帧越多,需要的带宽就越小,但发送消息延迟的时间就越长。Speex 帧越少,需要的带宽就越大,而延迟的时间就会越短。



实现
    public function get framesPerPacket():int
    public function set framesPerPacket(value:int):void

gain

属性 
gain:Number

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9

麦克风放大信号的程度。有效值为 0 到 100。默认值为 50。



实现
    public function get gain():Number
    public function set gain(value:Number):void

引发
PermissionError — 应用程序不具备麦克风使用权限。

相关 API 元素

index

属性 
index:int  [只读]

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9

麦克风的索引,它反映在 Microphone.names 返回的数组中。



实现
    public function get index():int

引发
PermissionError — 应用程序不具备麦克风使用权限。

相关 API 元素

isSupported

属性 
isSupported:Boolean  [只读]

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

如果当前平台支持 Microphone 类,则 isSupported 属性设置为 true,否则,设置为 false



实现
    public static function get isSupported():Boolean

muted

属性 
muted:Boolean  [只读]

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9

指定用户是已经拒绝对麦克风的访问 (true) 还是已经允许对麦克风的访问 (false)。当该值发生变化时,将调度 status 事件。有关详细信息,请参阅 Microphone.getMicrophone()



实现
    public function get muted():Boolean

引发
PermissionError — 应用程序不具备麦克风使用权限。

相关 API 元素

name

属性 
name:String  [只读]

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9

当前声音捕获设备的名称,它由声音捕获硬件返回。



实现
    public function get name():String

相关 API 元素

names

属性 
names:Array  [只读]

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9

包含所有可用声音捕获设备名称的字符串数组。返回名称,但不必向用户显示 Flash Player 的“专用设置”面板。此数组通过 Microphone.names.length 属性提供每个声音捕获设备的从零开始的索引和系统上声音捕获设备的数量。有关详细信息,请参阅 Array 类条目。

调用 Microphone.names 要求全面检查硬件,并可能需要几秒钟时间才能生成数组。大多数情况下,使用默认麦克风即可。

注意:要确定当前麦克风的名称,请使用 name 属性。



实现
    public static function get names():Array

相关 API 元素

noiseSuppressionLevel

属性 
noiseSuppressionLevel:int

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

Speex 编码器使用的最大噪音衰减分贝数(负数)。如果启用,则在从 Microphone 捕获的声音进行 Speex 压缩之前应用噪音抑制。设置为 0 以禁用噪音抑制。默认启用噪音抑制,最大衰减为 -30 dB。选择 Nellymoser 编解码器时被忽略。



实现
    public function get noiseSuppressionLevel():int
    public function set noiseSuppressionLevel(value:int):void

引发
PermissionError — 应用程序不具备麦克风使用权限。
    

permissionStatus

属性 
permissionStatus:String  [只读]

语言版本: ActionScript 3.0
运行时版本: AIR 24.0

确定应用程序是否已被授予麦克风使用权限。



实现
    public static function get permissionStatus():String

相关 API 元素

rate

属性 
rate:int

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9

麦克风捕获声音时使用的速率,单位是 kHz。可接受的值为 5、8、11、22 和 44。如果您的声音捕获设备支持 8 kHz,则默认值为 8 kHz。否则,默认值是您的声音捕获设备支持的高于 8 kHz 的下一个可用捕获级别,通常为 11 kHz。

注意:实际速率与下表中注明的 rate 值稍有不同:

rate实际频率
4444,100 Hz
2222,050 Hz
1111,025 Hz
88,000 Hz
55,512 Hz



实现
    public function get rate():int
    public function set rate(value:int):void

引发
PermissionError — 应用程序不具备麦克风使用权限。

相关 API 元素

silenceLevel

属性 
silenceLevel:Number  [只读]

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9

激活麦克风并调度 activity 事件所需的音量。默认值为 10。



实现
    public function get silenceLevel():Number

引发
PermissionError — 应用程序不具备麦克风使用权限。

相关 API 元素

silenceTimeout

属性 
silenceTimeout:int  [只读]

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9

麦克风停止检测声音的时间和调度 activity 事件的时间之间相差的毫秒数。默认值为 2000(2 秒)。

要设置此值,请使用 Microphone.setSilenceLevel() 方法。



实现
    public function get silenceTimeout():int

引发
PermissionError — 应用程序不具备麦克风使用权限。

相关 API 元素

soundTransform

属性 
soundTransform:flash.media:SoundTransform

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9

在此麦克风对象处于环回模式时,控制它的声音。



实现
    public function get soundTransform():flash.media:SoundTransform
    public function set soundTransform(value:flash.media:SoundTransform):void

引发
PermissionError — 应用程序不具备麦克风使用权限。

useEchoSuppression

属性 
useEchoSuppression:Boolean  [只读]

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9

如果启用了回音抑制,则设置为 true;否则,设置为 false。除非用户已经在 Flash Player 的“麦克风设置”面板中选择了“降低回音”,否则默认值为 false



实现
    public function get useEchoSuppression():Boolean

相关 API 元素

方法详细信息

getEnhancedMicrophone

()方法
public static function getEnhancedMicrophone(index:int = -1):Microphone

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.3, AIR 2.7

返回对可以执行回音消除功能的增强的 Microphone 对象的引用。使用回音消除功能可创建不需要耳机的音频/视频聊天应用程序。

Microphone.getEnhancedMicrophone() 方法和 Microphone.getMicrophone() 方法的 index 参数的工作方式相同。

要在 Android 上使用此方法,需在应用程序描述符的 Android 清单添加项下添加 MODIFY_ AUDIO_ SETTINGS 权限。

重要说明:在任何给定时间,您只能具有单个增强麦克风设备实例。所有其他 Microphone 实例都将停止提供音频数据,并且将收到 code 属性为 Microphone.UnavailableStatusEvent。当增强的音频初始化失败时,调用此方法将返回 null,为 Microphone.enhancedOptions 设置值没有效果,并且所有现有 Microphone 实例的工作方式保持不变。

若要配置增强的 Microphone 对象,请设置 Microphone.enhancedOptions 属性。下面的代码在本地测试中使用增强的 Microphone 对象和全双工回音消除功能:

	     var mic:Microphone = Microphone.getEnhancedMicrophone();
	     var options:MicrophoneEnhancedOptions = new MicrophoneEnhancedOptions();
	     options.mode = MicrophoneEnhancedMode.FULL_DUPLEX;
	     mic.enhancedOptions = options;
	     mic.setLoopBack(true);
	 

在使用回音消除功能时,将忽略 setUseEchoSuppression() 方法。

当 SWF 文件尝试访问 Microphone.getEnhancedMicrophone() 返回的对象时(例如,在调用 NetStream.attachAudio() 时),Flash Player 将显示“隐私”对话框,用户可从中选择是允许还是拒绝访问麦克风。(确保舞台大小至少为 215 x 138 个像素;这是 Flash Player 显示该对话框所需的最小大小。)

参数

index:int (default = -1) — 麦克风的索引值。

返回
Microphone — 对用于捕获音频的 Microphone 对象的引用。如果增强的音频初始化失败,则返回 null

相关 API 元素

getMicrophone

()方法 
public static function getMicrophone(index:int = -1):Microphone

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9

返回对用于捕获音频的 Microphone 对象的引用。要开始捕获音频,您必须将 Microphone 对象附加到 NetStream 对象(请参阅 NetStream.attachAudio())。

多个对 Microphone.getMicrophone() 的调用引用相同的麦克风。因此,如果您的代码包含 mic1 = Microphone.getMicrophone()mic2 = Microphone.getMicrophone() 行,那么 mic1mic2 都会引用相同的(默认)麦克风。

通常,不应传递 index 的值。只需调用 air.Microphone.getMicrophone() 即可返回对默认麦克风的引用。使用 Flash Player 设置面板的“麦克风设置”部分,用户可以指定应用程序应该使用的默认麦克风。(用户通过右键单击在 Web 浏览器中运行的 Flash Player 内容来访问 Flash Player 设置面板。)如果您为 index 传递一个值,您可以引用与用户选择的麦克风不同的麦克风。在极少数情况下(例如,应用程序同时从两个麦克风捕获音频),您可能会使用 index。在 Adobe AIR 中运行的内容也使用默认麦克风的 Flash Player 设置。

使用 Microphone.index 属性可以获取当前 Microphone 对象的索引值。然后,可以将该值传递给 Microphone 类的其他方法。

当 SWF 文件尝试访问 Microphone.getMicrophone() 返回的对象时(例如,在调用 NetStream.attachAudio() 时),Flash Player 将显示“隐私”对话框,用户可从中选择是允许还是拒绝访问麦克风。(确保舞台大小至少为 215 x 138 个像素;这是 Flash Player 显示该对话框所需的最小大小。)

当用户对此对话框做出响应时,将调度 status 事件以表示用户的响应。还可以检查 Microphone.muted 属性以确定用户是允许还是拒绝访问麦克风。

如果 Microphone.getMicrophone() 返回 null,则表明麦克风正由其它应用程序使用,或者系统上没有安装任何麦克风。要确定是否安装了任何麦克风,请使用 Microphones.names.length。要显示 Flash Player 的“麦克风设置”面板(用户可从中选择 Microphone.getMicrophone 所引用的麦克风),请使用 Security.showSettings()

参数

index:int (default = -1) — 麦克风的索引值。

返回
Microphone — 对用于捕获音频的 Microphone 对象的引用。

事件
status:StatusEvent — 在麦克风报告其状态时调度。如果 code 属性的值为 "Microphone.Muted",则表示用户拒绝 SWF 文件访问其麦克风。如果 code 属性的值为 "Microphone.Unmuted",则表示用户允许 SWF 文件访问其麦克风。

相关 API 元素


示例  ( 如何使用本示例 )

以下示例显示如何通过使用静态 Microphone.getMicrophone() 方法并侦听状态事件来请求对用户麦克风的访问权限。ActionScriptExamples.com 提供的示例。
var mic:Microphone = Microphone.getMicrophone();
mic.setLoopBack();
mic.addEventListener(StatusEvent.STATUS, mic_status);
 
var tf:TextField = new TextField();
tf.autoSize = TextFieldAutoSize.LEFT;
tf.text = "Detecting microphone...";
addChild(tf);
 
function mic_status(evt:StatusEvent):void {
    tf.text = "Microphone is muted?: " + mic.muted;
    switch (evt.code) {
        case "Microphone.Unmuted":
            tf.appendText("\n" + "Microphone access was allowed.");
            break;
        case "Microphone.Muted":
            tf.appendText("\n" + "Microphone access was denied.");
            break;
    }
}

    requestPermission

()方法 
public function requestPermission():void

语言版本: ActionScript 3.0
运行时版本: AIR 24.0

为应用程序申请麦克风权限。


事件
PermissionStatus:PermissionEvent — 当用户授予/拒绝所申请权限时调度。

setLoopBack

()方法 
public function setLoopBack(state:Boolean = true):void

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9

将麦克风捕获的音频传送到本地扬声器。

参数

state:Boolean (default = true)


引发
PermissionError — 应用程序不具备麦克风使用权限。

setSilenceLevel

()方法 
public function setSilenceLevel(silenceLevel:Number, timeout:int = -1):void

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9

设置可认定为有声的最低音量输入水平,以及实际静音前需经历的无声时间长度(可选)。

  • 要完全禁止麦克风检测声音,请为 silenceLevel 传递值 100;这样就决不会再调度 activity 事件了。
  • 要确定麦克风当前所检测的音量,请使用 Microphone.activityLevel

Speex 具有语音活动检测功能 (VAD),在未检测到语音时将自动减小带宽。使用 Speex 编解码器时,Adobe 建议将静音级别设置为 0。

活动检测是检测声音级别在何时表示某人正在谈话的功能。当某人没有谈话时,由于不需要发送关联的音频流,因此可以节约带宽。此信息也可用于视频反馈,以便让用户知道他们(或其它人)没有谈话。

静音值与活动值直接对应。完全静音对应于活动值 0。持续噪音(根据当前增益设置可以检测到的噪音)对应于活动值 100。当增益得到适当调整之后,在您没有说话时,活动值将小于静音值;在您说话时,活动值将大于静音值。

此方法与 Camera.setMotionLevel() 类似;这两种方法都用于指定何时调度 activity 事件。不过,这两种方法在对发布流的影响上具有显著的差异:

  • Camera.setMotionLevel() 设计用于检测运动,并且不影响带宽用量。即使视频流未检测到运动,仍将发送视频。
  • Microphone.setSilenceLevel() 设计用于优化带宽。在认为音频流被静音时,不发送任何音频数据。而改为发送一条表示静音已启动的消息。

参数

silenceLevel:Number — 激活麦克风并调度 activity 事件所需的音量。可接受值的范围为 0 到 100。
 
timeout:int (default = -1) — 在没有活动的情况下经过的毫秒数,必须经过这么长的时间,Flash Player 或 Adobe AIR 才会认为声音已停止并调度 dispatch 事件。默认值为 2000(2 秒)。(注意:在签名中显示的默认值 -1 是一个内部值,用于表示 Flash Player 或 Adobe AIR 使用 2000。)


引发
PermissionError — 应用程序不具备麦克风使用权限。

相关 API 元素

setUseEchoSuppression

()方法 
public function setUseEchoSuppression(useEchoSuppression:Boolean):void

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9

指定是否使用音频编解码器的回音抑制功能。除非用户已经在 Flash Player 的“麦克风设置”面板中选择了“降低回音”,否则默认值为 false

回音抑制是指降低音频回馈效果,当扬声器发出的声音由同一系统上的麦克风拾取时,将导致音频回馈。(这不同于回音消除,后者会完全移除反馈。在调用 getEnhancedMicrophone() 方法以使用回音消除功能时,将忽略 setUseEchoSuppression() 方法。)

通常情况下,当通过扬声器(而不是耳机)播放所捕获的声音时,建议使用回音抑制。如果您的 SWF 文件允许用户指定声音输出设备,则当他们指定使用扬声器并且还将使用麦克风时,您可能需要调用 Microphone.setUseEchoSuppression(true)

用户也可以在 Flash Player 的“麦克风设置”面板中调整这些设置。

参数

useEchoSuppression:Boolean — 一个 Boolean 值,表示是使用回音抑制 (true) 还是不使用该功能 (false)。


引发
PermissionError — 应用程序不具备麦克风使用权限。

相关 API 元素

MicrophoneExample.as

以下示例在用户允许访问其计算机的麦克风后通过使用麦克风的回音抑制捕获声音。Security.showSettings() 方法显示 Flash Player 对话框,请求提供对用户的麦克风的访问权限。对 setLoopBack(true) 的调用会将输入重新发送到本地扬声器,以便在运行示例时可以听到声音。

有两个侦听器用于侦听 activitystatus 事件。activity 事件在会话开始和结束(如果有)时被调度,并由 activityHandler() 方法捕获(此方法跟踪有关该事件的信息)。status 事件在附加的 Microphone 对象报告任何状态信息时被调度;将使用 statusHandler() 方法捕获并跟踪此信息。

注意:必须将麦克风与计算机连接,此示例才能正常运行。

package {
    import flash.display.Sprite;
    import flash.events.*;
    import flash.media.Microphone;
    import flash.system.Security;

    public class MicrophoneExample extends Sprite {
        public function MicrophoneExample() {
            var mic:Microphone = Microphone.getMicrophone();
            Security.showSettings("2");
            mic.setLoopBack(true);
                    
            if (mic != null) {
                mic.setUseEchoSuppression(true);
                mic.addEventListener(ActivityEvent.ACTIVITY, activityHandler);
                mic.addEventListener(StatusEvent.STATUS, statusHandler);
            }
        }

        private function activityHandler(event:ActivityEvent):void {
            trace("activityHandler: " + event);
        }

        private function statusHandler(event:StatusEvent):void {
            trace("statusHandler: " + event);
        }
    }
}




[ X ]为什么显示为英语?
《ActionScript 3.0 参考》中的内容以英语显示

《ActionScript 3.0 参考》中的部分内容未翻译成所有语言。当某个语言元素未翻译时,将显示为英语。例如,ga.controls.HelpBox 类未翻译成任何语言。因此在简体中文版的参考中,ga.controls.HelpBox 类显示为英语。