Skip to content

Commit

Permalink
fix: "Pause when tabbing out" Feature not working as expected #369
Browse files Browse the repository at this point in the history
fix: scrollbars
  • Loading branch information
ThaUnknown committed Mar 21, 2024
1 parent ebc6513 commit 2c3af49
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
11 changes: 7 additions & 4 deletions common/views/Player/Player.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import Keybinds, { loadWithDefaults, condition } from 'svelte-keybinds'
import { SUPPORTS } from '@/modules/support.js'
import 'rvfc-polyfill'
import IPC from '@/modules/ipc.js'
const emit = createEventDispatcher()
Expand Down Expand Up @@ -263,17 +264,19 @@
function toggleMute () {
muted = !muted
}
let visibilityPaused = true
document.addEventListener('visibilitychange', () => {
const handleVisibility = visibility => {
if (!video?.ended && $settings.playerPause && !pip) {
if (document.visibilityState === 'hidden') {
if (visibility === 'hidden') {
visibilityPaused = paused
paused = true
} else {
if (!visibilityPaused) paused = false
}
}
})
}
let visibilityPaused = true
document.addEventListener('visibilitychange', () => handleVisibility(document.visibilityState))
IPC.on('visibilitychange', handleVisibility)
function tryPlayNext () {
if ($settings.playerAutoplay && !state.value) playNext()
}
Expand Down
2 changes: 1 addition & 1 deletion common/webpack.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ module.exports = (parentDir, alias = {}, aliasFields = 'browser', filename = 'ap
${htmlWebpackPlugin.tags.headTags}
</head>
<body class="dark-mode with-custom-webkit-scrollbars with-custom-css-scrollbars">
<body class="dark-mode with-custom-webkit-scrollbars">
${htmlWebpackPlugin.tags.bodyTags}
</body>
Expand Down
3 changes: 3 additions & 0 deletions electron/src/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ function createWindow () {
webtorrentWindow.webContents.openDevTools()
})

mainWindow.on('minimize', () => mainWindow.webContents.postMessage('visibilitychange', 'hidden'))
mainWindow.on('restore', () => mainWindow.webContents.postMessage('visibilitychange', 'visible'))

mainWindow.on('closed', () => {
mainWindow = null
try {
Expand Down

0 comments on commit 2c3af49

Please sign in to comment.