🩹(frontend) fix screen sharing warnings browser compatibility
This feature is far from perfect. Still not working on Safari. Also, we should display this warning when user share the current opened window. Minor enhancement, I don't have time currently to prioritize these enhancements.
This commit is contained in:
committed by
aleb_the_flash
parent
ccca2b9472
commit
354bdd8bfe
@@ -20,14 +20,41 @@ export const FullScreenShareWarning = ({
|
||||
const { localParticipant } = useLocalParticipant()
|
||||
const screenSharePreferences = useSnapshot(ScreenSharePreferenceStore)
|
||||
|
||||
const isFullScreenCapture = useMemo(() => {
|
||||
const trackLabel =
|
||||
trackReference.publication?.track?.mediaStreamTrack?.label
|
||||
return trackLabel?.includes('screen')
|
||||
const isFullScreenSharing = useMemo(() => {
|
||||
if (trackReference?.source !== 'screen_share') return false
|
||||
|
||||
const mediaStreamTrack = trackReference.publication?.track?.mediaStreamTrack
|
||||
|
||||
if (!mediaStreamTrack) return false
|
||||
|
||||
// Method 1: Display Surface Check (Chrome & Edge)
|
||||
const trackSettings = mediaStreamTrack.getSettings()
|
||||
if (trackSettings?.displaySurface) {
|
||||
return trackSettings.displaySurface === 'monitor'
|
||||
}
|
||||
|
||||
// Method 2: Track Constraints Check
|
||||
const constraints = mediaStreamTrack.getConstraints()
|
||||
if (constraints?.displaySurface) {
|
||||
return constraints.displaySurface === 'monitor'
|
||||
}
|
||||
|
||||
// Method 3: Label Analysis (Firefox, Safari)
|
||||
const trackLabel = mediaStreamTrack.label.toLowerCase()
|
||||
const fullScreenIndicators = [
|
||||
'monitor',
|
||||
'screen',
|
||||
'display',
|
||||
'entire screen',
|
||||
'full screen',
|
||||
]
|
||||
return fullScreenIndicators.some((indicator) =>
|
||||
trackLabel.includes(indicator)
|
||||
)
|
||||
}, [trackReference])
|
||||
|
||||
const shouldShowWarning =
|
||||
screenSharePreferences.enabled && isFullScreenCapture
|
||||
screenSharePreferences.enabled && isFullScreenSharing
|
||||
|
||||
const handleStopScreenShare = async () => {
|
||||
if (!localParticipant.isScreenShareEnabled) return
|
||||
|
||||
@@ -200,7 +200,7 @@
|
||||
"fullScreen": "Full screen"
|
||||
},
|
||||
"fullScreenWarning": {
|
||||
"message": "To avoid infinite loop display, do not share your entire screen or browser window. Instead, share a tab or another window.",
|
||||
"message": "To avoid infinite loop display, do not share your entire screen. Instead, share a tab or another window.",
|
||||
"stop": "Stop presenting",
|
||||
"ignore": "Ignore"
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@
|
||||
"fullScreen": "Plein écran"
|
||||
},
|
||||
"fullScreenWarning": {
|
||||
"message": "Pour éviter l'affichage en boucle infinie, ne partagez pas l'intégralité de votre écran ni de votre fenêtre de navigateur. Partagez plutôt un onglet ou une autre fenêtre.",
|
||||
"message": "Pour éviter l'affichage en boucle infinie, ne partagez pas l'intégralité de votre écran. Partagez plutôt un onglet ou une autre fenêtre.",
|
||||
"stop": "Arrêter la présentation",
|
||||
"ignore": "Ignorer"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user