public class Recorder extends Object
This class provides the following methods:
setSource(ohos.media.common.Source): Sets the audio and video source.
setAudioProperty(ohos.media.common.AudioProperty): Sets audio properties.
setOutputFormat(int): Sets the output format.
setVideoProperty(ohos.media.common.VideoProperty): Sets video properties.
setStorageProperty(ohos.media.common.StorageProperty): Sets video and audio storage properties.
prepare(): Prepares for recording.
start(): Starts recording.
stop(): Stops recording.
SystemCapability.Multimedia#MEDIA| 限定符和类型 | 类 | 说明 |
|---|---|---|
static class |
Recorder.AudioEncoder |
Describes the audio encoding format.
|
static class |
Recorder.AudioSource |
Describes the audio source.
|
static interface |
Recorder.IRecorderListener |
Listens for errors, alarms, and info events related to audio and video recording.
|
static class |
Recorder.OrientationHint |
Describes the rotation angle used during video playback.
|
static class |
Recorder.OutputFormat |
Describes the format of the output media.
|
static class |
Recorder.RecorderOnErrorType |
Describes recording framework errors.
|
static class |
Recorder.RecorderOnInfoType |
Describes recording framework info events and alarms.
|
static class |
Recorder.VideoEncoder |
Describes the available video encoding formats, including H.264 and high efficiency video coding (HEVC).
|
static class |
Recorder.VideoSource |
Describes the video source, including the camera and surface.
|
| 构造器 | 说明 |
|---|---|
Recorder() |
A constructor used to create a
Recorder instance. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
protected void |
finalize() |
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
Surface |
getVideoSurface() |
Obtains the video surface.
|
int |
obtainMaxAmplitude() |
Obtains the maximum absolute amplitude in the audio source sampling data.
|
boolean |
pause() |
Pauses recording.
|
boolean |
prepare() |
Prepares recording resources.
|
void |
registerRecorderListener(Recorder.IRecorderListener listener) |
Registers a recording listener.
|
boolean |
release() |
Releases recording resources.
|
boolean |
reset() |
Resets recording.
|
boolean |
resume() |
Resumes recording.
|
boolean |
setAudioProperty(AudioProperty property) |
Sets audio properties.
|
boolean |
setOutputFormat(int outputFormat) |
Sets the output file format.
|
boolean |
setRecorderLocation(float latitude,
float longitude) |
Sets the longitude and latitude of a video.
|
boolean |
setRecorderProfile(RecorderProfile profile) |
Sets the recording configuration.
|
boolean |
setSource(Source source) |
Sets the audio and video source.
|
boolean |
setStorageProperty(StorageProperty property) |
Sets the audio and video storage properties.
|
boolean |
setVideoProperty(VideoProperty property) |
Sets video properties.
|
boolean |
start() |
Starts recording.
|
boolean |
stop() |
Stops recording.
|
public boolean setSource(Source source)
source - Indicates the audio and video source. For details, see Source.true if the setting is successful; returns false otherwise.public boolean setAudioProperty(AudioProperty property)
property - Indicates the audio properties, which include the number of audio channels, audio encoding
format, encoding bit rate, and sampling rate. For details, see AudioProperty.true if the setting is successful; returns false otherwise.public boolean setVideoProperty(VideoProperty property)
property - Indicates video properties, which include the video width and height, encoding format, frame
capture rate, rotation angle, frame rate, and encoding bit rate. For details, see VideoProperty.true if the setting is successful; returns false otherwise.public boolean setStorageProperty(StorageProperty property)
property - Indicates the audio and video storage properties, which include the maximum recording duration,
maximum recording file size, output file descriptor, output file object, and output file path.For details,
see StorageProperty.true if the setting is successful; returns false otherwise.public boolean prepare()
true if the resources are prepared; returns false otherwise.public boolean start()
true if the recording is started; returns false otherwise.public boolean stop()
true if the recording is stopped; returns false otherwise.public boolean pause()
true if the recording is paused; returns false otherwise.public boolean resume()
true if the recording is resumed; returns false otherwise.public boolean reset()
true if the recording is reset; returns false otherwise.public boolean setRecorderLocation(float latitude,
float longitude)
latitude - Indicates the latitude.longitude - Indicates the longitude.true if the setting is successful; returns false otherwise.public boolean setOutputFormat(int outputFormat)
outputFormat - Indicates the output file format.true if the setting is successful; returns false otherwise.public Surface getVideoSurface()
public boolean setRecorderProfile(RecorderProfile profile)
profile - Indicates the recording configuration. For details, see RecorderProfile.true if the setting is successful; returns false otherwise.public void registerRecorderListener(Recorder.IRecorderListener listener)
listener - Indicates a recording listener. For details, see IRecorderListener.public boolean release()
true if the resources are released; returns false otherwise.protected void finalize()
throws Throwable
Objectfinalize method to dispose of
system resources or to perform other cleanup.
The general contract of finalize is that it is invoked
if and when the Java™ virtual
machine has determined that there is no longer any
means by which this object can be accessed by any thread that has
not yet died, except as a result of an action taken by the
finalization of some other object or class which is ready to be
finalized. The finalize method may take any action, including
making this object available again to other threads; the usual purpose
of finalize, however, is to perform cleanup actions before
the object is irrevocably discarded. For example, the finalize method
for an object that represents an input/output connection might perform
explicit I/O transactions to break the connection before the object is
permanently discarded.
The finalize method of class Object performs no
special action; it simply returns normally. Subclasses of
Object may override this definition.
The Java programming language does not guarantee which thread will
invoke the finalize method for any given object. It is
guaranteed, however, that the thread that invokes finalize will not
be holding any user-visible synchronization locks when finalize is
invoked. If an uncaught exception is thrown by the finalize method,
the exception is ignored and finalization of that object terminates.
After the finalize method has been invoked for an object, no
further action is taken until the Java virtual machine has again
determined that there is no longer any means by which this object can
be accessed by any thread that has not yet died, including possible
actions by other objects or classes which are ready to be finalized,
at which point the object may be discarded.
The finalize method is never invoked more than once by a Java
virtual machine for any given object.
Any exception thrown by the finalize method causes
the finalization of this object to be halted, but is otherwise
ignored.
finalize 在类中 ObjectThrowable - the Exception raised by this methodWeakReference,
PhantomReferencepublic int obtainMaxAmplitude()
this method used for recording and must be called after setSource(ohos.media.common.Source).
IllegalStateException - Throws this exception if setSource is not set before.