2022年3月22日 星期二

Android Studio - MediaRecorder 參數(MediaRecorder Parameters)(七十二)

Android Studio - MediaRecorder 參數(MediaRecorder Parameters)(七十二):

MediaRecorder 類是 Android 提供的用來錄製視訊(Video)和音訊(Audio)的元件,MediaRecorder 和 MediaPlayer API 提供了經過更高層抽象和封裝介面,直接對檔進行操作,而且他倆功能更豐富,同時支援音訊和視頻。

Android MediaRecorder State Diagram
Nested classes Summary:

Nested classes

Description

class

MediaRecorder.AudioEncoder

Defines the audio encoding. 

class

MediaRecorder.AudioSource

Defines the audio source. 

class

MediaRecorder.MetricsConstants

 

interface

MediaRecorder.OnErrorListener

Interface definition for a callback to be invoked when an error occurs while recording. 

interface

MediaRecorder.OnInfoListener

Interface definition of a callback to be invoked to communicate some info and/or warning about the recording. 

class

MediaRecorder.OutputFormat

Defines the output format. 

class

MediaRecorder.VideoEncoder

Defines the video encoding. 

Class

MediaRecorder.VideoSource

Defines the video source. 


Constants Summary:

Constants

Description

int

MEDIA_ERROR_SERVER_DIED

Media server died.

int

MEDIA_RECORDER_ERROR_UNKNOWN

Unspecified media recorder error.

int

MEDIA_RECORDER_INFO_MAX_DURATION_REACHED

A maximum duration had been setup and has now been reached.

int

MEDIA_RECORDER_INFO_MAX_FILESIZE_APPROACHING

A maximum filesize had been setup and current recorded file size has reached 90% of the limit.

int

MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED

A maximum filesize had been setup and has now been reached.

int

MEDIA_RECORDER_INFO_NEXT_OUTPUT_FILE_STARTED

A maximum filesize had been reached and MediaRecorder has switched output to a new file set by application setNextOutputFile(File).

Int

MEDIA_RECORDER_INFO_UNKNOWN

Unspecified media recorder info.


Public methods:

Constants

Description

void

addOnRoutingChangedListener(AudioRouting.OnRoutingChangedListener listener, Handler handler)

Adds an AudioRouting.OnRoutingChangedListener to receive notifications of routing changes on this MediaRecorder.

List<MicrophoneInfo>

getActiveMicrophones()

Return A lists of MicrophoneInfo representing the active microphones.

AudioRecordingConfiguration

getActiveRecordingConfiguration()

Returns the current active audio recording for this audio recorder.

static final int

getAudioSourceMax()

Gets the maximum value for audio sources.

LogSessionId

getLogSessionId()

Returns the LogSessionId for MediaRecorder.

int

getMaxAmplitude()

Returns the maximum absolute amplitude that was sampled since the last call to this method.

PersistableBundle

getMetrics()

Return Metrics data about the current Mediarecorder instance.

AudioDeviceInfo

getPreferredDevice()

Returns the selected input device specified by setPreferredDevice(AudioDeviceInfo).

AudioDeviceInfo

getRoutedDevice()

Returns an AudioDeviceInfo identifying the current routing of this MediaRecorder Note: The query is only valid if the MediaRecorder is currently recording.

Surface

getSurface()

Gets the surface to record from when using SURFACE video source.

boolean

isPrivacySensitive()

Returns whether this MediaRecorder is marked as privacy sensitive or not with regard to audio capture.

void

pause()

Pauses recording.

void

prepare()

Prepares the recorder to begin capturing and encoding data.

void

registerAudioRecordingCallback(Executor executor, AudioManager.AudioRecordingCallback cb)

Register a callback to be notified of audio capture changes via a AudioManager.AudioRecordingCallback.

void

release()

Releases resources associated with this MediaRecorder object.

void

removeOnRoutingChangedListener(AudioRouting.OnRoutingChangedListener listener)

Removes an AudioRouting.OnRoutingChangedListener which has been previously added to receive rerouting notifications.

void

reset()

Restarts the MediaRecorder to its idle state.

void

resume()

Resumes recording.

void

setAudioChannels(int numChannels)

Sets the number of audio channels for recording.

void

setAudioEncoder(int audio_encoder)

Sets the audio encoder to be used for recording.

void

setAudioEncodingBitRate(int bitRate)

Sets the audio encoding bit rate for recording.

void

setAudioProfileEncoderProfiles.AudioProfile profile)

Uses the settings from an AudioProfile for recording.

void

setAudioSamplingRate(int samplingRate)

Sets the audio sampling rate for recording.

void

setAudioSource(int audioSource)

Sets the audio source to be used for recording.

void

setCameraCamera c)

This method was deprecated in API level 21. Use getSurface() and the android.hardware.camera2 API instead.

void

setCaptureRate(double fps)

Set video frame capture rate.

void

setInputSurface(Surface surface)

Configures the recorder to use a persistent surface when using SURFACE video source.

void

setLocation(float latitude, float longitude)

Set and store the geodata (latitude and longitude) in the output file.

void

setLogSessionId(LogSessionId id)

Sets the LogSessionId for MediaRecorder.

void

setMaxDuration(int max_duration_ms)

Sets the maximum duration (in ms) of the recording session.

void

setMaxFileSize(long max_filesize_bytes)

Sets the maximum filesize (in bytes) of the recording session.

void

setNextOutputFile(File file)

Sets the next output file to be used when the maximum filesize is reached on the prior output setOutputFile(File) or setNextOutputFile(File)).

void

setNextOutputFile(FileDescriptor fd)

