-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(frontend): 動画UIのフルスクリーン周りの調整 (#14877)
* refactor(frontend): フルスクリーン周りの調整 (cherry picked from commit 783032c) * refactor(frontend): deviceKindの循環参照を除去 (cherry picked from commit 1ca471f) * fix --------- Co-authored-by: taiyme <[email protected]>
- Loading branch information
1 parent
a4c5ce1
commit 3a42183
Showing
5 changed files
with
88 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* SPDX-FileCopyrightText: syuilo and misskey-project | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
type PartiallyPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>; | ||
|
||
type VideoEl = PartiallyPartial<HTMLVideoElement, 'requestFullscreen'> & { | ||
webkitEnterFullscreen?(): void; | ||
webkitExitFullscreen?(): void; | ||
}; | ||
|
||
type PlayerEl = PartiallyPartial<HTMLElement, 'requestFullscreen'>; | ||
|
||
type RequestFullscreenProps = { | ||
readonly videoEl: VideoEl; | ||
readonly playerEl: PlayerEl; | ||
readonly options?: FullscreenOptions | null; | ||
}; | ||
|
||
type ExitFullscreenProps = { | ||
readonly videoEl: VideoEl; | ||
}; | ||
|
||
export const requestFullscreen = ({ videoEl, playerEl, options }: RequestFullscreenProps) => { | ||
if (playerEl.requestFullscreen != null) { | ||
playerEl.requestFullscreen(options ?? undefined); | ||
return; | ||
} | ||
if (videoEl.webkitEnterFullscreen != null) { | ||
videoEl.webkitEnterFullscreen(); | ||
return; | ||
} | ||
}; | ||
|
||
export const exitFullscreen = ({ videoEl }: ExitFullscreenProps) => { | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
if (document.exitFullscreen != null) { | ||
document.exitFullscreen(); | ||
return; | ||
} | ||
if (videoEl.webkitExitFullscreen != null) { | ||
videoEl.webkitExitFullscreen(); | ||
return; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters