Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
Add notice sound
Browse files Browse the repository at this point in the history
  • Loading branch information
ukatama committed Sep 10, 2017
1 parent cc4d96d commit a518010
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/browser/utilities/noticeSound.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const AudioContext = window.AudioContext || window.webkitAudioContext;
const audioContext = new AudioContext();

const gain = audioContext.createGain();
gain.connect(audioContext.destination);

export default function playNoticeSound() {
const oscillator = audioContext.createOscillator();
oscillator.type = 'sine';
oscillator.frequency.value = 523.251;
oscillator.connect(gain);
oscillator.start();
setTimeout(() => {
oscillator.stop();
}, 100);
}
6 changes: 6 additions & 0 deletions src/browser/vue/MessageListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<script>
import { inOutSign } from 'ease-component';
import scroll from 'scroll';
import playNoticeSound from '../utilities/noticeSound';
import FromNow from './FromNow.vue';
import MessageBody from './MessageBody.vue';
Expand All @@ -32,6 +33,11 @@ export default {
props: [
'message',
],
created() {
if (Date.now() - this.message.createdAt < 1000) {
playNoticeSound();
}
},
mounted() {
const item = this.$refs.root;
const scrollable = item.closest('.neko-scroll');
Expand Down

0 comments on commit a518010

Please sign in to comment.