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

个人网站怎么做支付微信上wordpress

个人网站怎么做支付,微信上wordpress,求个网站你懂我的意思吗,傻瓜式做网站哪个软件好flutter开发实战-实现音效soundpool播放音频 最近开发过程中遇到低配置设备时候#xff0c;在Media播放音频时候出现音轨限制问题。所以将部分音频采用音效sound来播放。 一、音效类似iOS中的Sound 在iOS中使用sound来播放mp3音频示例如下 // 通过通知的Sound设置为voip_c…flutter开发实战-实现音效soundpool播放音频 最近开发过程中遇到低配置设备时候在Media播放音频时候出现音轨限制问题。所以将部分音频采用音效sound来播放。 一、音效类似iOS中的Sound 在iOS中使用sound来播放mp3音频示例如下 // 通过通知的Sound设置为voip_call.caf这里播放一段空白音频音频结束后结束震动NSString *path [[NSBundle mainBundle] pathForResource:blank_call.mp3 ofType:nil];AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:path], soundID);AudioServicesAddSystemSoundCompletion(soundID, NULL, NULL, soundCompleteCallback, NULL);AudioServicesAddSystemSoundCompletion(kSystemSoundID_Vibrate, NULL, NULL, soundCompleteCallback, NULL); [self startShakeSound];/// 开始播放与震动 - (void)startShakeSound {// 声音AudioServicesPlaySystemSound(soundID);// 震动AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); }/// 结束播放与震动 - (void)stopShakeSound {AudioServicesDisposeSystemSoundID(soundID);AudioServicesRemoveSystemSoundCompletion(soundID); }//AudioServicesAddSystemSoundCompletion的回调函数 void soundCompleteCallback(SystemSoundID sound,void * clientData) {if (sound kSystemSoundID_Vibrate) {AudioServicesPlayAlertSound(sound);//重复响铃震动} else {// 移除AudioServicesDisposeSystemSoundID(sound);AudioServicesRemoveSystemSoundCompletion(sound);AudioServicesDisposeSystemSoundID(kSystemSoundID_Vibrate);AudioServicesRemoveSystemSoundCompletion(kSystemSoundID_Vibrate);} }在iOS中通过soundID可以控制播放与暂停当然iOS中sound播放完成有通知回调callback。soundpool暂时没找到播放完成回调callback。 二、使用soundpool播放音频 2.1、引入soundpool 在pubspec.yaml中引入 soundpool: ^2.3.02.2、使用soundpool来播放音频 Soundpool的初始化要用到SoundpoolOptions SoundpoolOptions soundpoolOptions SoundpoolOptions(); _soundpool Soundpool.fromOptions(options: soundpoolOptions); _soundId await _soundpool!.loadUri(url);播放控制需要使用AudioStreamControl比如播放、暂停、停止、设置音量等控制操作 播放 _audioStreamControl await _soundpool!.playWithControls(_soundId!);暂停 await _audioStreamControl!.pause();停止 await _audioStreamControl!.stop();设置音量 await _audioStreamControl!.setVolume(volume: volume);2.3、通过播放时长控制是否可以再次播放 由于soundpool没有播放音频完成回调这里采用通过Media将音频时长获取到之后判断时间。判断当前播放时间与上次播放的时间间隔是否超过了音频时长Duration。 if (lastPlayMilliseconds null) {lastPlayMilliseconds TimeUtil.currentTimeMillis();_audioStreamControl await _soundpool!.playWithControls(_soundId!);} else {int nowMilliseconds TimeUtil.currentTimeMillis();bool shouldPlay true;if (audioDurationInMilliseconds ! null) {if (nowMilliseconds - lastPlayMilliseconds! audioDurationInMilliseconds!) {shouldPlay false;}}if (shouldPlay) {// 如果上次没有播放完成不进行播放// 通过判断播放时长_audioStreamControl await _soundpool!.playWithControls(_soundId!);lastPlayMilliseconds nowMilliseconds;}}整体使用soundpool播放音频的相关代码如下 import package:soundpool/soundpool.dart;// 使用SoundPool class SoundPlayer implements BaseAudioPlayer {// AudioStreamControl// SoundpoolSoundpool? _soundpool;String? audioUrl;// 上次播放时长的毫秒数int? lastPlayMilliseconds;// 时长int? audioDurationInMilliseconds;// 优先级late AudioConfig __audioConfig;late bool _playing false; // 是否正在播放int? _soundId;AudioStreamControl? _audioStreamControl;SoundPlayer(this.__audioConfig, {Duration? duration}) {if (duration ! null) {audioDurationInMilliseconds duration!.inMilliseconds;}print(SoundPlayer audioDurationInMilliseconds:${audioDurationInMilliseconds});SoundpoolOptions soundpoolOptions SoundpoolOptions();_soundpool Soundpool.fromOptions(options: soundpoolOptions);setAudioUrl(__audioConfig.audioUrl);}Futurevoid setAudioUrl(String url) async {if (_soundpool ! null) {_soundId await _soundpool!.loadUri(url);}}AudioConfig get_audioConfig() {return __audioConfig;}overridevoid play() async {// Usually you dont want to wait for playback to finish.if (__audioConfig.audioUrl ! null __audioConfig.audioUrl.isNotEmpty _soundId ! null _soundpool ! null) {if (lastPlayMilliseconds null) {lastPlayMilliseconds TimeUtil.currentTimeMillis();_audioStreamControl await _soundpool!.playWithControls(_soundId!);} else {int nowMilliseconds TimeUtil.currentTimeMillis();bool shouldPlay true;if (audioDurationInMilliseconds ! null) {if (nowMilliseconds - lastPlayMilliseconds! audioDurationInMilliseconds!) {shouldPlay false;}}if (shouldPlay) {// 如果上次没有播放完成不进行播放// 通过判断播放时长_audioStreamControl await _soundpool!.playWithControls(_soundId!);lastPlayMilliseconds nowMilliseconds;}}}}overridevoid pause() async {if (__audioConfig.audioUrl ! null __audioConfig.audioUrl.isNotEmpty _audioStreamControl ! null) {try {await _audioStreamControl!.pause();} catch(e) {print(audioStreamControl pause e:${e.toString()});}}}overridevoid stop() async {if (__audioConfig.audioUrl ! null __audioConfig.audioUrl.isNotEmpty _audioStreamControl ! null) {try {await _audioStreamControl!.stop();} catch(e) {print(audioStreamControl stop e:${e.toString()});}}}overridevoid setVolume(double volume) async {if (__audioConfig.audioUrl ! null __audioConfig.audioUrl.isNotEmpty _audioStreamControl ! null) {try {await _audioStreamControl!.setVolume(volume: volume);} catch(e) {print(audioStreamControl setVolume e:${e.toString()});}}}// 不需要该播放器则需要调用该方法overridevoid dispose() {if (_soundpool ! null) {_soundpool!.dispose();}} }三、小结 flutter开发实战-实现音效soundpool播放音频及控制播放、暂停、停止、设置音量等控制操作。 学习记录每天不停进步。
http://www.tj-hxxt.cn/news/136144.html

