英文:
Video is not playing automatically in React JS
问题
嗨,我想要在没有控件的情况下自动播放视频,因为我将其用作网站横幅背景。请指出我做错了什么。我正在使用Chrome浏览器。
``` HTML
<video
autoPlay
// playsinline
autoplay
muted
loop
className="stakingNft"
>
<source src="\assets\video\landing.mp4" type="video/mp4" />
</video>
<video
autoPlay
playsinline
autoplay
muted
loop
className="stakingNft"
>
<source src="\assets\video\landing.mp4" type="video/mp4" />
</video>
<details>
<summary>英文:</summary>
Hy, I want to play videos automatically without controls. because I'm using it as a website banner background. Please point out what I have done wrong. I'm using chrome browser.
<video
autoPlay
// playsinline
autoplay
muted
loop
className="stakingNft"
>
<source src="\assets\video\landing.mp4" type="video/mp4" />
</video>
<video
autoPlay
playsinline
autoplay
muted
loop
className="stakingNft"
>
<source src="\assets\video\landing.mp4" type="video/mp4" />
</video>
</details>
# 答案1
**得分**: 0
看起来视频路径有问题。
你使用了反斜杠而不是正斜杠。
参考链接:https://stackblitz.com/edit/react-xbfng5?file=src%2FApp.js
<details>
<summary>英文:</summary>
Looks like there's issue in path of video.
You used backward slash instead of forward slash.
Here is the reference: https://stackblitz.com/edit/react-xbfng5?file=src%2FApp.js
----------
</details>
# 答案2
**得分**: 0
以下是翻译好的内容:
这里是[CodeSandbox][1]。
autoPlay可能被定义了两次,而且用小写字母,我认为这可能是原因。
[1]: https://codesandbox.io/s/peaceful-archimedes-imdure?file=/src/App.js
<details>
<summary>英文:</summary>
Here is the [codesandbox][1]
autoPlay might be defined twice and in small case that's the reason I think.
[1]: https://codesandbox.io/s/peaceful-archimedes-imdure?file=/src/App.js
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论