草庐IT

javascript - 声音在 Chrome 桌面推送通知中的服务 worker 中不起作用

当我收到通知时,我正在尝试在Chrome浏览器的推送通知中播放声音。我已经在我的网站上设置了浏览器推送通知,但它不播放声音。我已经在浏览声音选项,但听不到声音。option={'body':'ThisiststDescription','icon':'icon.png','silent':'false','sound':'bell.mp3'}如果有任何其他方法可以播放通知中的声音,请告诉我。 最佳答案 或者您可以全局声明myAudio对象并在弹出通知之后或之前使用play()函数。myAudio=newAudio("alert_to

javascript - Safari ios 音频 - 拒绝播​​放错误

javascript错误是:UnhandledPromiseRejection:NotAllowedError:Therequestisnotallowedbytheuseragentortheplatforminthecurrentcontext,possiblebecausetheuserdeniedpermission.我的设置适用于其他浏览器、桌面和移动设备。它的工作方式是:有一个标志first_audio_played=false;添加一个播放音频的触摸事件监听器,并设置first_audio_played=true;(然后移除触摸监听器)所有后续音频检查if(first_a

ios - AVAudioPlayer.currentTime 在更改速率时给出错误的值

当我更改其中一个AVAudioPlayer的rate并稍后调用currentTime时,我得到了错误的值。这是为什么?例如,这段代码没有像我期望的那样工作:AVAudioPlayer*myAudio=//setupAVAudioPlayermyAudio.enableRate=YES;myAudio.rate=1.2;[myAudioplay];//Wait3secondsmyAudio.currentTime;//Returnsavaluesignificantlylargerthan3.0 最佳答案 当您调用AVAudioPla

iphone - 关于 AudioQueue : request to trim 0 + 1676 = 1676 frames from buffer containing 1152 frames 的 XCODE AVAudioPlayer 错误

我试图在不同的时间播放不同的声音。基于按钮按下或定时器超时等。这是代码。播放声音函数:-(void)myPlaySound:(NSString*)mySoundFileNumberOfLoops:(int)loopsCountofType:(NSString*)fileType{NSURL*musicFile=[NSURLfileURLWithPath:[[NSBundlemainBundle]pathForResource:mySoundFileofType:fileType]];myAudio=[[AVAudioPlayeralloc]initWithContentsOfURL:m