diff --git a/media/JSCamera/README.md b/media/JSCamera/README.md new file mode 100644 index 0000000000000000000000000000000000000000..93a94329bb418a4a7bf863fda42b8b308d5cfaab --- /dev/null +++ b/media/JSCamera/README.md @@ -0,0 +1,16 @@ +# JsCamera + +### Introduction + + This sample shows how to use the eTS UI component **\** to implement take photo. + +### Usage + +1. Start the sample app. The **\** component is displayed is loaded. At this time, the camera defaults to the back state. + +2. Click the front button to switch the front camera, and click to turn on/off the flash. + + +### Constraints + +This sample can only be run on standard-system devices. diff --git a/media/JSCamera/README_zh.md b/media/JSCamera/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..6c4f859cdbd1d60ac9f52f31f595e050dc8845e8 --- /dev/null +++ b/media/JSCamera/README_zh.md @@ -0,0 +1,28 @@ +# 摄像头前后置切换、打开/关闭手电筒 + +### 简介 + + 此Demo使用eTS UI中的组件,实现摄像头前后置切换、打开/关闭手电筒。实现效果如下: + +![main](screenshots/device/main.png) + +### 相关概念 + +camera:摄像头组件,通过在布局中使用camera组件,设置前后置摄像头、打开/关闭手电筒功能。 + +### 相关权限 + +不涉及。 + +### 使用说明 + +1.启动应用,界面展示组件,加载手机摄像头,此时摄像头默认为后置状态。 + +2.点击前置按钮切换前面摄像头,点击打开/关闭手电筒。 + + +### 约束与限制 + +1.本示例仅支持标准系统上运行。 + +2.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.901, built on May 30, 2022)才可编译运行。 \ No newline at end of file diff --git a/media/JSCamera/entry/build.gradle b/media/JSCamera/entry/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..1587dd1948941f3eaaf092ae6cae7969cb6895ff --- /dev/null +++ b/media/JSCamera/entry/build.gradle @@ -0,0 +1,21 @@ +apply plugin: 'com.huawei.ohos.hap' +//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 +ohos { + compileSdkVersion 7 + defaultConfig { + compatibleSdkVersion 7 + } + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) + testImplementation 'junit:junit:4.13.1' +} diff --git a/media/JSCamera/entry/proguard-rules.pro b/media/JSCamera/entry/proguard-rules.pro new file mode 100644 index 0000000000000000000000000000000000000000..f7666e47561d514b2a76d5a7dfbb43ede86da92a --- /dev/null +++ b/media/JSCamera/entry/proguard-rules.pro @@ -0,0 +1 @@ +# config module specific ProGuard rules here. \ No newline at end of file diff --git a/media/JSCamera/entry/src/main/config.json b/media/JSCamera/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..4160cb882dbc88fcde1bb77d2770d31389a45609 --- /dev/null +++ b/media/JSCamera/entry/src/main/config.json @@ -0,0 +1,66 @@ +{ + "app": { + "bundleName": "com.example.ets01", + "vendor": "example", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.ets01", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "deviceType": [ + "default" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/media/JSCamera/entry/src/main/ets/MainAbility/app.ets b/media/JSCamera/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..2eb18d66dc1b9324405a13e48bce34d033da27b2 --- /dev/null +++ b/media/JSCamera/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/media/JSCamera/entry/src/main/ets/MainAbility/pages/index.ets b/media/JSCamera/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..2607218a6c6be2422e63d4de8d73da8992407a27 --- /dev/null +++ b/media/JSCamera/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import router from '@system.router'; + +@Entry +@Component +struct Index { + @State cameraId: string = 'cameraId'; + @State position: DevicePosition = 1; + @State flash: string = 'on'; + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + + Camera({id:this.cameraId, + resolutionHeight:1920, + resolutionWidth:1080 + }).devicePosition(this.position).width(190).height(190) + + Button("前置摄像头").onClick(() => { + this.position = 0; + }).margin({top:10}).width(200).height(50).backgroundColor('#0D9FFB'); + + Button("后置摄像头").onClick(() => { + this.position = 1; + }).margin({top:10}).width(200).height(50).backgroundColor('#0D9FFB'); + + Button("打开手电筒").onClick(() => { + this.flash = 'torch'; + }).margin({top:10}).width(200).height(50).backgroundColor('#0D9FFB'); + + Button("关闭手电筒").onClick(() => { + this.flash = 'on'; + }).margin({top:10}).width(200).height(50).backgroundColor('#0D9FFB'); + + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/media/JSCamera/entry/src/main/resources/base/element/string.json b/media/JSCamera/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..03b8532c53ca563f8ed6b1e21d20ad3f67a68906 --- /dev/null +++ b/media/JSCamera/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/media/JSCamera/entry/src/main/resources/base/media/icon.png b/media/JSCamera/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/media/JSCamera/entry/src/main/resources/base/media/icon.png differ diff --git a/media/JSCamera/package.json b/media/JSCamera/package.json new file mode 100644 index 0000000000000000000000000000000000000000..0967ef424bce6791893e9a57bb952f80fd536e93 --- /dev/null +++ b/media/JSCamera/package.json @@ -0,0 +1 @@ +{}