MediaRecorder 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
用來錄製音訊和視訊。
[Android.Runtime.Register("android/media/MediaRecorder", DoNotGenerateAcw=true)]
public class MediaRecorder : Java.Lang.Object, Android.Media.IAudioRecordingMonitor, Android.Media.IAudioRouting, Android.Media.IMicrophoneDirection, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("android/media/MediaRecorder", DoNotGenerateAcw=true)>]
type MediaRecorder = class
inherit Object
interface IAudioRecordingMonitor
interface IJavaObject
interface IDisposable
interface IJavaPeerable
interface IAudioRouting
interface IMicrophoneDirection
- 繼承
- 屬性
- 實作
備註
用來錄製音訊和視訊。 錄製控制項是以簡單狀態電腦為基礎, (請參閱下方) 。
<img src=「 https://developer.android.com/images/mediarecorder_state_diagram.gif 」 border=「0」 />
使用 MediaRecorder 錄製音訊的常見案例如下:
MediaRecorder recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(PATH_NAME);
recorder.prepare();
recorder.start(); // Recording is now started
...
recorder.stop();
recorder.reset(); // You can reuse the object by going back to setAudioSource() step
recorder.release(); // Now the object cannot be reused
應用程式可能會想要註冊資訊事件和錯誤事件,以便在錄製期間收到一些內部更新和可能執行時間錯誤的通知。 註冊這類事件的方式是透過呼叫 (設定 #setOnInfoListener(OnInfoListener)
適當的接聽程式 (來設定 setOnInfoListener 和/或 #setOnErrorListener(OnErrorListener)
setOnErrorListener) 。 為了接收與這些接聽程式相關聯的個別回呼,應用程式必須線上程上建立 MediaRecorder 物件,且執行緒上執行迴圈器 (主要 UI 執行緒預設已經有執行) 的 Looper。
<strong > Note: < /strong > 目前,MediaRecorder 無法在模擬器上運作。
<div class=「special reference」 >< h3 > Developer Guides < /h3>
如需如何使用 MediaRecorder 錄製影片的詳細資訊,請閱讀 相機 開發人員指南。 如需如何使用 MediaRecorder 錄製音效的詳細資訊,請參閱 音訊擷取 開發人員指南。
</Div>
的 android.media.MediaRecorder
JAVA 檔。
此頁面的部分是根據所建立和共用的工作進行修改,並根據 2.5 屬性授權中所述的詞彙來使用。
建構函式
MediaRecorder() |
預設建構函式。 |
MediaRecorder(Context) |
預設建構函式。 |
MediaRecorder(IntPtr, JniHandleOwnership) |
建立 JNI 物件的 Managed 標記法時使用的建構函式;由執行時間呼叫。 |
欄位
MediaErrorServerDied |
已淘汰.
媒體伺服器無從存取。 |
MediaRecorderErrorUnknown |
已淘汰.
未指定的媒體錄製器錯誤。 |
屬性
ActiveMicrophones |
|
ActiveRecordingConfiguration |
傳回這個音訊錄製器目前的使用中音訊錄製。 |
AudioSourceMax |
取得音訊來源的最大值。 |
Class |
傳回這個 |
Handle |
基礎 Android 實例的控制碼。 (繼承來源 Object) |
JniIdentityHashCode |
用來錄製音訊和視訊。 (繼承來源 Object) |
JniPeerMembers |
用來錄製音訊和視訊。 |
LogSessionId |
傳 |
MaxAmplitude |
傳回自上次呼叫此方法以來取樣的最大絕對幅度。 |
Metrics |
傳回目前 Mediarecorder 實例的相關計量資料。 |
PeerReference |
用來錄製音訊和視訊。 (繼承來源 Object) |
PreferredDevice |
傳回 所 |
PrivacySensitive |
傳回此 MediaRecorder 是否標示為隱私權敏感,或與音訊擷取無關。 -或- 表示此擷取要求會區分隱私權,而且不允許任何並行擷取。 |
RoutedDevice |
|
Surface |
使用 SURFACE 視訊來源時,取得要錄製的介面。 |
ThresholdClass |
此 API 支援適用于 Android 的 Mono 基礎結構,並不適合直接從您的程式碼使用。 |
ThresholdType |
此 API 支援適用于 Android 的 Mono 基礎結構,並不適合直接從您的程式碼使用。 |
方法
AddOnRoutingChangedListener(IAudioRoutingOnRoutingChangedListener, Handler) |
新增 以 |
Clone() |
建立並傳回這個 物件的複本。 (繼承來源 Object) |
Dispose() |
用來錄製音訊和視訊。 (繼承來源 Object) |
Dispose(Boolean) |
用來錄製音訊和視訊。 (繼承來源 Object) |
Equals(Object) |
指出其他物件是否「等於」這個物件。 (繼承來源 Object) |
GetHashCode() |
傳回此物件的雜湊碼值。 (繼承來源 Object) |
JavaFinalize() |
當垃圾收集判斷物件不再參考物件時,垃圾收集行程會在物件上呼叫。 (繼承來源 Object) |
Notify() |
喚醒正在等候此物件監視器的單一線程。 (繼承來源 Object) |
NotifyAll() |
喚醒正在等候此物件監視器的所有線程。 (繼承來源 Object) |
Pause() |
暫停錄製。 |
Prepare() |
準備錄製器以開始擷取和編碼資料。 |
RegisterAudioRecordingCallback(IExecutor, AudioManager+AudioRecordingCallback) |
註冊回呼,以透過 |
Release() |
釋放與此 MediaRecorder 物件相關聯的資源。 |
RemoveOnRoutingChangedListener(IAudioRoutingOnRoutingChangedListener) |
|
Reset() |
將 MediaRecorder 重新開機為其閒置狀態。 |
Resume() |
繼續錄製。 |
SetAudioChannels(Int32) |
設定錄製的音訊通道數目。 |
SetAudioEncoder(AudioEncoder) |
設定要用於錄製的音訊編碼器。 |
SetAudioEncodingBitRate(Int32) |
設定錄製的音訊編碼位元速率。 |
SetAudioProfile(EncoderProfiles+AudioProfile) |
使用 AudioProfile 中的設定進行錄製。 |
SetAudioSamplingRate(Int32) |
設定錄製的音訊取樣率。 |
SetAudioSource(AudioSource) |
設定要用於錄製的音訊來源。 |
SetAuxiliaryOutputFile(FileDescriptor) |
已淘汰.
目前尚未實作。 |
SetAuxiliaryOutputFile(String) |
已淘汰.
目前尚未實作。 |
SetCamera(Camera) |
已淘汰.
|
SetCaptureRate(Double) |
設定視訊畫面擷取速率。 |
SetHandle(IntPtr, JniHandleOwnership) |
設定 Handle 屬性。 (繼承來源 Object) |
SetInputSurface(Surface) |
設定錄製器在使用 SURFACE 視訊來源時使用永續性表面。 |
SetLocation(Single, Single) |
在輸出檔案中設定及儲存 geodata (緯度和經度) 。 |
SetMaxDuration(Int32) |
在錄製會話的 ms) 中設定最大持續時間 (。 |
SetMaxFileSize(Int64) |
設定錄製會話) (檔案大小上限。 |
SetNextOutputFile(File) |
設定在先前輸出或 |
SetNextOutputFile(FileDescriptor) |
設定在先前輸出 |
SetOnErrorListener(MediaRecorder+IOnErrorListener) |
註冊在錄製時發生錯誤時要叫用的回呼。 |
SetOnInfoListener(MediaRecorder+IOnInfoListener) |
註冊在錄製時發生資訊事件時要叫用的回呼。 |
SetOrientationHint(Int32) |
設定輸出視訊播放的方向提示。 |
SetOutputFile(File) |
傳入要寫入的檔案物件。 |
SetOutputFile(FileDescriptor) |
傳入要寫入之檔案的檔案描述元。 |
SetOutputFile(String) |
設定要產生之輸出檔的路徑。 |
SetOutputFormat(OutputFormat) |
設定錄製期間產生的輸出檔格式。 |
SetPreferredDevice(AudioDeviceInfo) |
指定透過 |
SetPreferredMicrophoneDirection(MicDirection) |
指定用於處理) 的邏輯麥克風 (。 |
SetPreferredMicrophoneFieldDimension(Single) |
指定 i (縮放因數。 |
SetPreviewDisplay(Surface) |
設定 Surface 以顯示錄製的媒體預覽 (視訊) 。 |
SetProfile(CamcorderProfile) |
使用 CamcorderProfile 物件的設定進行錄製。 |
SetVideoEncoder(VideoEncoder) |
設定要用於錄製的視訊編碼器。 |
SetVideoEncodingBitRate(Int32) |
設定錄製的視訊編碼位元速率。 |
SetVideoEncodingProfileLevel(MediaCodecProfileType, Int32) |
設定錄製所需的視訊編碼設定檔和層級。 |
SetVideoFrameRate(Int32) |
設定要擷取之視訊的畫面播放速率。 |
SetVideoProfile(EncoderProfiles+VideoProfile) |
使用 VideoProfile 物件的設定進行錄製。 |
SetVideoSize(Int32, Int32) |
設定要擷取的視訊寬度和高度。 |
SetVideoSource(VideoSource) |
設定要用於錄製的視訊來源。 |
Start() |
開始擷取資料並將資料編碼至以 setOutputFile () 指定的檔案。 |
Stop() |
停止錄製。 |
ToArray<T>() |
用來錄製音訊和視訊。 (繼承來源 Object) |
ToString() |
傳回物件的字串表示。 (繼承來源 Object) |
UnregisterAudioRecordingCallback(AudioManager+AudioRecordingCallback) |
取消註冊先前向 |
UnregisterFromRuntime() |
用來錄製音訊和視訊。 (繼承來源 Object) |
Wait() |
讓目前的執行緒等到喚醒為止,通常是 em < notified/em > 或 < em > interrupted < /em > 。 >< (繼承來源 Object) |
Wait(Int64) |
讓目前的執行緒等到喚醒為止,通常是 em < notified/em > 或 < em > interrupted < /em > ,或直到經過一定數量的即時為止。 <> (繼承來源 Object) |
Wait(Int64, Int32) |
讓目前的執行緒等到喚醒為止,通常是 em < notified/em > 或 < em > interrupted < /em > ,或直到經過一定數量的即時為止。 <> (繼承來源 Object) |
事件
Error |
用來錄製音訊和視訊。 |
Info |
用來錄製音訊和視訊。 |
RoutingChanged |
用來錄製音訊和視訊。 |
明確介面實作
IJavaPeerable.Disposed() |
用來錄製音訊和視訊。 (繼承來源 Object) |
IJavaPeerable.DisposeUnlessReferenced() |
用來錄製音訊和視訊。 (繼承來源 Object) |
IJavaPeerable.Finalized() |
用來錄製音訊和視訊。 (繼承來源 Object) |
IJavaPeerable.JniManagedPeerState |
用來錄製音訊和視訊。 (繼承來源 Object) |
IJavaPeerable.SetJniIdentityHashCode(Int32) |
用來錄製音訊和視訊。 (繼承來源 Object) |
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) |
用來錄製音訊和視訊。 (繼承來源 Object) |
IJavaPeerable.SetPeerReference(JniObjectReference) |
用來錄製音訊和視訊。 (繼承來源 Object) |
擴充方法
JavaCast<TResult>(IJavaObject) |
執行 Android 執行時間檢查的類型轉換。 |
JavaCast<TResult>(IJavaObject) |
用來錄製音訊和視訊。 |
GetJniTypeName(IJavaPeerable) |
用來錄製音訊和視訊。 |