简体   繁体   English

延迟通知声音

[英]Delay Notification Sound

I am working on a group chat app. 我正在使用群聊应用程序。 In a scenario where there are lots of messages coming in, I would like the notification tone to re-played only after an interval. 在有大量消息传入的情况下,我希望仅在间隔后才播放通知音。

Essentially, once notification sound happens, I want notification sound to be turned off for a certain interval (60s) . 本质上,一旦发生通知声音,我希望在一定的时间间隔(60s)中关闭通知声音。 After the interval (60s) has elapsed, if a new message comes, only then the notification tone is re-played and again goes quiet for another 60s and so on. 间隔(60秒)过去之后,如果出现新消息,则仅重播通知音,然后再安静60秒,依此类推。 In between 60s intervals any number of messages would not trigger notification sound. 在60秒的间隔内,任何数量的消息都不会触发通知声音。

So, If I receive my first message at 0 seconds, then for 60 seconds, there will be no notification sound irrespective of number of messages I receive. 因此,如果我在0秒时收到我的第一条消息,那么60秒钟后,无论我收到多少消息,都不会发出通知声。 After 60 seconds, notification sound will be played only on new message and will stay quiet for another 60 seconds. 60秒钟后,通知声音将仅在新消息上播放,并且将保持安静60秒钟。

How can this be implemented. 如何实现。

Thanks Sunny 感谢Sunny

In your Service that creates notifications, when the first message is received, play sound and start a CountDownTimer (with 60 seconds). 在创建通知的Service ,收到第一条消息时,播放声音并启动CountDownTimer (60秒)。 Don't play sound until timer goes to zero. 在计时器归零之前,请勿播放声音。 After timer goes zero, play sound on next notification and reset timer. 计时器归零后,在下一个通知中播放声音并重置计时器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM