我正在嘗試為視頻標簽撰寫自定義全屏按鈕。
這是我的代碼:
const onClickVideoHandler = useCallback(() => {
console.log(videoRef.current?.webkitRequestFullscreen); // always undefined in ios webview
if (videoRef.current?.requestFullscreen) {
videoRef.current?.requestFullscreen();
} else if (videoRef.current?.msRequestFullscreen) {
videoRef.current?.msRequestFullscreen();
} else if (videoRef.current?.mozRequestFullScreen) {
videoRef.current?.mozRequestFullScreen();
} else if (videoRef.current?.webkitRequestFullscreen) {
videoRef.current?.webkitRequestFullscreen();
}
}, [videoRef.current]);
<VideoWrapper onClick={onClickVideoHandler}>
<video ref={videoRef} src={videoLink} muted={muted} controls={false} playsInline autoPlay loop onError={onErrorHandler} />
</VideoWrapper>
當我單擊 VideoWrapper 時,我希望視頻以全屏模式打開
我嘗試呼叫 webkitRequestFullscreen(),但此方法在 ios webview 中始終未定義(以及 mozRequestFullScreen、mozRequestFullScreen、msRequestFullscreen、requestFullscreen)
ios webview中有全屏模式的方法嗎?
uj5u.com熱心網友回復:
不幸requestFullscreen的是,iPad 僅部分支持,但 iPhone 不支持。可以在此處找到有關此 API 可用性的更多資訊:https ://caniuse.com/?search=requestFullscreen
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/525803.html
