mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-19 19:51:20 -08:00
use async/await
This commit is contained in:
1 parent
facf8876b5
commit
e34d09a99c
9 files changed
+86
-102
No files matched your search
@@ -40,7 +40,7 @@ export default function autoOrientation(art) {
|
||||
}
|
||||
});
|
||||
|
||||
art.on('fullscreen', (state) => {
|
||||
art.on('fullscreen', async (state) => {
|
||||
const lastOrientation = screen.orientation.type;
|
||||
if (state) {
|
||||
const { videoWidth, videoHeight } = $video;
|
||||
@@ -50,15 +50,13 @@ export default function autoOrientation(art) {
|
||||
(videoWidth < videoHeight && viewWidth > viewHeight)
|
||||
) {
|
||||
const oppositeOrientation = lastOrientation.startsWith('portrait') ? 'landscape' : 'portrait';
|
||||
screen.orientation.lock(oppositeOrientation).then(() => {
|
||||
addClass($player, 'art-auto-orientation-fullscreen');
|
||||
});
|
||||
await screen.orientation.lock(oppositeOrientation);
|
||||
addClass($player, 'art-auto-orientation-fullscreen');
|
||||
}
|
||||
} else {
|
||||
if (hasClass($player, 'art-auto-orientation-fullscreen')) {
|
||||
screen.orientation.lock(lastOrientation).then(() => {
|
||||
removeClass($player, 'art-auto-orientation-fullscreen');
|
||||
});
|
||||
await screen.orientation.lock(lastOrientation);
|
||||
removeClass($player, 'art-auto-orientation-fullscreen');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user