相关文章:

  • 软件网站建设基本流程图网站建设毕业设计报告书
  • 梯子seo网络优化师招聘
  • 网站后台英语财务软件哪个好用
  • 网站推广公司汉狮网络江干区网站建设
  • 北京网站推广优化上海网站建设推荐案例
  • 网站搜索推广方案论文上海网站备案审核
  • 哪种类型的网站比较难做制作英文网站多少钱
  • 360永久免费建网站专业柳州网站建设多少钱
  • 济南外贸网站中国建设app官方下载
  • 免费网站模板怎么做网站做的网站怎么上传到网上
  • 中国手机最好的网站排名电商系统app开发
  • 中国建设招标网 官方网站下载wordpress数据库重置密码
  • 平板电脑可以做网站吗有哪些做的很漂亮的网站
  • 晋中住房与城乡建设厅网站wordpress链接失效
  • 网站关键词库是怎么做的企业网站建设运营方案
  • 银川网站建设公司哪家不错Php外贸网站建设新浪博客
  • 两学一做学习网站温州平阳县网站建设兼职
  • 黑白的网站网站如何做tag
  • 自己做图网站北京建设工程招标信息网站
  • 网站logo设计创意网站建设与管理项目1项目规划
  • 企业网站备案流程湖北省市政工程建设官方网站
  • 北京天奕时代创意设计有限公司seo运营招聘
  • 高端网站改版内部网站做域名解析到端口
  • 成都美食网站设计论文wordpress ftp下载
  • 优客工场 网站开发深圳电商页面设计那家好
  • 网站建设拟采用的技术路线福步外贸论坛登录
  • 全球网站域名做网站项目如何实现支付
  • 响应式企业网站cms安卓app软件公司
  • 株洲seo网站优化wordpress 完整模板
  • 校园网站建设方案网站分辨率做96是否会更好