1# oh_window_pip.h 2 3## Overview 4 5The file declares the APIs related to the Picture in Picture (PiP) feature, including creating and deleting a PiP controller, and starting and stopping PiP. PiP is mainly used in video playback, live streaming, video calls, or video meetings. 6 7**File to include**: <window_manager/oh_window_pip.h> 8 9**Library**: libnative_window_manager.so 10 11**System capability**: SystemCapability.Window.SessionManager 12 13**Since**: 20 14 15**Related module**: [WindowManager](capi-windowmanager.md) 16 17## Summary 18 19### Enums 20 21| Name| typedef Keyword| Description| 22| -- | -- | -- | 23| [PictureInPicture_PipTemplateType](#pictureinpicture_piptemplatetype) | PictureInPicture_PipTemplateType | Enumerates the types of PiP templates.| 24| [PictureInPicture_PipControlGroup](#pictureinpicture_pipcontrolgroup) | PictureInPicture_PipControlGroup | Enumerates the types of component groups displayed on the PiP controller.| 25| [PictureInPicture_PipControlType](#pictureinpicture_pipcontroltype) | PictureInPicture_PipControlType | Enumerates the types of components displayed on the PiP controller.| 26| [PictureInPicture_PipControlStatus](#pictureinpicture_pipcontrolstatus) | PictureInPicture_PipControlStatus | Enumerates the statuses of components displayed on the PiP controller.| 27| [PictureInPicture_PipState](#pictureinpicture_pipstate) | PictureInPicture_PipState | Enumerates the PiP lifecycle states.| 28 29### Functions 30 31| Name| typedef Keyword| Description| 32| -- | -- | -- | 33| [typedef void (\*WebPipStartPipCallback)(uint32_t controllerId, uint8_t requestId, uint64_t surfaceId)](#webpipstartpipcallback) | WebPipStartPipCallback | Defines a callback function for PiP window creation.| 34| [typedef void (\*WebPipLifecycleCallback)(uint32_t controllerId, PictureInPicture_PipState state, int32_t errcode)](#webpiplifecyclecallback) | WebPipLifecycleCallback | Defines a callback function for PiP window lifecycle changes.| 35| [typedef void (\*WebPipControlEventCallback)(uint32_t controllerId, PictureInPicture_PipControlType controlType,PictureInPicture_PipControlStatus status)](#webpipcontroleventcallback) | WebPipControlEventCallback | Defines a callback function for the component click event of the PiP window.| 36| [typedef void (\*WebPipResizeCallback)(uint32_t controllerId, uint32_t width, uint32_t height, double scale)](#webpipresizecallback) | WebPipResizeCallback | Defines a callback function for PiP window size changes.| 37| [int32_t OH_PictureInPicture_CreatePipConfig(PictureInPicture_PipConfig* pipConfig)](#oh_pictureinpicture_createpipconfig) | - | Creates a PiP configuration.| 38| [int32_t OH_PictureInPicture_DestroyPipConfig(PictureInPicture_PipConfig* pipConfig)](#oh_pictureinpicture_destroypipconfig) | - | Destroys a PiP configuration.| 39| [int32_t OH_PictureInPicture_SetPipMainWindowId(PictureInPicture_PipConfig pipConfig, uint32_t mainWindowId)](#oh_pictureinpicture_setpipmainwindowid) | - | Sets the ID of the main window that launches PiP.| 40| [int32_t OH_PictureInPicture_SetPipTemplateType(PictureInPicture_PipConfig pipConfig,PictureInPicture_PipTemplateType pipTemplateType)](#oh_pictureinpicture_setpiptemplatetype) | - | Sets the PiP template type. The default value is video playback.| 41| [int32_t OH_PictureInPicture_SetPipRect(PictureInPicture_PipConfig pipConfig, uint32_t width, uint32_t height)](#oh_pictureinpicture_setpiprect) | - | Sets the size of the PiP window for calculating the aspect ratio.| 42| [int32_t OH_PictureInPicture_SetPipControlGroup(PictureInPicture_PipConfig pipConfig,PictureInPicture_PipControlGroup* controlGroup, uint8_t controlGroupLength)](#oh_pictureinpicture_setpipcontrolgroup) | - | Sets a PiP component group, which must match the template type.| 43| [int32_t OH_PictureInPicture_SetPipNapiEnv(PictureInPicture_PipConfig pipConfig, void* env)](#oh_pictureinpicture_setpipnapienv) | - | Sets the runtime environment for launching PiP.| 44| [int32_t OH_PictureInPicture_CreatePip(PictureInPicture_PipConfig pipConfig, uint32_t* controllerId)](#oh_pictureinpicture_createpip) | - | Creates a PiP controller.| 45| [int32_t OH_PictureInPicture_DeletePip(uint32_t controllerId)](#oh_pictureinpicture_deletepip) | - | Deletes a PiP controller.| 46| [int32_t OH_PictureInPicture_StartPip(uint32_t controllerId)](#oh_pictureinpicture_startpip) | - | Starts PiP.| 47| [int32_t OH_PictureInPicture_StopPip(uint32_t controllerId)](#oh_pictureinpicture_stoppip) | - | Stops PiP.| 48| [int32_t OH_PictureInPicture_UpdatePipContentSize(uint32_t controllerId, uint32_t width, uint32_t height)](#oh_pictureinpicture_updatepipcontentsize) | - | Updates the media content size when the media content changes.| 49| [int32_t OH_PictureInPicture_UpdatePipControlStatus(uint32_t controllerId, PictureInPicture_PipControlType controlType,PictureInPicture_PipControlStatus status)](#oh_pictureinpicture_updatepipcontrolstatus) | - | Updates the PiP component status.| 50| [int32_t OH_PictureInPicture_SetPipControlEnabled(uint32_t controllerId, PictureInPicture_PipControlType controlType,bool enabled)](#oh_pictureinpicture_setpipcontrolenabled) | - | Sets the PiP component enabled status.| 51| [int32_t OH_PictureInPicture_RegisterStartPipCallback(uint32_t controllerId, WebPipStartPipCallback callback)](#oh_pictureinpicture_registerstartpipcallback) | - | Registers a callback to listen for the completion of PiP surface creation.| 52| [int32_t OH_PictureInPicture_UnregisterStartPipCallback(uint32_t controllerId, WebPipStartPipCallback callback)](#oh_pictureinpicture_unregisterstartpipcallback) | - | Unregisters the callback used to listen for the completion of PiP surface creation.| 53| [int32_t OH_PictureInPicture_UnregisterAllStartPipCallbacks(uint32_t controllerId)](#oh_pictureinpicture_unregisterallstartpipcallbacks) | - | Unregisters all the callbacks used to listen for the completion of PiP surface creation.| 54| [int32_t OH_PictureInPicture_RegisterLifecycleListener(uint32_t controllerId, WebPipLifecycleCallback callback)](#oh_pictureinpicture_registerlifecyclelistener) | - | Registers a callback to listen for PiP lifecycle state changes.| 55| [int32_t OH_PictureInPicture_UnregisterLifecycleListener(uint32_t controllerId, WebPipLifecycleCallback callback)](#oh_pictureinpicture_unregisterlifecyclelistener) | - | Unregisters the callback used to listen for PiP lifecycle state changes.| 56| [int32_t OH_PictureInPicture_UnregisterAllLifecycleListeners(uint32_t controllerId)](#oh_pictureinpicture_unregisteralllifecyclelisteners) | - | Unregisters all the callbacks used to listen for PiP lifecycle state changes.| 57| [int32_t OH_PictureInPicture_RegisterControlEventListener(uint32_t controllerId, WebPipControlEventCallback callback)](#oh_pictureinpicture_registercontroleventlistener) | - | Registers a callback to listen for control panel action events in PiP mode.| 58| [int32_t OH_PictureInPicture_UnregisterControlEventListener(uint32_t controllerId, WebPipControlEventCallback callback)](#oh_pictureinpicture_unregistercontroleventlistener) | - | Unregisters the callback used to listen for control panel action events in PiP mode.| 59| [int32_t OH_PictureInPicture_UnregisterAllControlEventListeners(uint32_t controllerId)](#oh_pictureinpicture_unregisterallcontroleventlisteners) | - | Unregisters all the callbacks used to listen for control panel action events in PiP mode.| 60| [int32_t OH_PictureInPicture_RegisterResizeListener(uint32_t controllerId, WebPipResizeCallback callback)](#oh_pictureinpicture_registerresizelistener) | - | Registers a callback to listen for PiP window size changes.| 61| [int32_t OH_PictureInPicture_UnregisterResizeListener(uint32_t controllerId, WebPipResizeCallback callback)](#oh_pictureinpicture_unregisterresizelistener) | - | Unregisters the callback used to listen for PiP window size changes.| 62| [int32_t OH_PictureInPicture_UnregisterAllResizeListeners(uint32_t controllerId)](#oh_pictureinpicture_unregisterallresizelisteners) | - | Unregisters all the callbacks used to listen for PiP window size changes.| 63| [int32_t OH_PictureInPicture_SetPipInitialSurfaceRect(uint32_t controllerId, int32_t positionX, int32_t positionY,uint32_t width, uint32_t height)](#oh_pictureinpicture_setpipinitialsurfacerect) | - | Sets the initial position and size of the PiP surface when the PiP launch animation starts. It can be used to achieve a seamless transition effect.| 64| [int32_t OH_PictureInPicture_UnsetPipInitialSurfaceRect(uint32_t controllerId)](#oh_pictureinpicture_unsetpipinitialsurfacerect) | - | Cancels the previously set initial position and size for the PiP surface.| 65 66## Enum Description 67 68### PictureInPicture_PipTemplateType 69 70``` 71enum PictureInPicture_PipTemplateType 72``` 73 74**Description** 75 76Enumerates the types of PiP templates. 77 78**Since**: 20 79 80| Enum Item| Description| 81| -- | -- | 82| VIDEO_PLAY = 0 | Video playback template. A PiP window will be started during video playback, and the video playback template is loaded.| 83| VIDEO_CALL = 1 | Video call template. A PiP window will be started during a video call, and the video call template will be loaded.| 84| VIDEO_MEETING = 2 | Video meeting template. A PiP window will be started during a video meeting, and the video meeting template will be loaded.| 85| VIDEO_LIVE = 3 | Live template. A PiP window will be started during a live, and the live template is loaded.| 86 87### PictureInPicture_PipControlGroup 88 89``` 90enum PictureInPicture_PipControlGroup 91``` 92 93**Description** 94 95Enumerates the types of component groups displayed on the PiP controller. 96 97**Since**: 20 98 99| Enum Item| Description| 100| -- | -- | 101| VIDEO_PLAY_VIDEO_PREVIOUS_NEXT = 101 | Previous/Next component group for video playback. This component group is mutually exclusive with the fast-forward/rewind component group. It cannot be added if the fast-forward/rewind component group is added.| 102| VIDEO_PLAY_FAST_FORWARD_BACKWARD = 102 | Fast-forward/Rewind component group for video playback. This component group is mutually exclusive with the previous/next component group. It cannot be added if the previous/next component group is added.| 103| VIDEO_CALL_MICROPHONE_SWITCH = 201 | Microphone on/off component group for video calls.| 104| VIDEO_CALL_HANG_UP_BUTTON = 202 | Hang-up component group for video calls.| 105| VIDEO_CALL_CAMERA_SWITCH = 203 | Camera on/off component group for video calls.| 106| VIDEO_CALL_MUTE_SWITCH = 204 | Mute component group for video calls.| 107| VIDEO_MEETING_HANG_UP_BUTTON = 301 | Hang-up component group for video meetings.| 108| VIDEO_MEETING_CAMERA_SWITCH = 302 | Camera on/off component group for video meetings.| 109| VIDEO_MEETING_MUTE_SWITCH = 303 | Mute component group for video meetings.| 110| VIDEO_MEETING_MICROPHONE_SWITCH = 304 | Microphone on/off component group for video meetings.| 111| VIDEO_LIVE_VIDEO_PLAY_PAUSE = 401 | Play/Pause component group for live streaming.| 112| VIDEO_LIVE_MUTE_SWITCH = 402 | Mute component group for live streaming.| 113 114### PictureInPicture_PipControlType 115 116``` 117enum PictureInPicture_PipControlType 118``` 119 120**Description** 121 122Enumerates the types of components displayed on the PiP controller. 123 124**Since**: 20 125 126| Enum Item| Description| 127| -- | -- | 128| VIDEO_PLAY_PAUSE = 0 | Play/Pause component.| 129| VIDEO_PREVIOUS = 1 | Previous component in video scenarios.| 130| VIDEO_NEXT = 2 | Next component in video scenarios.| 131| FAST_FORWARD = 3 | Fast-forward component in video scenarios.| 132| FAST_BACKWARD = 4 | Rewind component in video scenarios.| 133| HANG_UP_BUTTON = 5 | Hang-up component.| 134| MICROPHONE_SWITCH = 6 | Microphone on/off component.| 135| CAMERA_SWITCH = 7 | Camera on/off component.| 136| MUTE_SWITCH = 8 | Mute/Unmute component.| 137 138### PictureInPicture_PipControlStatus 139 140``` 141enum PictureInPicture_PipControlStatus 142``` 143 144**Description** 145 146Enumerates the statuses of components displayed on the PiP controller. 147 148**Since**: 20 149 150| Enum Item| Description| 151| -- | -- | 152| PLAY = 1 | A video is playing.| 153| PAUSE = 0 | A video is paused.| 154| OPEN = 1 | The camera, microphone, and mute components are enabled.| 155| CLOSE = 0 | The camera, microphone, and mute components are disabled.| 156 157### PictureInPicture_PipState 158 159``` 160enum PictureInPicture_PipState 161``` 162 163**Description** 164 165Enumerates the PiP lifecycle states. 166 167**Since**: 20 168 169| Enum Item| Description| 170| -- | -- | 171| ABOUT_TO_START = 1 | PiP is about to start.| 172| STARTED = 2 | PiP is started.| 173| ABOUT_TO_STOP = 3 | PiP is about to stop.| 174| STOPPED = 4 | PiP is stopped.| 175| ABOUT_TO_RESTORE = 5 | The original page is about to restore.| 176| ERROR = 6 | An error occurs during the execution of the PiP lifecycle.| 177 178 179## Function Description 180 181### WebPipStartPipCallback() 182 183``` 184typedef void (*WebPipStartPipCallback)(uint32_t controllerId, uint8_t requestId, uint64_t surfaceId) 185``` 186 187**Description** 188 189Defines a callback function for PiP window creation. 190 191**Since**: 20 192 193 194**Parameters** 195 196| Parameter| Description| 197| -- | -- | 198| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 199| uint8_t requestId | Request ID, which indicates the number of times the PiP window has been requested to be pulled up.| 200| uint64_t surfaceId | Surface ID of the **XComponent** in PiP. It is used for application rendering.| 201 202### WebPipLifecycleCallback() 203 204``` 205typedef void (*WebPipLifecycleCallback)(uint32_t controllerId, PictureInPicture_PipState state, int32_t errcode) 206``` 207 208**Description** 209 210Defines a callback function for PiP window lifecycle changes. 211 212**Since**: 20 213 214 215**Parameters** 216 217| Parameter| Description| 218| -- | -- | 219| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 220| PictureInPicture_PipState state | PiP lifecycle state.| 221| int32_t errcode | Common status codes of PiP APIs. For details, see [WindowManager_ErrorCode](capi-oh-window-comm-h.md#windowmanager_errorcode).| 222 223### WebPipControlEventCallback() 224 225``` 226typedef void (*WebPipControlEventCallback)(uint32_t controllerId, PictureInPicture_PipControlType controlType, PictureInPicture_PipControlStatus status) 227``` 228 229**Description** 230 231Defines a callback function for the component click event of the PiP window. 232 233**Since**: 20 234 235 236**Parameters** 237 238| Parameter| Description| 239| -- | -- | 240| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 241| PictureInPicture_PipControlType controlType | Type of component displayed on the PiP controller.| 242| [PictureInPicture_PipControlStatus](#pictureinpicture_pipcontrolstatus) status | Status of the component displayed on the PiP controller.| 243 244### WebPipResizeCallback() 245 246``` 247typedef void (*WebPipResizeCallback)(uint32_t controllerId, uint32_t width, uint32_t height, double scale) 248``` 249 250**Description** 251 252Defines a callback function for PiP window size changes. 253 254**Since**: 20 255 256 257**Parameters** 258 259| Parameter| Description| 260| -- | -- | 261| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 262| uint32_t width | PiP window width, in px. The value is a positive integer and cannot be greater than the screen width.| 263| uint32_t height | PiP window height, in px. The value is a positive integer and cannot be greater than the screen height.| 264| double scale | Scale factor of the PiP window, representing the display size relative to the width and height. The value is a floating-point number in the range (0.0, 1.0]. The value **1** means that the PiP window matches the specified width and height.| 265 266### OH_PictureInPicture_CreatePipConfig() 267 268``` 269int32_t OH_PictureInPicture_CreatePipConfig(PictureInPicture_PipConfig* pipConfig) 270``` 271 272**Description** 273 274Creates a PiP configuration. 275 276**Since**: 20 277 278 279**Parameters** 280 281| Parameter| Description| 282| -- | -- | 283| [PictureInPicture_PipConfig](capi-pictureinpicture-pipconfig.md)* pipConfig | Pointer to the PiP parameter configuration.| 284 285**Return value** 286 287| Type| Description| 288| -- | -- | 289| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.| 290 291### OH_PictureInPicture_DestroyPipConfig() 292 293``` 294int32_t OH_PictureInPicture_DestroyPipConfig(PictureInPicture_PipConfig* pipConfig) 295``` 296 297**Description** 298 299Destroys a PiP configuration. 300 301**Since**: 20 302 303 304**Parameters** 305 306| Parameter| Description| 307| -- | -- | 308| [PictureInPicture_PipConfig](capi-pictureinpicture-pipconfig.md)* pipConfig | Pointer to the PiP configuration.| 309 310**Return value** 311 312| Type| Description| 313| -- | -- | 314| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.| 315 316### OH_PictureInPicture_SetPipMainWindowId() 317 318``` 319int32_t OH_PictureInPicture_SetPipMainWindowId(PictureInPicture_PipConfig pipConfig, uint32_t mainWindowId) 320``` 321 322**Description** 323 324Sets the ID of the main window that launches PiP. 325 326**Since**: 20 327 328 329**Parameters** 330 331| Parameter| Description| 332| -- | -- | 333| [PictureInPicture_PipConfig](capi-pictureinpicture-pipconfig.md) pipConfig | PiP configuration.| 334| uint32_t mainWindowId | ID of the main window that launches PiP.| 335 336**Return value** 337 338| Type| Description| 339| -- | -- | 340| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED**: The device does not support PiP.| 341 342### OH_PictureInPicture_SetPipTemplateType() 343 344``` 345int32_t OH_PictureInPicture_SetPipTemplateType(PictureInPicture_PipConfig pipConfig, PictureInPicture_PipTemplateType pipTemplateType) 346``` 347 348**Description** 349 350Sets the PiP template type. The default value is video playback. 351 352**Since**: 20 353 354 355**Parameters** 356 357| Parameter| Description| 358| -- | -- | 359| [PictureInPicture_PipConfig](capi-pictureinpicture-pipconfig.md) pipConfig | PiP configuration.| 360| [PictureInPicture_PipTemplateType](#pictureinpicture_piptemplatetype) pipTemplateType | Type of the PiP template.| 361 362**Return value** 363 364| Type| Description| 365| -- | -- | 366| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED**: The device does not support PiP.| 367 368### OH_PictureInPicture_SetPipRect() 369 370``` 371int32_t OH_PictureInPicture_SetPipRect(PictureInPicture_PipConfig pipConfig, uint32_t width, uint32_t height) 372``` 373 374**Description** 375 376Sets the size of the PiP window for calculating the aspect ratio. 377 378**Since**: 20 379 380 381**Parameters** 382 383| Parameter| Description| 384| -- | -- | 385| [PictureInPicture_PipConfig](capi-pictureinpicture-pipconfig.md) pipConfig | PiP configuration.| 386| uint32_t width | Width of the original content, in px. The value must be a positive integer. It is used to determine the aspect ratio of the PiP window.| 387| uint32_t height | Height of the original content, in px. The value must be a positive integer. It is used to determine the aspect ratio of the PiP window.| 388 389**Return value** 390 391| Type| Description| 392| -- | -- | 393| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED**: The device does not support PiP.| 394 395### OH_PictureInPicture_SetPipControlGroup() 396 397``` 398int32_t OH_PictureInPicture_SetPipControlGroup(PictureInPicture_PipConfig pipConfig, PictureInPicture_PipControlGroup* controlGroup, uint8_t controlGroupLength) 399``` 400 401**Description** 402 403Sets a PiP component group, which must match the template type. 404 405**Since**: 20 406 407 408**Parameters** 409 410| Parameter| Description| 411| -- | -- | 412| [PictureInPicture_PipConfig](capi-pictureinpicture-pipconfig.md) pipConfig | PiP configuration.| 413| [PictureInPicture_PipControlGroup](#pictureinpicture_pipcontrolgroup)* controlGroup | Pointer to an optional component group of the PiP controller. An application can configure whether to display these optional components. If this parameter is not set for an application, the basic components (for example, play/pause of the video playback component group) are displayed. A maximum of three components can be configured.| 414| uint8_t controlGroupLength | Number of components in the PiP component group. The value ranges from 0 to 3.| 415 416**Return value** 417 418| Type| Description| 419| -- | -- | 420| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED**: The device does not support PiP.| 421 422### OH_PictureInPicture_SetPipNapiEnv() 423 424``` 425int32_t OH_PictureInPicture_SetPipNapiEnv(PictureInPicture_PipConfig pipConfig, void* env) 426``` 427 428**Description** 429 430Sets the runtime environment for launching PiP. 431 432**Since**: 20 433 434 435**Parameters** 436 437| Parameter| Description| 438| -- | -- | 439| [PictureInPicture_PipConfig](capi-pictureinpicture-pipconfig.md) pipConfig | PiP configuration.| 440| void* env | Pointer to the NAPI environment.| 441 442**Return value** 443 444| Type| Description| 445| -- | -- | 446| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED**: The device does not support PiP.| 447 448### OH_PictureInPicture_CreatePip() 449 450``` 451int32_t OH_PictureInPicture_CreatePip(PictureInPicture_PipConfig pipConfig, uint32_t* controllerId) 452``` 453 454**Description** 455 456Creates a PiP controller. 457 458**Since**: 20 459 460 461**Parameters** 462 463| Parameter| Description| 464| -- | -- | 465| [PictureInPicture_PipConfig](capi-pictureinpicture-pipconfig.md) pipConfig | PiP configuration.| 466| uint32_t* controllerId | Pointer to the ID of the PiP controller created.| 467 468**Return value** 469 470| Type| Description| 471| -- | -- | 472| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED**: The device does not support PiP.<br>**WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR**: An internal error occurs in PiP.| 473 474### OH_PictureInPicture_DeletePip() 475 476``` 477int32_t OH_PictureInPicture_DeletePip(uint32_t controllerId) 478``` 479 480**Description** 481 482Deletes a PiP controller. 483 484**Since**: 20 485 486 487**Parameters** 488 489| Parameter| Description| 490| -- | -- | 491| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 492 493**Return value** 494 495| Type| Description| 496| -- | -- | 497| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.| 498 499### OH_PictureInPicture_StartPip() 500 501``` 502int32_t OH_PictureInPicture_StartPip(uint32_t controllerId) 503``` 504 505**Description** 506 507Starts PiP. 508 509**Since**: 20 510 511 512**Parameters** 513 514| Parameter| Description| 515| -- | -- | 516| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 517 518**Return value** 519 520| Type| Description| 521| -- | -- | 522| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_PIP_STATE_ABNORMAL**: The PiP window is abnormal.<br>**WINDOW_MANAGER_ERRORCODE_PIP_CREATE_FAILED**: Creating the PiP window fails.<br>**WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR**: An internal error occurs in PiP.<br>**WINDOW_MANAGER_ERRORCODE_PIP_REPEATED_OPERATION**: The PiP window is manipulated repeatedly.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.| 523 524### OH_PictureInPicture_StopPip() 525 526``` 527int32_t OH_PictureInPicture_StopPip(uint32_t controllerId) 528``` 529 530**Description** 531 532Stops PiP. 533 534**Since**: 20 535 536 537**Parameters** 538 539| Parameter| Description| 540| -- | -- | 541| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 542 543**Return value** 544 545| Type| Description| 546| -- | -- | 547| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_PIP_DESTROY_FAILED**: Destroying the PiP window fails.<br>**WINDOW_MANAGER_ERRORCODE_PIP_STATE_ABNORMAL**: The PiP window is abnormal.<br>**WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR**: An internal error occurs in PiP.<br>**WINDOW_MANAGER_ERRORCODE_PIP_REPEATED_OPERATION**: The PiP window is manipulated repeatedly.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.| 548 549### OH_PictureInPicture_UpdatePipContentSize() 550 551``` 552int32_t OH_PictureInPicture_UpdatePipContentSize(uint32_t controllerId, uint32_t width, uint32_t height) 553``` 554 555**Description** 556 557Updates the media content size when the media content changes. 558 559**Since**: 20 560 561 562**Parameters** 563 564| Parameter| Description| 565| -- | -- | 566| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 567| uint32_t width | Width of the media content, in px. The value must be a positive integer. It is used to update the aspect ratio of the PiP window.| 568| uint32_t height | Height of the media content, in px. The value must be a positive integer. It is used to update the aspect ratio of the PiP window.| 569 570**Return value** 571 572| Type| Description| 573| -- | -- | 574| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR**: An internal error occurs in PiP.| 575 576### OH_PictureInPicture_UpdatePipControlStatus() 577 578``` 579int32_t OH_PictureInPicture_UpdatePipControlStatus(uint32_t controllerId, PictureInPicture_PipControlType controlType, PictureInPicture_PipControlStatus status) 580``` 581 582**Description** 583 584Updates the PiP component status. 585 586**Since**: 20 587 588 589**Parameters** 590 591| Parameter| Description| 592| -- | -- | 593| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 594| [PictureInPicture_PipControlType](#pictureinpicture_pipcontroltype) controlType | Type of the component displayed on the PiP controller. Currently, only **VIDEO_PLAY_PAUSE**, **MICROPHONE_SWITCH**, **CAMERA_SWITCH**, and **MUTE_SWITCH** are supported.| 595| [PictureInPicture_PipControlStatus](#pictureinpicture_pipcontrolstatus) status | Status of the component displayed on the PiP controller.| 596 597**Return value** 598 599| Type| Description| 600| -- | -- | 601| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR**: An internal error occurs in PiP.| 602 603### OH_PictureInPicture_SetPipControlEnabled() 604 605``` 606int32_t OH_PictureInPicture_SetPipControlEnabled(uint32_t controllerId, PictureInPicture_PipControlType controlType, bool enabled) 607``` 608 609**Description** 610 611Sets the PiP component enabled status. 612 613**Since**: 20 614 615 616**Parameters** 617 618| Parameter| Description| 619| -- | -- | 620| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 621| [PictureInPicture_PipControlType](#pictureinpicture_pipcontroltype) controlType | Type of the component displayed on the PiP controller.| 622| bool enabled | Enabled status of the component displayed on the PiP controller. **true** if enabled, **false** otherwise.| 623 624**Return value** 625 626| Type| Description| 627| -- | -- | 628| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR**: An internal error occurs in PiP.| 629 630### OH_PictureInPicture_RegisterStartPipCallback() 631 632``` 633int32_t OH_PictureInPicture_RegisterStartPipCallback(uint32_t controllerId, WebPipStartPipCallback callback) 634``` 635 636**Description** 637 638Registers a callback to listen for the completion of PiP surface creation. 639 640**Since**: 20 641 642 643**Parameters** 644 645| Parameter| Description| 646| -- | -- | 647| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 648| [WebPipStartPipCallback](#webpipstartpipcallback) callback | Callback function for PiP window creation.| 649 650**Return value** 651 652| Type| Description| 653| -- | -- | 654| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED**: The device does not support PiP.<br>**WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR**: An internal error occurs in PiP.| 655 656### OH_PictureInPicture_UnregisterStartPipCallback() 657 658``` 659int32_t OH_PictureInPicture_UnregisterStartPipCallback(uint32_t controllerId, WebPipStartPipCallback callback) 660``` 661 662**Description** 663 664Unregisters the callback used to listen for the completion of PiP surface creation. 665 666**Since**: 20 667 668 669**Parameters** 670 671| Parameter| Description| 672| -- | -- | 673| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 674| [WebPipStartPipCallback](#webpipstartpipcallback) callback | Callback function for PiP window creation.| 675 676**Return value** 677 678| Type| Description| 679| -- | -- | 680| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED**: The device does not support PiP.<br>**WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR**: An internal error occurs in PiP.| 681 682### OH_PictureInPicture_UnregisterAllStartPipCallbacks() 683 684``` 685int32_t OH_PictureInPicture_UnregisterAllStartPipCallbacks(uint32_t controllerId) 686``` 687 688**Description** 689 690Unregisters all the callbacks used to listen for the completion of PiP surface creation. 691 692**Since**: 20 693 694 695**Parameters** 696 697| Parameter| Description| 698| -- | -- | 699| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 700 701**Return value** 702 703| Type| Description| 704| -- | -- | 705| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED**: The device does not support PiP.<br>**WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR**: An internal error occurs in PiP.| 706 707### OH_PictureInPicture_RegisterLifecycleListener() 708 709``` 710int32_t OH_PictureInPicture_RegisterLifecycleListener(uint32_t controllerId, WebPipLifecycleCallback callback) 711``` 712 713**Description** 714 715Registers a callback to listen for PiP lifecycle state changes. 716 717**Since**: 20 718 719 720**Parameters** 721 722| Parameter| Description| 723| -- | -- | 724| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 725| [WebPipLifecycleCallback](#webpiplifecyclecallback) callback | Callback function for PiP window lifecycle changes.| 726 727**Return value** 728 729| Type| Description| 730| -- | -- | 731| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED**: The device does not support PiP.<br>**WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR**: An internal error occurs in PiP.| 732 733### OH_PictureInPicture_UnregisterLifecycleListener() 734 735``` 736int32_t OH_PictureInPicture_UnregisterLifecycleListener(uint32_t controllerId, WebPipLifecycleCallback callback) 737``` 738 739**Description** 740 741Unregisters the callback used to listen for PiP lifecycle state changes. 742 743**Since**: 20 744 745 746**Parameters** 747 748| Parameter| Description| 749| -- | -- | 750| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 751| [WebPipLifecycleCallback](#webpiplifecyclecallback) callback | Callback function for PiP window lifecycle changes.| 752 753**Return value** 754 755| Type| Description| 756| -- | -- | 757| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED**: The device does not support PiP.<br>**WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR**: An internal error occurs in PiP.| 758 759### OH_PictureInPicture_UnregisterAllLifecycleListeners() 760 761``` 762int32_t OH_PictureInPicture_UnregisterAllLifecycleListeners(uint32_t controllerId) 763``` 764 765**Description** 766 767Unregisters all the callbacks used to listen for PiP lifecycle state changes. 768 769**Since**: 20 770 771 772**Parameters** 773 774| Parameter| Description| 775| -- | -- | 776| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 777 778**Return value** 779 780| Type| Description| 781| -- | -- | 782| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED**: The device does not support PiP.<br>**WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR**: An internal error occurs in PiP.| 783 784### OH_PictureInPicture_RegisterControlEventListener() 785 786``` 787int32_t OH_PictureInPicture_RegisterControlEventListener(uint32_t controllerId, WebPipControlEventCallback callback) 788``` 789 790**Description** 791 792Registers a callback to listen for control panel action events in PiP mode. 793 794**Since**: 20 795 796 797**Parameters** 798 799| Parameter| Description| 800| -- | -- | 801| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 802| [WebPipControlEventCallback](#webpipcontroleventcallback) callback | Callback function for the component click event of the PiP window.| 803 804**Return value** 805 806| Type| Description| 807| -- | -- | 808| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED**: The device does not support PiP.<br>**WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR**: An internal error occurs in PiP.| 809 810### OH_PictureInPicture_UnregisterControlEventListener() 811 812``` 813int32_t OH_PictureInPicture_UnregisterControlEventListener(uint32_t controllerId, WebPipControlEventCallback callback) 814``` 815 816**Description** 817 818Unregisters the callback used to listen for control panel action events in PiP mode. 819 820**Since**: 20 821 822 823**Parameters** 824 825| Parameter| Description| 826| -- | -- | 827| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 828| [WebPipControlEventCallback](#webpipcontroleventcallback) callback | Callback function for the component click event of the PiP window.| 829 830**Return value** 831 832| Type| Description| 833| -- | -- | 834| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED**: The device does not support PiP.<br>**WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR**: An internal error occurs in PiP.| 835 836### OH_PictureInPicture_UnregisterAllControlEventListeners() 837 838``` 839int32_t OH_PictureInPicture_UnregisterAllControlEventListeners(uint32_t controllerId) 840``` 841 842**Description** 843 844Unregisters all the callbacks used to listen for control panel action events in PiP mode. 845 846**Since**: 20 847 848 849**Parameters** 850 851| Parameter| Description| 852| -- | -- | 853| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 854 855**Return value** 856 857| Type| Description| 858| -- | -- | 859| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED**: The device does not support PiP.<br>**WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR**: An internal error occurs in PiP.| 860 861### OH_PictureInPicture_RegisterResizeListener() 862 863``` 864int32_t OH_PictureInPicture_RegisterResizeListener(uint32_t controllerId, WebPipResizeCallback callback) 865``` 866 867**Description** 868 869Registers a callback to listen for PiP window size changes. 870 871**Since**: 20 872 873 874**Parameters** 875 876| Parameter| Description| 877| -- | -- | 878| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 879| [WebPipResizeCallback](#webpipresizecallback) callback | Callback function for PiP window size changes.| 880 881**Return value** 882 883| Type| Description| 884| -- | -- | 885| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED**: The device does not support PiP.<br>**WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR**: An internal error occurs in PiP.| 886 887### OH_PictureInPicture_UnregisterResizeListener() 888 889``` 890int32_t OH_PictureInPicture_UnregisterResizeListener(uint32_t controllerId, WebPipResizeCallback callback) 891``` 892 893**Description** 894 895Unregisters the callback used to listen for PiP window size changes. 896 897**Since**: 20 898 899 900**Parameters** 901 902| Parameter| Description| 903| -- | -- | 904| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 905| [WebPipResizeCallback](#webpipresizecallback) callback | Callback function for PiP window size changes.| 906 907**Return value** 908 909| Type| Description| 910| -- | -- | 911| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED**: The device does not support PiP.<br>**WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR**: An internal error occurs in PiP.| 912 913### OH_PictureInPicture_UnregisterAllResizeListeners() 914 915``` 916int32_t OH_PictureInPicture_UnregisterAllResizeListeners(uint32_t controllerId) 917``` 918 919**Description** 920 921Unregisters all the callbacks used to listen for PiP window size changes. 922 923**Since**: 20 924 925**Parameters** 926 927| Parameter| Description| 928| -- | -- | 929| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 930 931**Return value** 932 933| Type| Description| 934| -- | -- | 935| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED**: The device does not support PiP.<br>**WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR**: An internal error occurs in PiP.| 936 937### OH_PictureInPicture_SetPipInitialSurfaceRect() 938 939``` 940int32_t OH_PictureInPicture_SetPipInitialSurfaceRect(uint32_t controllerId, int32_t positionX, int32_t positionY,uint32_t width, uint32_t height) 941``` 942 943**Description** 944 945Sets the initial position and size of the PiP surface when the PiP launch animation starts. It can be used to achieve a seamless transition effect. 946 947**Since**: 20 948 949**Parameters** 950 951| Parameter| Description| 952| -- | -- | 953| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 954| int32_t positionX | X coordinate of the PiP window relative to the upper-left corner of the screen when the PiP window is started, in px.| 955| int32_t positionY | Y coordinate of the PiP window relative to the upper-left corner of the screen when the PiP window is started, in px.| 956| uint32_t width | Width of the PiP window when the PiP window is started. The value is greater than 0, measured in px.| 957| uint32_t height | Height of the PiP window when the PiP window is started. The value is greater than 0, measured in px.| 958 959**Return value** 960 961| Type| Description| 962| -- | -- | 963| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR**: An internal error occurs in PiP.| 964 965### OH_PictureInPicture_UnsetPipInitialSurfaceRect() 966 967``` 968int32_t OH_PictureInPicture_UnsetPipInitialSurfaceRect(uint32_t controllerId) 969``` 970 971**Description** 972 973Cancels the previously set initial position and size for the PiP surface. 974 975**Since**: 20 976 977**Parameters** 978 979| Parameter| Description| 980| -- | -- | 981| uint32_t controllerId | ID of the PiP controller. The value is a non-negative integer.| 982 983**Return value** 984 985| Type| Description| 986| -- | -- | 987| int32_t | One of the following result codes:<br>**OK**: The function is successfully called.<br>**WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM**: A parameter is incorrect.<br>**WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR**: An internal error occurs in PiP.| 988