admin管理员组文章数量:1426048
I am making a web app with video playback and custom controls: a Next Video button and a Previous Video Button. My ponent looks like this:
const videos = [
'.mp4',
'.mp4',
'.mp4',
]
function App() {
const [videoIndex, setVideoIndex] = useState(0);
const h1Ref = useRef<HTMLVideoElement>(null);
return (
<div>
<DivButton onClick={() => {
setVideoIndex(getPrevIndex(videoIndex));
h1Ref.current!.load();
}}>
Prev
</DivButton>
{' '}
<DivButton onClick={() => {
setVideoIndex(getNextIndex(videoIndex));
h1Ref.current!.load();
}}>
Next
</DivButton>
<div>
<video id="video_player" autoPlay muted loop playsinline preload="" ref={h1Ref}>
<source id="video_player_source" src={videos[videoIndex]} type="video/mp4"/>
</video>
</div>
</div>
);
}
The problem is this: when I click Next or Prev buttons, the videos do switch between one another, but after every switch they are entering fullscreen mode on iOS. I don't need that, I need my controls around the video being played.
Is there a way to prevent that?
I am making a web app with video playback and custom controls: a Next Video button and a Previous Video Button. My ponent looks like this:
const videos = [
'https://d3t1nqlebka5eu.cloudfront/videos3/82818a63-1972-4e39-b296-9cd3b85b0b39.mp4',
'https://d3t1nqlebka5eu.cloudfront/videos3/dd4dd6c5-95b7-41c2-b131-7b62392ad1b5.mp4',
'https://d3t1nqlebka5eu.cloudfront/videos3/29812506-e67d-4cab-b2b3-82461a4eadf1.mp4',
]
function App() {
const [videoIndex, setVideoIndex] = useState(0);
const h1Ref = useRef<HTMLVideoElement>(null);
return (
<div>
<DivButton onClick={() => {
setVideoIndex(getPrevIndex(videoIndex));
h1Ref.current!.load();
}}>
Prev
</DivButton>
{' '}
<DivButton onClick={() => {
setVideoIndex(getNextIndex(videoIndex));
h1Ref.current!.load();
}}>
Next
</DivButton>
<div>
<video id="video_player" autoPlay muted loop playsinline preload="" ref={h1Ref}>
<source id="video_player_source" src={videos[videoIndex]} type="video/mp4"/>
</video>
</div>
</div>
);
}
The problem is this: when I click Next or Prev buttons, the videos do switch between one another, but after every switch they are entering fullscreen mode on iOS. I don't need that, I need my controls around the video being played.
Is there a way to prevent that?
Share Improve this question edited Mar 12, 2020 at 20:41 kurtgn asked Mar 12, 2020 at 20:35 kurtgnkurtgn 8,76215 gold badges61 silver badges103 bronze badges1 Answer
Reset to default 8Assuming you already found an answer but for other people looking at this in the future, I suspect the issue was your capitalization of playsinline
- in React you have to provide it as playsInline
in order for it to be applied correctly, but that prop should prevent iOS from forcing videos into fullscreen when they start playing.
本文标签: javascriptreactprevent video from going fullscreen on iOSStack Overflow
版权声明:本文标题:javascript - react - prevent video from going fullscreen on iOS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745463489a2659428.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论