• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15import type Context from './application/Context';
16import type camera from './@ohos.multimedia.camera';
17
18/**
19 * @namespace cameraPicker
20 * @syscap SystemCapability.Multimedia.Camera.Core
21 * @since 11
22 */
23declare namespace cameraPicker {
24
25  /**
26   * Picker profile settings for take photo and record video.
27   *
28   * @syscap SystemCapability.Multimedia.Camera.Core
29   * @since 11
30   */
31  class PickerProfile {
32    /**
33     * The camera position to be used.
34     *
35     * @type { camera.CameraPosition }
36     * @syscap SystemCapability.Multimedia.Camera.Core
37     * @since 11
38     */
39    cameraPosition: camera.CameraPosition;
40
41    /**
42     * The uri of the result to be saved.
43     *
44     * @type { ?string }
45     * @syscap SystemCapability.Multimedia.Camera.Core
46     * @since 11
47     */
48    saveUri?: string;
49
50    /**
51     * The max duration of the video.
52     *
53     * @type { ?number }
54     * @syscap SystemCapability.Multimedia.Camera.Core
55     * @since 11
56     */
57    videoDuration?: number;
58  }
59
60  /**
61   * Enum for camera picker media type.
62   *
63   * @enum { string }
64   * @syscap SystemCapability.Multimedia.Camera.Core
65   * @since 11
66   */
67  enum PickerMediaType {
68    /**
69     * Type image, picker provide an ability to take photo.
70     *
71     * @syscap SystemCapability.Multimedia.Camera.Core
72     * @since 11
73     */
74    PHOTO = 'photo',
75
76    /**
77     * Type video, picker provide an ability to record video.
78     *
79     * @syscap SystemCapability.Multimedia.Camera.Core
80     * @since 11
81     */
82    VIDEO = 'video'
83  }
84
85  /**
86   * The picker result info for pick function.
87   *
88   * @syscap SystemCapability.Multimedia.Camera.Core
89   * @since 11
90   */
91  class PickerResult {
92    /**
93     * The result code.
94     *
95     * @type { number }
96     * @syscap SystemCapability.Multimedia.Camera.Core
97     * @since 11
98     */
99    resultCode: number;
100
101    /**
102     * The result saved uri.
103     *
104     * @type { number }
105     * @syscap SystemCapability.Multimedia.Camera.Core
106     * @since 11
107     */
108    resultUri: string;
109
110    /**
111     * The result resource type.
112     *
113     * @type { PickerMediaType }
114     * @syscap SystemCapability.Multimedia.Camera.Core
115     * @since 11
116     */
117    mediaType: PickerMediaType;
118  }
119
120  /**
121   * Pick function to get a photo or video result.
122   *
123   * @param { Context } context - From UIExtensionAbility.
124   * @param { Array<PickerMediaType> } mediaTypes - Pick media type.
125   * @param { PickerProfile } pickerProfile - Picker input Profile.
126   * @returns { Promise<PickerResult> } pick result.
127   * @syscap SystemCapability.Multimedia.Camera.Core
128   * @since 11
129   */
130  function pick(context: Context, mediaTypes: Array<PickerMediaType>, pickerProfile: PickerProfile): Promise<PickerResult>;
131}
132
133export default cameraPicker;