# 媒体子系统JS API变更 OpenHarmony 3.2 Canary1版本相较于OpenHarmony 3.1 Release版本,媒体子系统的API变更如下: ## 接口变更 | 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | |---|---|---|---| | ohos.multimedia.audio | AudioRenderer | on(type: 'interrupt', callback: Callback\): void; | 新增 | | ohos.multimedia.audio | InterruptEvent | hintType: InterruptHint; | 新增 | | ohos.multimedia.audio | InterruptEvent | forceType: InterruptForceType; | 新增 | | ohos.multimedia.audio | InterruptEvent | eventType: InterruptType; | 新增 | | ohos.multimedia.audio | InterruptForceType | INTERRUPT_SHARE | 新增 | | ohos.multimedia.audio | InterruptForceType | INTERRUPT_FORCE = 0 | 新增 | | ohos.multimedia.camera | VideoOutputError | code: VideoOutputErrorCode; | 新增 | | ohos.multimedia.camera | VideoOutputErrorCode | ERROR_UNKNOWN = -1 | 新增 | | ohos.multimedia.camera | VideoOutput | on(type: 'error', callback: ErrorCallback\): void; | 新增 | | ohos.multimedia.camera | VideoOutput | on(type: 'frameEnd', callback: AsyncCallback\): void; | 新增 | | ohos.multimedia.camera | VideoOutput | on(type: 'frameStart', callback: AsyncCallback\): void; | 新增 | | ohos.multimedia.camera | VideoOutput | release(callback: AsyncCallback\): void;
release(): Promise\; | 新增 | | ohos.multimedia.camera | VideoOutput | stop(callback: AsyncCallback\): void;
stop(): Promise\; | 新增 | | ohos.multimedia.camera | VideoOutput | start(callback: AsyncCallback\): void;
start(): Promise\; | 新增 | | ohos.multimedia.camera | camera | createVideoOutput(surfaceId: string, callback: AsyncCallback\): void;
createVideoOutput(surfaceId: string): Promise\; | 新增 | | ohos.multimedia.camera | PhotoOutputError | code: PhotoOutputErrorCode; | 新增 | | ohos.multimedia.camera | PhotoOutputErrorCode | ERROR_UNKNOWN = -1 | 新增 | | ohos.multimedia.camera | CaptureEndInfo | frameCount: number; | 新增 | | ohos.multimedia.camera | CaptureEndInfo | captureId: number; | 新增 | | ohos.multimedia.camera | FrameShutterInfo | timestamp: number; | 新增 | | ohos.multimedia.camera | FrameShutterInfo | captureId: number; | 新增 | | ohos.multimedia.camera | PhotoOutput | on(type: 'error', callback: ErrorCallback\): void; | 新增 | | ohos.multimedia.camera | PhotoOutput | on(type: 'captureEnd', callback: AsyncCallback\): void; | 新增 | | ohos.multimedia.camera | PhotoOutput | on(type: 'frameShutter', callback: AsyncCallback\): void; | 新增 | | ohos.multimedia.camera | PhotoOutput | on(type: 'captureStart', callback: AsyncCallback\): void; | 新增 | | ohos.multimedia.camera | PhotoOutput | release(callback: AsyncCallback\): void;
release(): Promise\; | 新增 | | ohos.multimedia.camera | PhotoOutput | capture(callback: AsyncCallback\): void;
capture(setting: PhotoCaptureSetting, callback: AsyncCallback\): void;
capture(setting?: PhotoCaptureSetting): Promise\; | 新增 | | ohos.multimedia.camera | PhotoCaptureSetting | rotation?: ImageRotation; | 新增 | | ohos.multimedia.camera | PhotoCaptureSetting | quality?: QualityLevel; | 新增 | | ohos.multimedia.camera | QualityLevel | QUALITY_LEVEL_LOW | 新增 | | ohos.multimedia.camera | QualityLevel | QUALITY_LEVEL_MEDIUM | 新增 | | ohos.multimedia.camera | QualityLevel | QUALITY_LEVEL_HIGH = 0 | 新增 | | ohos.multimedia.camera | ImageRotation | ROTATION_270 = 270 | 新增 | | ohos.multimedia.camera | ImageRotation | ROTATION_180 = 180 | 新增 | | ohos.multimedia.camera | ImageRotation | ROTATION_90 = 90 | 新增 | | ohos.multimedia.camera | ImageRotation | ROTATION_0 = 0 | 新增 | | ohos.multimedia.camera | camera | createPhotoOutput(surfaceId: string, callback: AsyncCallback\): void;
createPhotoOutput(surfaceId: string): Promise\; | 新增 | | ohos.multimedia.camera | PreviewOutputError | code: PreviewOutputErrorCode; | 新增 | | ohos.multimedia.camera | PreviewOutputErrorCode | ERROR_UNKNOWN = -1 | 新增 | | ohos.multimedia.camera | PreviewOutput | on(type: 'error', callback: ErrorCallback\): void; | 新增 | | ohos.multimedia.camera | PreviewOutput | on(type: 'frameEnd', callback: AsyncCallback\): void; | 新增 | | ohos.multimedia.camera | PreviewOutput | on(type: 'frameStart', callback: AsyncCallback\): void; | 新增 | | ohos.multimedia.camera | PreviewOutput | release(callback: AsyncCallback\): void;
release(): Promise\; | 新增 | | ohos.multimedia.camera | camera | createPreviewOutput(surfaceId: string, callback: AsyncCallback\): void;
createPreviewOutput(surfaceId: string): Promise\; | 新增 | | ohos.multimedia.camera | CaptureSessionError | code: CaptureSessionErrorCode; | 新增 | | ohos.multimedia.camera | CaptureSessionErrorCode | ERROR_UNKNOWN = -1 | 新增 | | ohos.multimedia.camera | CaptureSession | on(type: 'error', callback: ErrorCallback\): void; | 新增 | | ohos.multimedia.camera | CaptureSession | release(callback: AsyncCallback\): void;
release(): Promise\; | 新增 | | ohos.multimedia.camera | CaptureSession | stop(callback: AsyncCallback\): void;
stop(): Promise\; | 新增 | | ohos.multimedia.camera | CaptureSession | start(callback: AsyncCallback\): void;
start(): Promise\; | 新增 | | ohos.multimedia.camera | CaptureSession | removeOutput(previewOutput: PreviewOutput, callback: AsyncCallback\): void;
removeOutput(previewOutput: PreviewOutput): Promise\;
removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback\): void;
removeOutput(photoOutput: PhotoOutput): Promise\;
removeOutput(videoOutput: VideoOutput, callback: AsyncCallback\): void;
removeOutput(videoOutput: VideoOutput): Promise\; | 新增 | | ohos.multimedia.camera | CaptureSession | removeInput(cameraInput: CameraInput, callback: AsyncCallback\): void;
removeInput(cameraInput: CameraInput): Promise\; | 新增 | | ohos.multimedia.camera | CaptureSession | addOutput(previewOutput: PreviewOutput, callback: AsyncCallback\): void;
addOutput(previewOutput: PreviewOutput): Promise\;
addOutput(photoOutput: PhotoOutput, callback: AsyncCallback\): void;
addOutput(photoOutput: PhotoOutput): Promise\;
addOutput(videoOutput: VideoOutput, callback: AsyncCallback\): void;
addOutput(videoOutput: VideoOutput): Promise\; | 新增 | | ohos.multimedia.camera | CaptureSession | addInput(cameraInput: CameraInput, callback: AsyncCallback\): void;
addInput(cameraInput: CameraInput): Promise\; | 新增 | | ohos.multimedia.camera | CaptureSession | commitConfig(callback: AsyncCallback\): void;
commitConfig(): Promise\; | 新增 | | ohos.multimedia.camera | CaptureSession | beginConfig(callback: AsyncCallback\): void;
beginConfig(): Promise\; | 新增 | | ohos.multimedia.camera | camera | createCaptureSession(context: Context, callback: AsyncCallback\): void;
createCaptureSession(context: Context): Promise\; | 新增 | | ohos.multimedia.camera | FocusState | FOCUS_STATE_UNFOCUSED | 新增 | | ohos.multimedia.camera | FocusState | FOCUS_STATE_FOCUSED | 新增 | | ohos.multimedia.camera | FocusState | FOCUS_STATE_SCAN = 0 | 新增 | | ohos.multimedia.camera | FocusMode | FOCUS_MODE_LOCKED | 新增 | | ohos.multimedia.camera | FocusMode | FOCUS_MODE_AUTO | 新增 | | ohos.multimedia.camera | FocusMode | FOCUS_MODE_CONTINUOUS_AUTO | 新增 | | ohos.multimedia.camera | FocusMode | FOCUS_MODE_MANUAL = 0 | 新增 | | ohos.multimedia.camera | FlashMode | FLASH_MODE_ALWAYS_OPEN | 新增 | | ohos.multimedia.camera | FlashMode | FLASH_MODE_AUTO | 新增 | | ohos.multimedia.camera | FlashMode | FLASH_MODE_OPEN | 新增 | | ohos.multimedia.camera | FlashMode | FLASH_MODE_CLOSE = 0 | 新增 | | ohos.multimedia.camera | CameraInputError | code: CameraInputErrorCode; | 新增 | | ohos.multimedia.camera | CameraInputErrorCode | ERROR_UNKNOWN = -1 | 新增 | | ohos.multimedia.camera | CameraInput | on(type: 'error', callback: ErrorCallback\): void; | 新增 | | ohos.multimedia.camera | CameraInput | on(type: 'focusStateChange', callback: AsyncCallback\): void; | 新增 | | ohos.multimedia.camera | CameraInput | release(callback: AsyncCallback\): void;
release(): Promise\; | 新增 | | ohos.multimedia.camera | CameraInput | setZoomRatio(zoomRatio: number, callback: AsyncCallback\): void;
setZoomRatio(zoomRatio: number): Promise\; | 新增 | | ohos.multimedia.camera | CameraInput | getZoomRatio(callback: AsyncCallback\): void;
getZoomRatio(): Promise\; | 新增 | | ohos.multimedia.camera | CameraInput | getZoomRatioRange(callback: AsyncCallback\>): void;
getZoomRatioRange(): Promise\>; | 新增 | | ohos.multimedia.camera | CameraInput | setFocusMode(afMode: FocusMode, callback: AsyncCallback\): void;
setFocusMode(afMode: FocusMode): Promise\; | 新增 | | ohos.multimedia.camera | CameraInput | getFocusMode(callback: AsyncCallback\): void;
getFocusMode(): Promise\; | 新增 | | ohos.multimedia.camera | CameraInput | isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback\): void;
isFocusModeSupported(afMode: FocusMode): Promise\; | 新增 | | ohos.multimedia.camera | CameraInput | setFlashMode(flashMode: FlashMode, callback: AsyncCallback\): void;
setFlashMode(flashMode: FlashMode): Promise\; | 新增 | | ohos.multimedia.camera | CameraInput | getFlashMode(callback: AsyncCallback\): void;
getFlashMode(): Promise\; | 新增 | | ohos.multimedia.camera | CameraInput | isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback\): void;
isFlashModeSupported(flashMode: FlashMode): Promise\; | 新增 | | ohos.multimedia.camera | CameraInput | hasFlash(callback: AsyncCallback\): void;
hasFlash(): Promise\; | 新增 | | ohos.multimedia.camera | CameraInput | getCameraId(callback: AsyncCallback\): void;
getCameraId(): Promise\; | 新增 | | ohos.multimedia.camera | Size | width: number; | 新增 | | ohos.multimedia.camera | Size | height: number; | 新增 | | ohos.multimedia.camera | Camera | readonly connectionType: ConnectionType; | 新增 | | ohos.multimedia.camera | Camera | readonly cameraType: CameraType; | 新增 | | ohos.multimedia.camera | Camera | readonly cameraPosition: CameraPosition; | 新增 | | ohos.multimedia.camera | Camera | readonly cameraId: string; | 新增 | | ohos.multimedia.camera | ConnectionType | CAMERA_CONNECTION_REMOTE | 新增 | | ohos.multimedia.camera | ConnectionType | CAMERA_CONNECTION_USB_PLUGIN | 新增 | | ohos.multimedia.camera | ConnectionType | CAMERA_CONNECTION_BUILT_IN = 0 | 新增 | | ohos.multimedia.camera | CameraType | CAMERA_TYPE_TRUE_DEPTH | 新增 | | ohos.multimedia.camera | CameraType | CAMERA_TYPE_TELEPHOTO | 新增 | | ohos.multimedia.camera | CameraType | CAMERA_TYPE_ULTRA_WIDE | 新增 | | ohos.multimedia.camera | CameraType | CAMERA_TYPE_WIDE_ANGLE | 新增 | | ohos.multimedia.camera | CameraType | CAMERA_TYPE_UNSPECIFIED = 0 | 新增 | | ohos.multimedia.camera | CameraPosition | CAMERA_POSITION_FRONT | 新增 | | ohos.multimedia.camera | CameraPosition | CAMERA_POSITION_BACK | 新增 | | ohos.multimedia.camera | CameraPosition | CAMERA_POSITION_UNSPECIFIED = 0 | 新增 | | ohos.multimedia.camera | CameraStatusInfo | status: CameraStatus; | 新增 | | ohos.multimedia.camera | CameraStatusInfo | camera: Camera; | 新增 | | ohos.multimedia.camera | CameraManager | on(type: 'cameraStatus', callback: AsyncCallback\): void; | 新增 | | ohos.multimedia.camera | CameraManager | createCameraInput(cameraId: string, callback: AsyncCallback\): void;
createCameraInput(cameraId: string): Promise\;
createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback\): void;
createCameraInput(position: CameraPosition, type: CameraType): Promise\; | 新增 | | ohos.multimedia.camera | CameraManager | getCameras(callback: AsyncCallback\>): void;
getCameras(): Promise\>; | 新增 | | ohos.multimedia.camera | CameraStatus | CAMERA_STATUS_UNAVAILABLE | 新增 | | ohos.multimedia.camera | CameraStatus | CAMERA_STATUS_AVAILABLE | 新增 | | ohos.multimedia.camera | CameraStatus | CAMERA_STATUS_DISAPPEAR | 新增 | | ohos.multimedia.camera | CameraStatus | CAMERA_STATUS_APPEAR = 0 | 新增 | | ohos.multimedia.camera | camera | getCameraManager(context: Context, callback: AsyncCallback\): void;
getCameraManager(context: Context): Promise\; | 新增 | | ohos.multimedia.image | ImageReceiver | release(callback: AsyncCallback\): void;
release(): Promise\; | 新增 | | ohos.multimedia.image | ImageReceiver | on(type: 'imageArrival', callback: AsyncCallback\): void; | 新增 | | ohos.multimedia.image | ImageReceiver | readNextImage(callback: AsyncCallback\): void;
readNextImage(): Promise\; | 新增 | | ohos.multimedia.image | ImageReceiver | readLatestImage(callback: AsyncCallback\): void;
readLatestImage(): Promise\; | 新增 | | ohos.multimedia.image | ImageReceiver | getReceivingSurfaceId(callback: AsyncCallback\): void;
getReceivingSurfaceId(): Promise\; | 新增 | | ohos.multimedia.image | ImageReceiver | readonly format: ImageFormat; | 新增 | | ohos.multimedia.image | ImageReceiver | readonly capacity: number; | 新增 | | ohos.multimedia.image | ImageReceiver | readonly size: Size; | 新增 | | ohos.multimedia.image | Image | release(callback: AsyncCallback\): void;
release(): Promise\; | 新增 | | ohos.multimedia.image | Image | getComponent(componentType: ComponentType, callback: AsyncCallback\): void;
getComponent(componentType: ComponentType): Promise\; | 新增 | | ohos.multimedia.image | Image | readonly format: number; | 新增 | | ohos.multimedia.image | Image | readonly size: Size; | 新增 | | ohos.multimedia.image | Image | clipRect: Region; | 新增 | | ohos.multimedia.image | image | createImageReceiver(width: number, height: number, format: number, capacity: number): ImageReceiver; | 新增 | | ohos.multimedia.image | Component | readonly byteBuffer: ArrayBuffer; | 新增 | | ohos.multimedia.image | Component | readonly pixelStride: number; | 新增 | | ohos.multimedia.image | Component | readonly rowStride: number; | 新增 | | ohos.multimedia.image | Component | readonly componentType: ComponentType; | 新增 | | ohos.multimedia.image | ComponentType | JPEG = 4 | 新增 | | ohos.multimedia.image | ComponentType | YUV_V = 3 | 新增 | | ohos.multimedia.image | ComponentType | YUV_U = 2 | 新增 | | ohos.multimedia.image | ComponentType | YUV_Y = 1 | 新增 | | ohos.multimedia.image | ImageFormat | JPEG = 2000 | 新增 | | ohos.multimedia.image | ImageFormat | YCBCR_422_SP = 1000 | 新增 | | ohos.multimedia.media | VideoRecorderConfig | location?: Location; | 新增 | | ohos.multimedia.media | VideoRecorderConfig | rotation?: number; | 新增 | | ohos.multimedia.media | VideoRecorderConfig | url: string; | 新增 | | ohos.multimedia.media | VideoRecorderConfig | profile: VideoRecorderProfile; | 新增 | | ohos.multimedia.media | VideoRecorderConfig | videoSourceType: VideoSourceType; | 新增 | | ohos.multimedia.media | VideoRecorderConfig | audioSourceType: AudioSourceType; | 新增 | | ohos.multimedia.media | VideoSourceType | VIDEO_SOURCE_TYPE_SURFACE_ES = 1 | 新增 | | ohos.multimedia.media | VideoSourceType | VIDEO_SOURCE_TYPE_SURFACE_YUV = 0 | 新增 | | ohos.multimedia.media | AudioSourceType | AUDIO_SOURCE_TYPE_MIC = 1 | 新增 | | ohos.multimedia.media | AudioSourceType | AUDIO_SOURCE_TYPE_DEFAULT = 0 | 新增 | | ohos.multimedia.media | VideoRecorderProfile | readonly videoFrameRate: number; | 新增 | | ohos.multimedia.media | VideoRecorderProfile | readonly videoFrameHeight: number; | 新增 | | ohos.multimedia.media | VideoRecorderProfile | readonly videoFrameWidth: number; | 新增 | | ohos.multimedia.media | VideoRecorderProfile | readonly videoCodec: CodecMimeType; | 新增 | | ohos.multimedia.media | VideoRecorderProfile | readonly videoBitrate: number; | 新增 | | ohos.multimedia.media | VideoRecorderProfile | readonly fileFormat: ContainerFormatType; | 新增 | | ohos.multimedia.media | VideoRecorderProfile | readonly audioSampleRate: number; | 新增 | | ohos.multimedia.media | VideoRecorderProfile | readonly audioCodec: CodecMimeType; | 新增 | | ohos.multimedia.media | VideoRecorderProfile | readonly audioChannels: number; | 新增 | | ohos.multimedia.media | VideoRecorderProfile | readonly audioBitrate: number; | 新增 | | ohos.multimedia.media | VideoRecorder | readonly state: VideoRecordState; | 新增 | | ohos.multimedia.media | VideoRecorder | on(type: 'error', callback: ErrorCallback): void; | 新增 | | ohos.multimedia.media | VideoRecorder | reset(callback: AsyncCallback\): void;
reset(): Promise\; | 新增 | | ohos.multimedia.media | VideoRecorder | release(callback: AsyncCallback\): void;
release(): Promise\; | 新增 | | ohos.multimedia.media | VideoRecorder | stop(callback: AsyncCallback\): void;
stop(): Promise\; | 新增 | | ohos.multimedia.media | VideoRecorder | resume(callback: AsyncCallback\): void;
resume(): Promise\; | 新增 | | ohos.multimedia.media | VideoRecorder | pause(callback: AsyncCallback\): void;
pause(): Promise\; | 新增 | | ohos.multimedia.media | VideoRecorder | start(callback: AsyncCallback\): void;
start(): Promise\; | 新增 | | ohos.multimedia.media | VideoRecorder | getInputSurface(callback: AsyncCallback\): void;
getInputSurface(): Promise\; | 新增 | | ohos.multimedia.media | VideoRecorder | prepare(config: VideoRecorderConfig, callback: AsyncCallback\): void;
prepare(config: VideoRecorderConfig): Promise\; | 新增 | | ohos.multimedia.media | media | createVideoRecorder(callback: AsyncCallback\): void;
createVideoRecorder(): Promise\; | 新增 |