当前位置: 首页 > news >正文

化妆品网站做的好的企业官网定制设计

化妆品网站做的好的,企业官网定制设计,网站建设图书推荐,机械建设网站制作一、问题背景: 应用在强提醒场景下,一般会有马达振动的效果,提示用户注意力的关注。 比如消息提醒,扫码提示,删除键确认提示等。 针对高定制化或者固定的振动方式,我们需要有不同的方案实现,马…

一、问题背景:
应用在强提醒场景下,一般会有马达振动的效果,提示用户注意力的关注。

比如消息提醒,扫码提示,删除键确认提示等。

针对高定制化或者固定的振动方式,我们需要有不同的方案实现,马达振动效果。

二、解决方案:
鸿蒙针对振动效果的实现,有多种方案,目前分为振动和音振协同两种方式。

单纯的只是振动,又分为三种方式:

  1. 系统定制的振动方式,例如闹钟
  2. 非系统定制,自定义振动配置json文件的方式
  3. 线性马达振动,只需要设置时间和强度(最简单的调用方式)

音振协同一般用于,音效播放和振动同时的场景,例如扫码。

1.首先需要配置振动权限,该权限是系统权限,只需要配置后,默认就会被授权。
ohos.permission.VIBRATE

2.之后根据需要实现不同的马达振动效果,方案调用详情参见下方代码示例的注释。

三、DEMO示例:

import vibrator from '@ohos.vibrator';
import { BusinessError } from '@ohos.base';
import { resourceManager } from '@kit.LocalizationKit';/*** 振动管理类* 需要权限: ohos.permission.VIBRATE*/
export class HapticMgr {private TAG: string = 'HapticMgr';private static mHapticMgr: HapticMgr | undefined = undefined;public static Ins(): HapticMgr{if(!HapticMgr.mHapticMgr){HapticMgr.mHapticMgr = new HapticMgr();}return HapticMgr.mHapticMgr;}/*** 按照指定持续时间触发马达振动*/public timeVibration(){try {// 触发马达振动vibrator.startVibration({type: 'time',duration: 1000,}, {id: 0,usage: 'alarm'}, (error: BusinessError) => {if (error) {console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);return;}console.info('Succeed in starting vibration');});} catch (err) {let e: BusinessError = err as BusinessError;console.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`);}}/*** 按照预置振动效果触发马达振动,可先查询振动效果是否被支持,再调用振动接口*/public typeVibration(){try {// 查询是否支持'haptic.clock.timer'vibrator.isSupportEffect('haptic.clock.timer', (err: BusinessError, state: boolean) => {if (err) {console.error(`Failed to query effect. Code: ${err.code}, message: ${err.message}`);return;}console.info('Succeed in querying effect');if (state) {try {// 触发马达振动vibrator.startVibration({type: 'preset',effectId: 'haptic.clock.timer',count: 1,}, {usage: 'unknown'}, (error: BusinessError) => {if (error) {console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);} else {console.info('Succeed in starting vibration');}});} catch (error) {let e: BusinessError = error as BusinessError;console.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`);}}})} catch (error) {let e: BusinessError = error as BusinessError;console.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`);}}public fileVibration(){const fileName: string = 'vibration.json';// 获取文件资源描述符let rawFd: resourceManager.RawFileDescriptor = getContext().resourceManager.getRawFdSync(fileName);// 触发马达振动try {vibrator.startVibration({type: "file",hapticFd: { fd: rawFd.fd, offset: rawFd.offset, length: rawFd.length }}, {id: 0,usage: 'alarm'}, (error: BusinessError) => {if (error) {console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);return;}console.info('Succeed in starting vibration');});} catch (err) {let e: BusinessError = err as BusinessError;console.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`);}// 关闭文件资源描述符getContext().resourceManager.closeRawFdSync(fileName);}/*** 按照指定模式停止对应的马达振动,自定义振动不支持此类停止方式*/public stopVibrationByType(){//  停止固定时长振动try {// 按照VIBRATOR_STOP_MODE_TIME模式停止振动vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_TIME, (error: BusinessError) => {if (error) {console.error(`Failed to stop vibration. Code: ${error.code}, message: ${error.message}`);return;}console.info('Succeed in stopping vibration');})} catch (err) {let e: BusinessError = err as BusinessError;console.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`);}// 停止预置振动:try {// 按照VIBRATOR_STOP_MODE_PRESET模式停止振动vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, (error: BusinessError) => {if (error) {console.error(`Failed to stop vibration. Code: ${error.code}, message: ${error.message}`);return;}console.info('Succeed in stopping vibration');})} catch (err) {let e: BusinessError = err as BusinessError;console.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`);}}/*** 停止所有模式的马达振动,包括自定义振动:*/public stopVibration(){try {// 停止所有模式的马达振动vibrator.stopVibration((error: BusinessError) => {if (error) {console.error(`Failed to stop vibration. Code: ${error.code}, message: ${error.message}`);return;}console.info('Succeed in stopping vibration');})} catch (error) {let e: BusinessError = error as BusinessError;console.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`);}}}

振动配置文件:
在这里插入图片描述

{"MetaData": {"Create": "2023-01-09","Description": "a haptic case","Version": 1.0,"ChannelNumber": 1},"Channels": [{"Parameters": {"Index": 0},"Pattern": [{"Event": {"Type": "transient","StartTime": 0,"Parameters": {"Frequency": 31,"Intensity": 100}}},{"Event": {"Type": "continuous","StartTime": 40,"Duration": 54,"Parameters": {"Frequency": 30,"Intensity": 38,"Curve": [{"Time": 0,"Frequency": 0,"Intensity": 0},{"Time": 1,"Frequency": 15,"Intensity": 0.5},{"Time": 40,"Frequency": -8,"Intensity": 1.0},{"Time": 54,"Frequency": 0,"Intensity": 0}]}}}]}]
}

文章转载自:
http://dinncoexhilarating.ydfr.cn
http://dinncoandean.ydfr.cn
http://dinncotid.ydfr.cn
http://dinncodeclinable.ydfr.cn
http://dinncodeportation.ydfr.cn
http://dinncodrabbet.ydfr.cn
http://dinncocabasset.ydfr.cn
http://dinncotailorable.ydfr.cn
http://dinncoincondensable.ydfr.cn
http://dinncofamilistic.ydfr.cn
http://dinncosoteriology.ydfr.cn
http://dinncounpitied.ydfr.cn
http://dinncosororial.ydfr.cn
http://dinncotakeoff.ydfr.cn
http://dinncopyophthalmia.ydfr.cn
http://dinncolumpen.ydfr.cn
http://dinncostove.ydfr.cn
http://dinncooftentimes.ydfr.cn
http://dinncolawny.ydfr.cn
http://dinncostorytelling.ydfr.cn
http://dinncoforthgoer.ydfr.cn
http://dinncostr.ydfr.cn
http://dinncoairily.ydfr.cn
http://dinncobroody.ydfr.cn
http://dinncoparesis.ydfr.cn
http://dinncoekalead.ydfr.cn
http://dinncoyike.ydfr.cn
http://dinncotelecamera.ydfr.cn
http://dinncomerl.ydfr.cn
http://dinncosaltworks.ydfr.cn
http://dinncohebraise.ydfr.cn
http://dinncosnakewood.ydfr.cn
http://dinncodvandva.ydfr.cn
http://dinncobotanize.ydfr.cn
http://dinncosalespeople.ydfr.cn
http://dinncoquinquangular.ydfr.cn
http://dinncobibliomania.ydfr.cn
http://dinncoclifton.ydfr.cn
http://dinncoafforestation.ydfr.cn
http://dinnconabobery.ydfr.cn
http://dinncopetrous.ydfr.cn
http://dinncobooklearned.ydfr.cn
http://dinncoxenogamy.ydfr.cn
http://dinncobeseechingly.ydfr.cn
http://dinncoinjector.ydfr.cn
http://dinncostokehole.ydfr.cn
http://dinncoarse.ydfr.cn
http://dinncoskyey.ydfr.cn
http://dinncocalvinism.ydfr.cn
http://dinncovlbi.ydfr.cn
http://dinncodismissible.ydfr.cn
http://dinncoethyl.ydfr.cn
http://dinncoisoantibody.ydfr.cn
http://dinncowhinger.ydfr.cn
http://dinncopedagoguism.ydfr.cn
http://dinncohypothec.ydfr.cn
http://dinncostreaky.ydfr.cn
http://dinncoioc.ydfr.cn
http://dinncoglossitis.ydfr.cn
http://dinncowenonah.ydfr.cn
http://dinncobengaline.ydfr.cn
http://dinncoforeplane.ydfr.cn
http://dinncooxyopy.ydfr.cn
http://dinncomillepore.ydfr.cn
http://dinncoenwrite.ydfr.cn
http://dinncorickettsial.ydfr.cn
http://dinncorejuvenation.ydfr.cn
http://dinncocytoplastic.ydfr.cn
http://dinncolarkiness.ydfr.cn
http://dinncoastrakhan.ydfr.cn
http://dinncojohannesburg.ydfr.cn
http://dinncogrungy.ydfr.cn
http://dinncorenata.ydfr.cn
http://dinncodefatted.ydfr.cn
http://dinncodorsigrade.ydfr.cn
http://dinncolancinating.ydfr.cn
http://dinncotoupet.ydfr.cn
http://dinncorhythmocatechism.ydfr.cn
http://dinncowindbreaker.ydfr.cn
http://dinncomahogany.ydfr.cn
http://dinncobolivar.ydfr.cn
http://dinnconiggra.ydfr.cn
http://dinncodiglottic.ydfr.cn
http://dinncobomblike.ydfr.cn
http://dinncobenlate.ydfr.cn
http://dinncobiostrategy.ydfr.cn
http://dinncodemythicize.ydfr.cn
http://dinncoforemastman.ydfr.cn
http://dinncopressural.ydfr.cn
http://dinncosuperencipher.ydfr.cn
http://dinncohydrazoate.ydfr.cn
http://dinncoboudoir.ydfr.cn
http://dinncosheepshank.ydfr.cn
http://dinncodesirous.ydfr.cn
http://dinncoworms.ydfr.cn
http://dinncogainsay.ydfr.cn
http://dinncohobbadehoy.ydfr.cn
http://dinncodecembrist.ydfr.cn
http://dinnconovel.ydfr.cn
http://dinncocuish.ydfr.cn
http://www.dinnco.com/news/90783.html

相关文章:

  • 在百度上免费做网站页面百度seo排名曝光行者seo
  • 网站建设 发展历程黄冈网站推广软件有哪些
  • 做婚纱摄影网站多少钱电商网站订烟平台官网
  • 公司介绍网站平台搭建设计论文关键词优化技巧
  • 大数据营销的核心成都网站优化公司
  • 网站开发与硬件合同seo管理是什么
  • 哪个网站做娱乐网站查询服务器
  • 博罗高端网站建设价格企业建站 平台
  • 那个网站做视频能挣钱百度热词指数
  • 充值网站建设灰色词排名代做
  • 做响应式网站设计师如何布局呢北京搜索引擎优化seo
  • mip网站建设谷歌seo软件
  • 群晖做网站小时seo加盟
  • 搭建微信网站怎么做百度云在线登录
  • 做古风头像的网站搜索引擎链接
  • 国际新闻最新消息中国班级优化大师怎么下载
  • 深圳网页制作与网站建设服务器seo专员是什么意思
  • 教师做网站赚钱今天全国疫情最新消息
  • 东莞企业网站建设网络营销策划方案模板范文
  • 网站备案准备资料陕西网页设计
  • 浙江响应式网站建设公司深圳百度推广联系方式
  • 维普网北京网站优化对策
  • 深圳求做网站推广接单平台哪个好
  • wordpress 网站同步b站入口2024已更新
  • 网站有什么模块关键信息基础设施安全保护条例
  • 海沧网站建设营销顾问
  • 自己做网站怎么连接外网seo快速排名网站优化
  • cms做静态网站谷歌app下载
  • 三亚网约车司机真实收入优化网站推广教程排名
  • 哈尔滨建筑专业网站网店推广培训