Sets the next output file descriptor to be used when the maximum filesize is reached on the prior output setOutputFile(File) or setNextOutputFile(File)).

void

setOnErrorListener(MediaRecorder.OnErrorListener l)

Register a callback to be invoked when an error occurs while recording.

void

setOnInfoListener(MediaRecorder.OnInfoListener listener)

Register a callback to be invoked when an informational event occurs while recording.

void

setOrientationHint(int degrees)

Sets the orientation hint for output video playback.

void

setOutputFile(FileDescriptor fd)

Pass in the file descriptor of the file to be written.

void

setOutputFile(String path)

Sets the path of the output file to be produced.

void

setOutputFile(File file)

Pass in the file object to be written.

void

setOutputFormat(int output_format)

Sets the format of the output file produced during recording.

boolean

setPreferredDevice(AudioDeviceInfo deviceInfo)

Specifies an audio device (via an AudioDeviceInfo object) to route the input from this MediaRecorder.

boolean

setPreferredMicrophoneDirection(int direction)

Specifies the logical microphone (for processing).

boolean

setPreferredMicrophoneFieldDimension(float zoom)

Specifies the zoom factor (i.e.

void

setPreviewDisplay(Surface sv)

Sets a Surface to show a preview of recorded media (video).

void

setPrivacySensitive(boolean privacySensitive)

Indicates that this capture request is privacy sensitive and that any concurrent capture is not permitted.

void

setProfile(CamcorderProfile profile)

Uses the settings from a CamcorderProfile object for recording.

void

setVideoEncoder(int video_encoder)

Sets the video encoder to be used for recording.

void

setVideoEncodingBitRate(int bitRate)

Sets the video encoding bit rate for recording.

void

setVideoEncodingProfileLevel(int profile, int level)

Sets the desired video encoding profile and level for recording.

void

setVideoFrameRate(int rate)

Sets the frame rate of the video to be captured.

void

setVideoProfile(EncoderProfiles.VideoProfile profile)

Uses the settings from a VideoProfile object for recording.

void

setVideoSize(int width, int height)

Sets the width and height of the video to be captured.

void

setVideoSource(int video_source)

Sets the video source to be used for recording.

void

start()

Begins capturing and encoding data to the file specified with setOutputFile().

void

stop()

Stops recording.

void

unregisterAudioRecordingCallback(AudioManager.AudioRecordingCallback cb)

Unregister an audio recording callback previously registered with registerAudioRecordingCallback(java.util.concurrent.Executor, android.media.AudioManager.AudioRecordingCallback).


Protected methods:

Constants

Description

void

finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.


Inherited methods - From class java.lang.Object:

From class java.lang.Object

Description

Object

clone()

Creates and returns a copy of this object.

boolean

equals(Object obj)

Indicates whether some other object is "equal to" this one.

void

finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?>

getClass()

Returns the runtime class of this Object.

int

hashCode()

Returns a hash code value for the object.

final void

notify() Wakes up a single thread that is waiting on this object's monitor.

final void

notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String

toString()

Returns a string representation of the object.

final void

wait(long timeout, int nanos)

Causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

final void

wait(long timeout)

Causes the current thread to wait until either another thread invokes the notify() method or the notifyAll() method for this object, or a specified amount of time has elapsed.

final void

wait()

Causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object.


Inherited methods - From interface android.media.AudioRouting:

From interface android.media.AudioRouting

abstract void

addOnRoutingChangedListener(AudioRouting.OnRoutingChangedListener listener, Handler handler)

Adds an AudioRouting.OnRoutingChangedListener to receive notifications of routing changes on this AudioTrack/AudioRecord.

abstract AudioDeviceInfo

getPreferredDevice()

Returns the selected output/input specified by setPreferredDevice(AudioDeviceInfo).

abstract AudioDeviceInfo

getRoutedDevice()

Returns an AudioDeviceInfo identifying the current routing of this AudioTrack/AudioRecord.

abstract void

removeOnRoutingChangedListener(AudioRouting.OnRoutingChangedListener listener)

Removes an AudioRouting.OnRoutingChangedListener which has been previously added to receive rerouting notifications.

abstract boolean

setPreferredDevice(AudioDeviceInfo deviceInfo)

Specifies an audio device (via an AudioDeviceInfo object) to route the output/input to/from.


Inherited methods - From interface android.media.AudioRecordingMonitor:

From interface android.media.AudioRecordingMonitor

abstract AudioRecordingConfiguration

getActiveRecordingConfiguration()

Returns the current active audio recording for this audio recorder.

abstract void

registerAudioRecordingCallback(Executor executor, AudioManager.AudioRecordingCallback cb)

Register a callback to be notified of audio capture changes via a AudioManager.AudioRecordingCallback.

abstract void

unregisterAudioRecordingCallback(AudioManager.AudioRecordingCallback cb)

Unregister an audio recording callback previously registered with registerAudioRecordingCallback(java.util.concurrent.Executor, android.media.AudioManager.AudioRecordingCallback).


Inherited methods - From interface android.media.MicrophoneDirection:

From interface android.media.MicrophoneDirection

abstract boolean

setPreferredMicrophoneDirection(int direction)

Specifies the logical microphone (for processing).

abstract boolean

setPreferredMicrophoneFieldDimension(float zoom)

Specifies the zoom factor


參考網址:
※ MediaRecorder
※ MediaRecorder 概覽

2022年 3月 22日(Tue)天氣報告
氣溫:49.0°F / 9.0°C @ 07:00
風速:每小時 5公里
降雨機會:35%
相對濕度:百分之 82%
天氣:霧

沒有留言:

張貼留言