Skip to content

Commit

Permalink
fix: yt blackscreens during seek
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmaddock committed Aug 18, 2024
1 parent 46a17c1 commit ddcaa92
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
21 changes: 19 additions & 2 deletions packages/metastream-app/src/components/lobby/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { StorageKey } from 'constants/storage'
import { EMBED_BLOCKED_DOMAIN_LIST } from 'constants/embed'
import { IdleScreen } from './overlays/IdleScreen'
import { setVolume } from 'actions/settings'
import { ytDomains } from 'constants/domains'

type MediaReadyPayload = {
duration?: number
Expand Down Expand Up @@ -217,7 +218,7 @@ class _VideoPlayer extends PureComponent<PrivateProps, IState> {
}

if (playerSettings !== prevProps.playerSettings) {
this.dispatchMedia('set-settings', playerSettings)
this.updatePlayerSettings(playerSettings)
}

if (current !== prevMedia) {
Expand Down Expand Up @@ -379,7 +380,7 @@ class _VideoPlayer extends PureComponent<PrivateProps, IState> {
this.mediaTimeout = -1
}

this.dispatchMedia('set-settings', this.props.playerSettings)
this.updatePlayerSettings(this.props.playerSettings)

// Apply auto-fullscreen to all subframes with nested iframes
const isValidFrameSender = !isTopSubFrame || this.shouldRenderPopup
Expand Down Expand Up @@ -458,6 +459,22 @@ class _VideoPlayer extends PureComponent<PrivateProps, IState> {
this.dispatchMedia('set-media-playback-rate', playbackRate)
}

private updatePlayerSettings = (settings: PlayerSettings) => {
let url
try {
url = new URL(this.mediaUrl)

// 2024: disable due to blackscreens during seek
if (ytDomains.has(url.hostname)) {
settings = { ...settings, mediaSessionProxy: false }
}
} catch {
// ignore
}

this.dispatchMedia('set-settings', settings)
}

private updateVolume = () => {
const { volume, mute } = this.props

Expand Down
1 change: 1 addition & 0 deletions packages/metastream-app/src/constants/domains.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const ytDomains = new Set(['www.youtube.com', 'www.youtu.be', 'm.youtube.com', 'youtube.com']);

0 comments on commit ddcaa92

Please sign in to comment.