Guard unsupported web orientation methods

This commit is contained in:
2026-08-12 14:15:50 -07:00
parent 42608bd8d1
commit a1579eebad

View File

@@ -139,15 +139,19 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
navigationUI: 'hide', navigationUI: 'hide',
}); });
if (orientation === 'all' || !orientation || autorotate) { if (orientation === 'all' || !orientation || autorotate) {
screen.orientation.unlock(); if (typeof screen.orientation?.unlock === 'function') {
} else { screen.orientation.unlock();
}
} else if (typeof screen.orientation?.lock === 'function') {
await screen.orientation.lock(orientation); await screen.orientation.lock(orientation);
} }
} else { } else {
if (document.fullscreenElement) { if (document.fullscreenElement) {
await document.exitFullscreen(); await document.exitFullscreen();
} }
screen.orientation.unlock(); if (typeof screen.orientation?.unlock === 'function') {
screen.orientation.unlock();
}
} }
} catch (e) { } catch (e) {
// Changing fullscreen status without a button click is not allowed so it throws. // Changing fullscreen status without a button click is not allowed so it throws.