Guard unsupported web orientation methods
This commit is contained in:
@@ -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.
|
||||||
|
|||||||
Reference in New Issue
Block a user