• 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 */
15
16/**
17 * @file
18 * @kit ArkUI
19 */
20
21import type BaseContext from './application/BaseContext';
22import type { Callback } from './@ohos.base';
23import { NodeController } from './arkui/NodeController';
24import { typeNode } from './arkui/FrameNode';
25
26/**
27 * Picture In Picture Window Manager
28 *
29 * @namespace PiPWindow
30 * @syscap SystemCapability.Window.SessionManager
31 * @since 11
32 */
33/**
34 * Picture In Picture Window Manager
35 *
36 * @namespace PiPWindow
37 * @syscap SystemCapability.Window.SessionManager
38 * @atomicservice
39 * @since 12
40 */
41declare namespace PiPWindow {
42  /**
43   * If picture-in-picture enabled in current OS.
44   *
45   * @returns { boolean } true if PictureInPicture enabled, otherwise false
46   * @syscap SystemCapability.Window.SessionManager
47   * @since 11
48   */
49  /**
50   * If picture-in-picture enabled in current OS.
51   *
52   * @returns { boolean } true if PictureInPicture enabled, otherwise false
53   * @syscap SystemCapability.Window.SessionManager
54   * @atomicservice
55   * @since 12
56   */
57  function isPiPEnabled(): boolean;
58
59  /**
60   * Create picture-in-picture controller
61   *
62   * @param { PiPConfiguration } config - Params for picture-in-picture controller creation. The config must be valid,
63   * the context and componentController in config should not be null. If templateType is specified, make sure
64   * it's type of PiPTemplateType. If controlGroups is specified, make sure it correspond to the templateType.
65   * @returns { Promise<PiPController> } - The promise returned by the function
66   * @throws { BusinessError } 401 - Params error. Possible causes: 1. Mandatory parameters are left unspecified.
67   *                                                                2. Incorrect parameter types.
68   *                                                                3. Parameter verification failed
69   * @throws { BusinessError } 801 - Capability not supported. Failed to call the API due to limited device capabilities.
70   * @syscap SystemCapability.Window.SessionManager
71   * @since 11
72   */
73  /**
74   * Create picture-in-picture controller
75   *
76   * @param { PiPConfiguration } config - Params for picture-in-picture controller creation. The config must be valid,
77   * the context and componentController in config should not be null. If templateType is specified, make sure
78   * it's type of PiPTemplateType. If controlGroups is specified, make sure it correspond to the templateType.
79   * @returns { Promise<PiPController> } - The promise returned by the function
80   * @throws { BusinessError } 401 - Params error. Possible causes: 1. Mandatory parameters are left unspecified.
81   *                                                                2. Incorrect parameter types.
82   *                                                                3. Parameter verification failed
83   * @throws { BusinessError } 801 - Capability not supported. Failed to call the API due to limited device capabilities.
84   * @syscap SystemCapability.Window.SessionManager
85   * @atomicservice
86   * @since 12
87   */
88  function create(config: PiPConfiguration): Promise<PiPController>;
89
90  /**
91   * Create picture-in-picture controller
92   *
93   * @param { PiPConfiguration } config - Params for picture-in-picture controller creation. The config must be valid,
94   * the context and componentController in config should not be null. If templateType is specified, make sure
95   * it's type of PiPTemplateType. If controlGroups is specified, make sure it correspond to the templateType.
96   * @param { typeNode.XComponent } contentNode - Params for picture-in-picture controller creation.
97   * Indicates the node which display the content of pip window.
98   * @returns { Promise<PiPController> } - The promise returned by the function
99   * @throws { BusinessError } 401 - Params error. Possible causes: 1. Mandatory parameters are left unspecified.
100   *                                                                2. Incorrect parameter types.
101   *                                                                3. Parameter verification failed.
102   * @throws { BusinessError } 801 - Capability not supported. Failed to call the API due to limited device capabilities.
103   * @syscap SystemCapability.Window.SessionManager
104   * @atomicservice
105   * @since 12
106   */
107  function create(config: PiPConfiguration, contentNode: typeNode.XComponent): Promise<PiPController>;
108
109  /**
110   * PiPConfiguration
111   *
112   * @interface PiPConfiguration
113   * @syscap SystemCapability.Window.SessionManager
114   * @since 11
115   */
116  /**
117   * PiPConfiguration
118   *
119   * @interface PiPConfiguration
120   * @syscap SystemCapability.Window.SessionManager
121   * @atomicservice
122   * @since 12
123   */
124  interface PiPConfiguration {
125    /**
126     * Indicates window context.
127     *
128     * @type { BaseContext }
129     * @syscap SystemCapability.Window.SessionManager
130     * @since 11
131     */
132    /**
133     * Indicates window context.
134     *
135     * @type { BaseContext }
136     * @syscap SystemCapability.Window.SessionManager
137     * @atomicservice
138     * @since 12
139     */
140    context: BaseContext;
141
142    /**
143     * Indicates the origin XComponentController.
144     *
145     * @type { XComponentController }
146     * @syscap SystemCapability.Window.SessionManager
147     * @since 11
148     */
149    /**
150     * Indicates the origin XComponentController.
151     *
152     * @type { XComponentController }
153     * @syscap SystemCapability.Window.SessionManager
154     * @atomicservice
155     * @since 12
156     */
157    componentController: XComponentController;
158
159    /**
160     * Indicates navigation ID.
161     *
162     * @type { ?string }
163     * @syscap SystemCapability.Window.SessionManager
164     * @since 11
165     */
166    /**
167     * Indicates navigation ID.
168     *
169     * @type { ?string }
170     * @syscap SystemCapability.Window.SessionManager
171     * @atomicservice
172     * @since 12
173     */
174    navigationId?: string;
175
176    /**
177     * Picture-in-picture template type.
178     *
179     * @type { ?PiPTemplateType }
180     * @syscap SystemCapability.Window.SessionManager
181     * @since 11
182     */
183    /**
184     * Picture-in-picture template type.
185     *
186     * @type { ?PiPTemplateType }
187     * @syscap SystemCapability.Window.SessionManager
188     * @atomicservice
189     * @since 12
190     */
191    templateType?: PiPTemplateType;
192
193    /**
194     * Describes the width of content to be displayed in PiP window. For adjusting PiP window aspect ratio.
195     *
196     * @type { ?number }
197     * @syscap SystemCapability.Window.SessionManager
198     * @since 11
199     */
200    /**
201     * Describes the width of content to be displayed in PiP window. For adjusting PiP window aspect ratio.
202     *
203     * @type { ?number }
204     * @syscap SystemCapability.Window.SessionManager
205     * @atomicservice
206     * @since 12
207     */
208    contentWidth?: number;
209
210    /**
211     * Describes the height of content to be displayed in PiP window. For adjusting PiP window aspect ratio.
212     *
213     * @type { ?number }
214     * @syscap SystemCapability.Window.SessionManager
215     * @since 11
216     */
217    /**
218     * Describes the height of content to be displayed in PiP window. For adjusting PiP window aspect ratio.
219     *
220     * @type { ?number }
221     * @syscap SystemCapability.Window.SessionManager
222     * @atomicservice
223     * @since 12
224     */
225    contentHeight?: number;
226
227    /**
228     * Describes the custom controls to be displayed in PiP window control panel. If the parameter is empty, only mandatory controls are displayed.
229     *
230     * @type { ?Array<PiPControlGroup> }
231     * @syscap SystemCapability.Window.SessionManager
232     * @atomicservice
233     * @since 12
234     */
235    controlGroups?: Array<PiPControlGroup>;
236
237    /**
238     * Describes the customUIController by which we can display a custom layout above pip content.
239     *
240     * @type { ?NodeController }
241     * @syscap SystemCapability.Window.SessionManager
242     * @atomicservice
243     * @since 12
244     */
245    customUIController?: NodeController;
246
247    /**
248     * Describes the data object shared within the content instance loaded by the window.
249     *
250     * @type { ?LocalStorage }
251     * @syscap SystemCapability.Window.SessionManager
252     * @atomicservice
253     * @since 17
254     */
255    localStorage?: LocalStorage;
256  }
257
258  /**
259   * The picture-in-picture window size
260   *
261   * @interface PiPWindowSize
262   * @syscap SystemCapability.Window.SessionManager
263   * @atomicservice
264   * @since 15
265   */
266   interface PiPWindowSize {
267    /**
268     * The width of the picture-in-picture window.
269     *
270     * @type { number }
271     * @syscap SystemCapability.Window.SessionManager
272     * @atomicservice
273     * @since 15
274     */
275    width: number;
276
277    /**
278     * The height of the picture-in-picture window.
279     *
280     * @type { number }
281     * @syscap SystemCapability.Window.SessionManager
282     * @atomicservice
283     * @since 15
284     */
285    height: number;
286
287    /**
288     * The scale of the picture-in-picture window.
289     *
290     * @type { number }
291     * @syscap SystemCapability.Window.SessionManager
292     * @atomicservice
293     * @since 15
294     */
295    scale: number;
296  }
297
298  /**
299   * The info of picture-in-picture window
300   *
301   * @interface PiPWindowInfo
302   * @syscap SystemCapability.Window.SessionManager
303   * @atomicservice
304   * @since 15
305   */
306  interface PiPWindowInfo {
307    /**
308     * Indicates target window id.
309     *
310     * @type { number }
311     * @syscap SystemCapability.Window.SessionManager
312     * @atomicservice
313     * @since 15
314     */
315    windowId: number;
316
317    /**
318     * The picture-in-picture window size.
319     *
320     * @type { PiPWindowSize }
321     * @syscap SystemCapability.Window.SessionManager
322     * @atomicservice
323     * @since 15
324     */
325    size: PiPWindowSize;
326  }
327
328  /**
329   * Describe the type of picture-in-picture.
330   *
331   * @enum { number }.
332   * @syscap SystemCapability.Window.SessionManager
333   * @since 11
334   */
335  /**
336   * Describe the type of picture-in-picture.
337   *
338   * @enum { number }.
339   * @syscap SystemCapability.Window.SessionManager
340   * @atomicservice
341   * @since 12
342   */
343  enum PiPTemplateType {
344    /**
345     * Indicates the content to show in picture-in-picture window is video play
346     * @syscap SystemCapability.Window.SessionManager
347     * @since 11
348     */
349    /**
350     * Indicates the content to show in picture-in-picture window is video play
351     * @syscap SystemCapability.Window.SessionManager
352     * @atomicservice
353     * @since 12
354     */
355    VIDEO_PLAY,
356
357    /**
358     * Indicates the content to show in picture-in-picture window is video call
359     * @syscap SystemCapability.Window.SessionManager
360     * @since 11
361     */
362    /**
363     * Indicates the content to show in picture-in-picture window is video call
364     * @syscap SystemCapability.Window.SessionManager
365     * @atomicservice
366     * @since 12
367     */
368    VIDEO_CALL,
369
370    /**
371     * Indicates the content to show in picture-in-picture window is video meeting
372     * @syscap SystemCapability.Window.SessionManager
373     * @since 11
374     */
375    /**
376     * Indicates the content to show in picture-in-picture window is video meeting
377     * @syscap SystemCapability.Window.SessionManager
378     * @atomicservice
379     * @since 12
380     */
381    VIDEO_MEETING,
382
383    /**
384     * Indicates the content to show in picture-in-picture window is video live
385     * @syscap SystemCapability.Window.SessionManager
386     * @since 11
387     */
388    /**
389     * Indicates the content to show in picture-in-picture window is video live
390     * @syscap SystemCapability.Window.SessionManager
391     * @atomicservice
392     * @since 12
393     */
394    VIDEO_LIVE,
395  }
396
397  /**
398   * Enum for PiP window callback event type.
399   *
400   * @enum { number }.
401   * @syscap SystemCapability.Window.SessionManager
402   * @since 11
403   */
404  /**
405   * Enum for PiP window callback event type.
406   *
407   * @enum { number }.
408   * @syscap SystemCapability.Window.SessionManager
409   * @atomicservice
410   * @since 12
411   */
412  enum PiPState {
413    /**
414     * PiP window is about to start.
415     *
416     * @syscap SystemCapability.Window.SessionManager
417     * @since 11
418     */
419    /**
420     * PiP window is about to start.
421     *
422     * @syscap SystemCapability.Window.SessionManager
423     * @atomicservice
424     * @since 12
425     */
426    ABOUT_TO_START = 1,
427
428    /**
429     * PiP window started.
430     *
431     * @syscap SystemCapability.Window.SessionManager
432     * @since 11
433     */
434    /**
435     * PiP window started.
436     *
437     * @syscap SystemCapability.Window.SessionManager
438     * @atomicservice
439     * @since 12
440     */
441    STARTED = 2,
442
443    /**
444     * PiP window is about to stop.
445     *
446     * @syscap SystemCapability.Window.SessionManager
447     * @since 11
448     */
449    /**
450     * PiP window is about to stop.
451     *
452     * @syscap SystemCapability.Window.SessionManager
453     * @atomicservice
454     * @since 12
455     */
456    ABOUT_TO_STOP = 3,
457
458    /**
459     * PiP window stopped.
460     *
461     * @syscap SystemCapability.Window.SessionManager
462     * @since 11
463     */
464    /**
465     * PiP window stopped.
466     *
467     * @syscap SystemCapability.Window.SessionManager
468     * @atomicservice
469     * @since 12
470     */
471    STOPPED = 4,
472
473    /**
474     * Restore the original page from PiP window
475     *
476     * @syscap SystemCapability.Window.SessionManager
477     * @since 11
478     */
479    /**
480     * Restore the original page from PiP window
481     *
482     * @syscap SystemCapability.Window.SessionManager
483     * @atomicservice
484     * @since 12
485     */
486    ABOUT_TO_RESTORE = 5,
487
488    /**
489     * Error message during start/stop.
490     *
491     * @syscap SystemCapability.Window.SessionManager
492     * @since 11
493     */
494    /**
495     * Error message during start/stop.
496     *
497     * @syscap SystemCapability.Window.SessionManager
498     * @atomicservice
499     * @since 12
500     */
501    ERROR = 6,
502  }
503
504  /**
505   * Describe PiP window custom controls.
506   *
507   * @typedef { VideoPlayControlGroup | VideoCallControlGroup | VideoMeetingControlGroup | VideoLiveControlGroup }
508   * @syscap SystemCapability.Window.SessionManager
509   * @atomicservice
510   * @since 12
511   */
512  type PiPControlGroup = VideoPlayControlGroup | VideoCallControlGroup | VideoMeetingControlGroup | VideoLiveControlGroup;
513
514  /**
515   * Enum for video play PiP window custom controls.
516   *
517   * @enum { number }.
518   * @syscap SystemCapability.Window.SessionManager
519   * @atomicservice
520   * @since 12
521   */
522  enum VideoPlayControlGroup {
523    /**
524     * Previous/Next for video.
525     *
526     * @syscap SystemCapability.Window.SessionManager
527     * @atomicservice
528     * @since 12
529     */
530    VIDEO_PREVIOUS_NEXT = 101,
531
532    /**
533     * Forward/Backward for video.
534     *
535     * @syscap SystemCapability.Window.SessionManager
536     * @atomicservice
537     * @since 12
538     */
539    FAST_FORWARD_BACKWARD = 102,
540  }
541
542  /**
543   * Enum for video call PiP window custom controls.
544   *
545   * @enum { number }.
546   * @syscap SystemCapability.Window.SessionManager
547   * @atomicservice
548   * @since 12
549   */
550  enum VideoCallControlGroup {
551    /**
552     * Turn on/off the microphone.
553     *
554     * @syscap SystemCapability.Window.SessionManager
555     * @atomicservice
556     * @since 12
557     */
558    MICROPHONE_SWITCH = 201,
559
560    /**
561     * Hang up.
562     *
563     * @syscap SystemCapability.Window.SessionManager
564     * @atomicservice
565     * @since 12
566     */
567    HANG_UP_BUTTON = 202,
568
569    /**
570     * Turn on/off the camera
571     *
572     * @syscap SystemCapability.Window.SessionManager
573     * @atomicservice
574     * @since 12
575     */
576    CAMERA_SWITCH = 203,
577
578    /**
579     * Mute switch.
580     *
581     * @syscap SystemCapability.Window.SessionManager
582     * @atomicservice
583     * @since 12
584     */
585    MUTE_SWITCH = 204,
586  }
587
588  /**
589   * Enum for video meeting PiP window custom controls.
590   *
591   * @enum { number }.
592   * @syscap SystemCapability.Window.SessionManager
593   * @atomicservice
594   * @since 12
595   */
596  enum VideoMeetingControlGroup {
597    /**
598     * Hang up.
599     *
600     * @syscap SystemCapability.Window.SessionManager
601     * @atomicservice
602     * @since 12
603     */
604    HANG_UP_BUTTON = 301,
605
606    /**
607     * Turn on/off the camera
608     *
609     * @syscap SystemCapability.Window.SessionManager
610     * @atomicservice
611     * @since 12
612     */
613    CAMERA_SWITCH = 302,
614
615    /**
616     * Mute switch.
617     *
618     * @syscap SystemCapability.Window.SessionManager
619     * @atomicservice
620     * @since 12
621     */
622    MUTE_SWITCH = 303,
623
624    /**
625     * Turn on/off the microphone.
626     *
627     * @syscap SystemCapability.Window.SessionManager
628     * @atomicservice
629     * @since 12
630     */
631    MICROPHONE_SWITCH = 304,
632  }
633
634  /**
635   * Enum for video Live PiP window custom controls.
636   *
637   * @enum { number }.
638   * @syscap SystemCapability.Window.SessionManager
639   * @atomicservice
640   * @since 12
641   */
642  enum VideoLiveControlGroup {
643    /**
644     * Video play/pause control.
645     *
646     * @syscap SystemCapability.Window.SessionManager
647     * @atomicservice
648     * @since 12
649     */
650    VIDEO_PLAY_PAUSE = 401,
651
652    /**
653     * Mute switch.
654     *
655     * @syscap SystemCapability.Window.SessionManager
656     * @atomicservice
657     * @since 12
658     */
659    MUTE_SWITCH = 402,
660  }
661
662  /**
663   * Enum for control status.
664   *
665   * @enum { number }.
666   * @syscap SystemCapability.Window.SessionManager
667   * @atomicservice
668   * @since 12
669   */
670  enum PiPControlStatus {
671    /**
672     * The video is in play mode.
673     *
674     * @syscap SystemCapability.Window.SessionManager
675     * @atomicservice
676     * @since 12
677     */
678    PLAY = 1,
679
680    /**
681     * The video is in pause mode.
682     *
683     * @syscap SystemCapability.Window.SessionManager
684     * @atomicservice
685     * @since 12
686     */
687    PAUSE = 0,
688
689    /**
690     * A control with both open and closed states is in an open state.
691     *
692     * @syscap SystemCapability.Window.SessionManager
693     * @atomicservice
694     * @since 12
695     */
696    OPEN = 1,
697
698    /**
699     * A control with both open and closed states is in a close state.
700     *
701     * @syscap SystemCapability.Window.SessionManager
702     * @atomicservice
703     * @since 12
704     */
705    CLOSE = 0,
706  }
707
708  /**
709   * Enum for control type.
710   *
711   * @enum { number }.
712   * @syscap SystemCapability.Window.SessionManager
713   * @atomicservice
714   * @since 12
715   */
716  enum PiPControlType {
717    /**
718     * Video play/pause control.
719     *
720     * @syscap SystemCapability.Window.SessionManager
721     * @atomicservice
722     * @since 12
723     */
724    VIDEO_PLAY_PAUSE = 0,
725
726    /**
727     * Previous video control.
728     *
729     * @syscap SystemCapability.Window.SessionManager
730     * @atomicservice
731     * @since 12
732     */
733    VIDEO_PREVIOUS = 1,
734
735    /**
736     * Next video control.
737     *
738     * @syscap SystemCapability.Window.SessionManager
739     * @atomicservice
740     * @since 12
741     */
742    VIDEO_NEXT = 2,
743
744    /**
745     * Fast-forward control.
746     *
747     * @syscap SystemCapability.Window.SessionManager
748     * @atomicservice
749     * @since 12
750     */
751    FAST_FORWARD = 3,
752
753    /**
754     * Fast-backward control.
755     *
756     * @syscap SystemCapability.Window.SessionManager
757     * @atomicservice
758     * @since 12
759     */
760    FAST_BACKWARD = 4,
761
762    /**
763     * Hang-up control.
764     *
765     * @syscap SystemCapability.Window.SessionManager
766     * @atomicservice
767     * @since 12
768     */
769    HANG_UP_BUTTON = 5,
770
771    /**
772     * Microphone state switching control.
773     *
774     * @syscap SystemCapability.Window.SessionManager
775     * @atomicservice
776     * @since 12
777     */
778    MICROPHONE_SWITCH = 6,
779
780    /**
781     * Camera state switching control.
782     *
783     * @syscap SystemCapability.Window.SessionManager
784     * @atomicservice
785     * @since 12
786     */
787    CAMERA_SWITCH = 7,
788
789    /**
790     * Mute state switching control.
791     *
792     * @syscap SystemCapability.Window.SessionManager
793     * @atomicservice
794     * @since 12
795     */
796    MUTE_SWITCH = 8,
797  }
798
799
800  /**
801   * Describe picture-in-picture action event type.
802   *
803   * @typedef { PiPVideoActionEvent | PiPCallActionEvent | PiPMeetingActionEvent | PiPLiveActionEvent }
804   * @syscap SystemCapability.Window.SessionManager
805   * @since 11
806   */
807  /**
808   * Describe picture-in-picture action event type.
809   *
810   * @typedef { PiPVideoActionEvent | PiPCallActionEvent | PiPMeetingActionEvent | PiPLiveActionEvent }
811   * @syscap SystemCapability.Window.SessionManager
812   * @atomicservice
813   * @since 12
814   */
815  type PiPActionEventType = PiPVideoActionEvent | PiPCallActionEvent | PiPMeetingActionEvent | PiPLiveActionEvent;
816
817  /**
818   * Describe picture-in-picture video template action event type.
819   *
820   * @typedef { 'playbackStateChanged' | 'nextVideo' | 'previousVideo' }
821   * @syscap SystemCapability.Window.SessionManager
822   * @since 11
823   */
824  /**
825   * Describe picture-in-picture video template action event type.
826   *
827   * @typedef { 'playbackStateChanged' | 'nextVideo' | 'previousVideo' | 'fastForward' | 'fastBackward' }
828   * @syscap SystemCapability.Window.SessionManager
829   * @atomicservice
830   * @since 12
831   */
832  type PiPVideoActionEvent = 'playbackStateChanged' | 'nextVideo' | 'previousVideo' | 'fastForward' | 'fastBackward';
833
834  /**
835   * Describe picture-in-picture call template action event type.
836   *
837   * @typedef { 'hangUp' | 'micStateChanged' | 'videoStateChanged' }
838   * @syscap SystemCapability.Window.SessionManager
839   * @since 11
840   */
841  /**
842   * Describe picture-in-picture call template action event type.
843   *
844   * @typedef { 'hangUp' | 'micStateChanged' | 'videoStateChanged' | 'voiceStateChanged' }
845   * @syscap SystemCapability.Window.SessionManager
846   * @atomicservice
847   * @since 12
848   */
849  type PiPCallActionEvent = 'hangUp' | 'micStateChanged' | 'videoStateChanged' | 'voiceStateChanged';
850
851  /**
852   * Describe picture-in-picture meeting template action event type.
853   *
854   * @typedef { 'hangUp' | 'voiceStateChanged' | 'videoStateChanged' }
855   * @syscap SystemCapability.Window.SessionManager
856   * @since 11
857   */
858  /**
859   * Describe picture-in-picture meeting template action event type.
860   *
861   * @typedef { 'hangUp' | 'voiceStateChanged' | 'videoStateChanged' | 'micStateChanged' }
862   * @syscap SystemCapability.Window.SessionManager
863   * @atomicservice
864   * @since 12
865   */
866  type PiPMeetingActionEvent = 'hangUp' | 'voiceStateChanged' | 'videoStateChanged' | 'micStateChanged';
867
868  /**
869   * Describe picture-in-picture live template action event type.
870   *
871   * @typedef { 'playbackStateChanged' }
872   * @syscap SystemCapability.Window.SessionManager
873   * @since 11
874   */
875  /**
876   * Describe picture-in-picture live template action event type.
877   *
878   * @typedef { 'playbackStateChanged' | 'voiceStateChanged' }
879   * @syscap SystemCapability.Window.SessionManager
880   * @atomicservice
881   * @since 12
882   */
883  type PiPLiveActionEvent = 'playbackStateChanged' | 'voiceStateChanged';
884
885  /**
886   * Describe picture-in-picture control panel action event callback.
887   *
888   * @typedef { function } ControlPanelActionEventCallback
889   * @param { PiPActionEventType } event - the event from controlPanel
890   * @param { number } [status] - the status of control button
891   * @syscap SystemCapability.Window.SessionManager
892   * @atomicservice
893   * @since 12
894   */
895  type ControlPanelActionEventCallback = (event: PiPActionEventType, status?: number) => void;
896
897  /**
898   * Describe picture-in-picture control event callback.
899   *
900   * @interface ControlEventParam
901   * @syscap SystemCapability.Window.SessionManager
902   * @atomicservice
903   * @since 12
904   */
905  interface ControlEventParam {
906    /**
907     * The type of control.
908     *
909     * @type { PiPControlType }
910     * @syscap SystemCapability.Window.SessionManager
911     * @atomicservice
912     * @since 12
913     */
914    controlType: PiPControlType;
915
916    /**
917     * The status of control.
918     *
919     * @type { ?PiPControlStatus }
920     * @syscap SystemCapability.Window.SessionManager
921     * @atomicservice
922     * @since 12
923     */
924    status?: PiPControlStatus;
925  }
926
927  /**
928   * PiPController
929   *
930   * @interface PiPController
931   * @syscap SystemCapability.Window.SessionManager
932   * @since 11
933   */
934  /**
935   * PiPController
936   *
937   * @interface PiPController
938   * @syscap SystemCapability.Window.SessionManager
939   * @atomicservice
940   * @since 12
941   */
942  interface PiPController {
943
944    /**
945     * Start picture-in-picture
946     * @returns { Promise<void> } - The promise returned by the function
947     * @throws { BusinessError } 1300012 - The PiP window state is abnormal.
948     * @throws { BusinessError } 1300013 - Failed to create the PiP window.
949     * @throws { BusinessError } 1300014 - PiP internal error.
950     * @throws { BusinessError } 1300015 - Repeated PiP operation.
951     * @syscap SystemCapability.Window.SessionManager
952     * @since 11
953     */
954    /**
955     * Start picture-in-picture
956     * @returns { Promise<void> } - The promise returned by the function
957     * @throws { BusinessError } 1300012 - The PiP window state is abnormal.
958     * @throws { BusinessError } 1300013 - Failed to create the PiP window.
959     * @throws { BusinessError } 1300014 - PiP internal error.
960     * @throws { BusinessError } 1300015 - Repeated PiP operation.
961     * @syscap SystemCapability.Window.SessionManager
962     * @atomicservice
963     * @since 12
964     */
965    startPiP(): Promise<void>;
966
967    /**
968     * Stop picture-in-picture.
969     * @returns { Promise<void> } - The promise returned by the function.
970     * @throws { BusinessError } 1300011 - Failed to destroy the PiP window.
971     * @throws { BusinessError } 1300012 - The PiP window state is abnormal.
972     * @throws { BusinessError } 1300015 - Repeated PiP operation.
973     * @syscap SystemCapability.Window.SessionManager
974     * @since 11
975     */
976    /**
977     * Stop picture-in-picture.
978     * @returns { Promise<void> } - The promise returned by the function.
979     * @throws { BusinessError } 1300011 - Failed to destroy the PiP window.
980     * @throws { BusinessError } 1300012 - The PiP window state is abnormal.
981     * @throws { BusinessError } 1300015 - Repeated PiP operation.
982     * @syscap SystemCapability.Window.SessionManager
983     * @atomicservice
984     * @since 12
985     */
986    stopPiP(): Promise<void>;
987
988    /**
989     * Set if auto start picture-in-picture when back home
990     * @param { boolean } enable - Enable auto start picture-in-picture when back home
991     * @syscap SystemCapability.Window.SessionManager
992     * @since 11
993     */
994    /**
995     * Set if auto start picture-in-picture when back home
996     * @param { boolean } enable - Enable auto start picture-in-picture when back home
997     * @syscap SystemCapability.Window.SessionManager
998     * @atomicservice
999     * @since 12
1000     */
1001    setAutoStartEnabled(enable: boolean): void;
1002
1003    /**
1004     * Update source content size to adjust PiP window aspect ratio.
1005     * @param { number } width - Indicate the width of the content. The width can consist of only digits and above 0.
1006     * @param { number } height - Indicate the height of the content. The height can consist of only digits and above 0.
1007     * @throws { BusinessError } 401 - Params error. Possible causes: 1. Mandatory parameters are left unspecified.
1008     *                                                                2. Incorrect parameter types.
1009     * @syscap SystemCapability.Window.SessionManager
1010     * @since 11
1011     */
1012    /**
1013     * Update source content size to adjust PiP window aspect ratio.
1014     * @param { number } width - Indicate the width of the content. The width can consist of only digits and above 0.
1015     * @param { number } height - Indicate the height of the content. The height can consist of only digits and above 0.
1016     * @throws { BusinessError } 401 - Params error. Possible causes: 1. Mandatory parameters are left unspecified.
1017     *                                                                2. Incorrect parameter types.
1018     * @syscap SystemCapability.Window.SessionManager
1019     * @atomicservice
1020     * @since 12
1021     */
1022    updateContentSize(width: number, height: number): void;
1023
1024    /**
1025     * Set dashboard control status.
1026     * @param { PiPControlType } controlType - Describe picture-in-picture control type.
1027     * @param { PiPControlStatus } status - Describe picture-in-picture control Status.
1028     * @throws { BusinessError } 401 - Params error. Possible causes: 1. Mandatory parameters are left unspecified.
1029     *                                                                2. Incorrect parameter types.
1030     *                                                                3. Parameter verification failed
1031     * @syscap SystemCapability.Window.SessionManager
1032     * @atomicservice
1033     * @since 12
1034     */
1035    updatePiPControlStatus(controlType: PiPControlType, status: PiPControlStatus): void;
1036
1037    /**
1038     * Update the node which display the content of PiP window.
1039     * @param { typeNode.XComponent } contentNode - The node which display the content of pip window.
1040     * @returns { Promise<void> } - The promise returned by the function.
1041     * @throws { BusinessError } 401 - Params error. Possible causes: 1. Mandatory parameters are left unspecified.
1042     *                                                                2. Incorrect parameter types.
1043     *                                                                3. Parameter verification failed.
1044     * @throws { BusinessError } 801 - Capability not supported. Failed to call the API due to limited device capabilities.
1045     * @throws { BusinessError } 1300014 - PiP internal error.
1046     * @syscap SystemCapability.Window.SessionManager
1047     * @atomicservice
1048     * @since 18
1049     */
1050    updateContentNode(contentNode: typeNode.XComponent): Promise<void>;
1051
1052    /**
1053     * Set Dashboard control enable status.
1054     * @param { PiPControlType } controlType - Describe picture-in-picture control type.
1055     * @param { boolean } enabled - Describe picture-in-picture control enable Status.
1056     * @throws { BusinessError } 401 - Params error. Possible causes: 1. Mandatory parameters are left unspecified.
1057     *                                                                2. Incorrect parameter types.
1058     *                                                                3. Parameter verification failed
1059     * @syscap SystemCapability.Window.SessionManager
1060     * @atomicservice
1061     * @since 12
1062     */
1063    setPiPControlEnabled(controlType: PiPControlType, enabled: boolean): void;
1064
1065    /**
1066     * Get the info of PiP window.
1067     * @returns { Promise<PiPWindowInfo> } - The promise used to return the PIP window info.
1068     * @throws { BusinessError } 801 - Capability not supported. Failed to call the API due to limited device capabilities.
1069     * @throws { BusinessError } 1300014 - PiP internal error.
1070     * @syscap SystemCapability.Window.SessionManager
1071     * @atomicservice
1072     * @since 15
1073     */
1074     getPiPWindowInfo(): Promise<PiPWindowInfo>;
1075
1076    /**
1077     * Register picture-in-picture control event listener.
1078     * @param { 'stateChange' } type - Registration type, PiP lifecycle state change, 'stateChange'
1079     * @param { function } callback - Used to handle {'stateChange'} command
1080     * @syscap SystemCapability.Window.SessionManager
1081     * @since 11
1082     */
1083    /**
1084     * Register picture-in-picture control event listener.
1085     * @param { 'stateChange' } type - Registration type, PiP lifecycle state change, 'stateChange'
1086     * @param { function } callback - Used to handle {'stateChange'} command
1087     * @syscap SystemCapability.Window.SessionManager
1088     * @atomicservice
1089     * @since 12
1090     */
1091    on(type: 'stateChange', callback: (state: PiPState, reason: string) => void): void;
1092
1093    /**
1094     * Unregister picture-in-picture lifecycle event listener.
1095     * @param { 'stateChange' } type - Used to unregister listener for {'stateChange'} command
1096     * @syscap SystemCapability.Window.SessionManager
1097     * @since 11
1098     */
1099    /**
1100     * Unregister picture-in-picture lifecycle event listener.
1101     * @param { 'stateChange' } type - Used to unregister listener for {'stateChange'} command
1102     * @syscap SystemCapability.Window.SessionManager
1103     * @atomicservice
1104     * @since 12
1105     */
1106    off(type: 'stateChange'): void;
1107
1108    /**
1109     * Register picture-in-picture control event listener.
1110     * @param { 'controlPanelActionEvent' } type - Registration type, user action event, 'controlPanelActionEvent'
1111     * @param { function } callback - Used to handle {'controlPanelActionEvent'} command
1112     * @syscap SystemCapability.Window.SessionManager
1113     * @since 11
1114     */
1115    /**
1116     * Register picture-in-picture control event listener.
1117     *
1118     * @param { 'controlPanelActionEvent' } type - Registration type, user action event, 'controlPanelActionEvent'
1119     * @param { ControlPanelActionEventCallback } callback - Used to handle {'controlPanelActionEvent'} command.
1120     * @syscap SystemCapability.Window.SessionManager
1121     * @atomicservice
1122     * @since 12
1123     */
1124    on(type: 'controlPanelActionEvent', callback: ControlPanelActionEventCallback): void;
1125
1126    /**
1127     * Unregister picture-in-picture lifecycle event listener
1128     * @param { 'controlPanelActionEvent' } type - Used to unregister listener for {'controlPanelActionEvent'} command
1129     * @syscap SystemCapability.Window.SessionManager
1130     * @since 11
1131     */
1132    /**
1133     * Unregister picture-in-picture lifecycle event listener
1134     * @param { 'controlPanelActionEvent' } type - Used to unregister listener for {'controlPanelActionEvent'} command
1135     * @syscap SystemCapability.Window.SessionManager
1136     * @atomicservice
1137     * @since 12
1138     */
1139    off(type: 'controlPanelActionEvent'): void;
1140
1141    /**
1142     * Register picture-in-picture control event listener.
1143     *
1144     * @param { 'controlEvent' } type - Registration type, user action event, 'controlEvent'
1145     * @param { Callback<ControlEventParam> } callback - Used to handle {'controlEvent'} command.
1146     * @syscap SystemCapability.Window.SessionManager
1147     * @atomicservice
1148     * @since 12
1149     */
1150    on(type: 'controlEvent', callback: Callback<ControlEventParam>): void;
1151
1152    /**
1153     * Unregister picture-in-picture control event listener
1154     * @param { 'controlEvent' } type - Used to unregister listener for {'controlEvent'} command
1155     * @param { Callback<ControlEventParam> } callback - Used to handle {'controlEvent'} command.
1156     * @syscap SystemCapability.Window.SessionManager
1157     * @atomicservice
1158     * @since 12
1159     */
1160    off(type: 'controlEvent', callback?: Callback<ControlEventParam>): void;
1161
1162    /**
1163     * Register picture-in-picture window size change event listener
1164     *
1165     * @param { 'pipWindowSizeChange' } type - The value is fixed at 'pipWindowSizeChange', indicating the picture-in-picture
1166     * window size change event.
1167     * @param { Callback<PiPWindowSize> } callback - Callback used to return the picture-in-picture window size.
1168     * @throws { BusinessError } 401 - Params error. Possible causes: 1. Mandatory parameters are left unspecified.
1169     *                                                                2. Incorrect parameter types.
1170     *                                                                3. Parameter verification failed.
1171     * @throws { BusinessError } 801 - Capability not supported. Failed to call the API due to limited device capabilities.
1172     * @throws { BusinessError } 1300014 - PiP internal error.
1173     * @syscap SystemCapability.Window.SessionManager
1174     * @atomicservice
1175     * @since 15
1176     */
1177    on(type: 'pipWindowSizeChange', callback: Callback<PiPWindowSize>): void;
1178
1179    /**
1180     * Unregister picture-in-picture window size change event listener
1181     *
1182     * @param { 'pipWindowSizeChange' } type - The value is fixed at 'pipWindowSizeChange', indicating the picture-in-picture
1183     * window size change event.
1184     * @param { Callback<PiPWindowSize> } callback - Callback used to return the picture-in-picture window size.
1185     * @throws { BusinessError } 401 - Params error. Possible causes: 1. Mandatory parameters are left unspecified.
1186     *                                                                2. Incorrect parameter types.
1187     *                                                                3. Parameter verification failed.
1188     * @throws { BusinessError } 801 - Capability not supported. Failed to call the API due to limited device capabilities.
1189     * @throws { BusinessError } 1300014 - PiP internal error.
1190     * @syscap SystemCapability.Window.SessionManager
1191     * @atomicservice
1192     * @since 15
1193     */
1194    off(type: 'pipWindowSizeChange', callback?: Callback<PiPWindowSize>): void;
1195
1196    /**
1197     * Returns a Boolean value that indicates whether picture-in-picture is supported
1198     *
1199     * @returns { boolean } - True if picture-in-picture is supported, otherwise false
1200     * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app.
1201     * @throws { BusinessError } 1300014 - PiP internal error.
1202     * @syscap SystemCapability.Window.SessionManager
1203     * @systemapi Hide this for inner system use
1204     * @since 18
1205     * @test
1206     */
1207    isPiPSupported(): boolean;
1208  }
1209}
1210
1211export default PiPWindow;
1212