diff options
author | Hegymegi Kiss Áron <[email protected]> | 2021-12-11 16:02:07 +0100 |
---|---|---|
committer | Hegymegi Kiss Áron <[email protected]> | 2021-12-11 16:02:07 +0100 |
commit | 9f9df9479bf6cf0bcdd838cb0433a394a1ec814c (patch) | |
tree | 94739ec5de20fdf14c2caff399a2a70f0331d473 /src | |
parent | 1c911581db2f617a4ae6f46c0eb53c840911a618 (diff) | |
download | SponsorBlock-9f9df9479bf6cf0bcdd838cb0433a394a1ec814c.tar.gz SponsorBlock-9f9df9479bf6cf0bcdd838cb0433a394a1ec814c.zip |
move audio notification to content.ts
fixes #756
Diffstat (limited to 'src')
-rw-r--r-- | src/components/SkipNoticeComponent.tsx | 13 | ||||
-rw-r--r-- | src/content.ts | 7 |
2 files changed, 6 insertions, 14 deletions
diff --git a/src/components/SkipNoticeComponent.tsx b/src/components/SkipNoticeComponent.tsx index 6e8876ff..6dffccbd 100644 --- a/src/components/SkipNoticeComponent.tsx +++ b/src/components/SkipNoticeComponent.tsx @@ -74,7 +74,6 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta amountOfPreviousNotices: number; showInSecondSlot: boolean; - audio: HTMLAudioElement; idSuffix: string; @@ -96,7 +95,6 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta this.segments = props.segments; this.autoSkip = props.autoSkip; this.contentContainer = props.contentContainer; - this.audio = null; const noticeTitle = getSkippingText(this.segments, this.props.autoSkip); @@ -156,13 +154,6 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta } } - componentDidMount(): void { - if (Config.config.audioNotificationOnSkip && this.audio) { - this.audio.volume = this.contentContainer().v.volume * 0.1; - if (this.autoSkip) this.audio.play(); - } - } - render(): React.ReactElement { const noticeStyle: React.CSSProperties = { } if (this.contentContainer().onMobileYouTube) { @@ -196,10 +187,6 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta firstColumn={firstColumn} bottomRow={[...this.getMessageBoxes(), ...this.getBottomRow() ]} onMouseEnter={() => this.onMouseEnter() } > - - {(Config.config.audioNotificationOnSkip) && <audio ref={(source) => { this.audio = source; }}> - <source src={chrome.extension.getURL("icons/beep.ogg")} type="audio/ogg"></source> - </audio>} </NoticeComponent> ); } diff --git a/src/content.ts b/src/content.ts index c4bdafef..e4eaedb5 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1242,7 +1242,12 @@ function skipToTime({v, skipTime, skippingSegments, openNotice, forceAutoSkip, u break; } } - + } + + if (autoSkip && Config.config.audioNotificationOnSkip) { + const beep = new Audio(chrome.runtime.getURL("icons/beep.ogg")); + beep.volume = skipNoticeContentContainer().v.volume * 0.1; + beep.play(); } if (!autoSkip |