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

教做饮品的网站三明网站设计

教做饮品的网站,三明网站设计,物联网有哪些工作岗位,网站建设方案报价单一、问题背景#xff1a; 应用在强提醒场景下#xff0c;一般会有马达振动的效果#xff0c;提示用户注意力的关注。 比如消息提醒#xff0c;扫码提示#xff0c;删除键确认提示等。 针对高定制化或者固定的振动方式#xff0c;我们需要有不同的方案实现#xff0c;马…一、问题背景 应用在强提醒场景下一般会有马达振动的效果提示用户注意力的关注。 比如消息提醒扫码提示删除键确认提示等。 针对高定制化或者固定的振动方式我们需要有不同的方案实现马达振动效果。 二、解决方案 鸿蒙针对振动效果的实现有多种方案目前分为振动和音振协同两种方式。 单纯的只是振动又分为三种方式 系统定制的振动方式例如闹钟非系统定制自定义振动配置json文件的方式线性马达振动只需要设置时间和强度最简单的调用方式 音振协同一般用于音效播放和振动同时的场景例如扫码。 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.timervibrator.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://www.hkea.cn/news/14415668/

相关文章:

  • 网站首页的名字通常是国家公示系统官网
  • 品划网络做网站网页设计电子版教材
  • 重庆怎么自己做网站dede做手机网站
  • 黑龙江省中国建设银行网站首页代理加盟微信网站建设
  • 商城网站包括哪些模块2023免费网站推广
  • 江苏省城乡和住房建设厅网站网站为什么做等保
  • 网站开发课程意见和建议wordpress网址采集
  • 昆山专业做网站wordpress 性能怎么样
  • 做微信推文的网站什么是搜索推广
  • 珠海网站建设专线可以免费建网站的
  • 摄影网站采用照片做宣传_版权费是多少?为网站网站做宣传
  • 网站制作专业网站上的地图导航怎么做
  • 宜宾微信网站建设wordpress page 调用
  • 做项目的网站网站建设制度都有哪些
  • 网站开发服务费vi设计思路怎么写
  • 北京网站建设价格天爱企查在线查询
  • 龙港做网站店铺个人网页制作模板图片代码
  • 鹿泉市建设局网站潮流印花图案设计网站
  • 辽宁住房和城乡建设部网站wordpress本地调试修改域名
  • 阳江做网站多少钱如何删除wordpress文件夹
  • 怎么做交易猫假网站做新闻微网站
  • ui设计和网站建设人员李伟宁做图片网站 侵权
  • 网站开发项目总结小网站广告投放
  • 有哪个网站做ic哪里有帮做微课的网站
  • 网站的建设背景图片青浦区做网站
  • 哈尔滨网站建设哪个好一流的企业网站建设
  • 营销型网站建设的定义大气黑色机械企业网站源码
  • wamp网站根目录配置仙桃哪里做网站
  • 嘉兴做网站设计设计家官网下载
  • 网站怎么添加外链营销型网站主机