Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
4f43a773
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4f43a773
编写于
8月 25, 2022
作者:
L
lanyill
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
xcomponent文档修改
Signed-off-by:
N
lanyill
<
lanyi3@huawei.com
>
上级
c60e6d33
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
42 addition
and
24 deletion
+42
-24
zh-cn/application-dev/reference/arkui-ts/ts-basic-components-xcomponent.md
...-dev/reference/arkui-ts/ts-basic-components-xcomponent.md
+42
-24
未找到文件。
zh-cn/application-dev/reference/arkui-ts/ts-basic-components-xcomponent.md
浏览文件 @
4f43a773
# XComponent
可用于EGL/OpenGLES和媒体数据写入,并显示在XComponent组件。
> **说明:**
>
**说明:**
>
> 该组件从API Version 8 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本
。
>
该组件从API Version 8 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
可用于EGL/OpenGLES和媒体数据写入,并显示在XComponent组件
。
## 权限列表
...
...
@@ -16,23 +16,36 @@
## 接口
XComponent(value: {id: string, type: string, libraryname?: string, controller?: XComponentController}
)
XComponent
\(
value: {id: string, type: string, libraryname?: string, controller?: XComponentController}
\
)
**参数
:**
**参数
:**
|
名称 | 参数类型 | 必填 | 描述
|
| ---------
-- | --------------------------------------------- | ---- | -------------------------------------------------------
----- |
| id
| string | 是 | 组件的唯一标识,支持最大的字符串长度128。
|
| type
| string | 是 |
用于指定XComponent组件类型,可选值为:
<br/>
-surface:组件内容单独送显,直接合成到屏幕。
<br/>
-component:组件内容与其他组件合成后统一送显。 |
| libraryname | string
| 否 | 应用Native层编译输出动态库名称。
|
| controller
|
[
XComponentController
](
#xcomponentcontroller
)
| 否 | 给组件绑定一个控制器,通过控制器调用组件方法。
|
|
参数名 | 参数类型 | 必填 | 描述
|
| ---------
| ------ | ---- |
----- |
| id
| string | 是 | 组件的唯一标识,支持最大的字符串长度128。
|
| type
| string | 是 |
用于指定XComponent组件类型,可选值为:
<br/>
-surface:组件内容单独送显,直接合成到屏幕。
<br/>
-component:组件内容与其他组件合成后统一送显。 |
| libraryname | string
| 否 | 应用Native层编译输出动态库名称。
|
| controller
|
[
XComponentcontroller
](
#xcomponentcontroller
)
| 否 | 给组件绑定一个控制器,通过控制器调用组件方法。
|
## 事件
| 名称 | 功能描述 |
| -------------------------------- | ------------ |
| onLoad(callback: (event?: object) => void) | 插件加载完成时回调事件, 返回值object即为XComponent实例对象的context。 |
| onDestroy(event: () => void) | 插件卸载完成时回调事件。 |
### onLoad
onLoad(callback: (event?: object) => void )
插件加载完成时回调事件。
**参数:**
| 参数名 | 参数类型 | 必填 | 描述 |
| ------------- | ------ | ---- | ----------------------- |
| event | object | 否 | 获取XComponent实例对象的context,context上挂载的方法由开发者在c++层定义。 |
### onDestroy
onDestroy(event: () => void )
插件卸载完成时回调事件。
## XComponentController
...
...
@@ -50,7 +63,9 @@ getXComponentSurfaceId(): string
获取XComponent对应Surface的ID,供@ohos接口使用,比如camera相关接口。
**返回值:**
**系统接口:**
此接口为系统接口。
**返回值:**
| 类型 | 描述 |
| ------ | ----------------------- |
...
...
@@ -62,12 +77,14 @@ setXComponentSurfaceSize(value: {surfaceWidth: number, surfaceHeight: number}):
设置XComponent持有Surface的宽度和高度。
**
参数:**
**
系统接口:**
此接口为系统接口。
| 参数名 | 参数类型 | 必填 | 默认值 | 描述 |
| ------------- | ------ | ---- | ---- | ----------------------- |
| surfaceWidth | number | 是 | - | XComponent持有Surface的宽度。 |
| surfaceHeight | number | 是 | - | XComponent持有Surface的高度。 |
**参数:**
| 参数名 | 参数类型 | 必填 | 描述 |
| ------------- | ------ | ---- | ----------------------- |
| surfaceWidth | number | 是 | XComponent持有Surface的宽度。 |
| surfaceHeight | number | 是 | XComponent持有Surface的高度。 |
### getXComponentContext
...
...
@@ -75,7 +92,7 @@ getXComponentContext(): Object
获取XComponent实例对象的context。
**返回值
:
**
**返回值
:
**
| 类型 | 描述 |
| ------ | ---------------------------------------- |
...
...
@@ -87,6 +104,7 @@ getXComponentContext(): Object
示例效果请以真机运行为准,当前IDE预览器不支持。
```
ts
// xxx.ets
import
camera
from
'
@ohos.multimedia.camera
'
;
@
Entry
@
Component
...
...
@@ -114,4 +132,4 @@ struct PreviewArea {
.
position
({
x
:
0
,
y
:
48
})
}
}
```
\ No newline at end of file
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录