【发布时间】:2021-10-14 03:45:14
【问题描述】:
我尝试在 html video 标签中播放本地视频文件,我使用打开对话框来选择文件并获取文件的路径。然后我把这条路径放在src中
export default function VideoContainer() {
const { videoUrl } = useTypeSelector(state => state.video);
console.log(videoUrl);
return (
<div className='VideoContainer'>
{videoUrl !== '' && (
<video className='VideoContainer__video' controls>
<source src={`custom-protocol://${videoUrl}`} type={`video/mp4`} />
</video>
)}
</div>
);
}
对于西里尔文文件,它不起作用。 error with cyrillic
我该如何解决这个问题?
我使用 Electron.js、React.js、Redux。
这是我尝试过的:
export default function VideoContainer() {
const { videoUrl } = useTypeSelector(state => state.video);
const newStr = decodeURI(videoUrl);
console.log(newStr);
return (
<div className='VideoContainer'>
{videoUrl !== '' && (
<video className='VideoContainer__video' controls>
<source src={`custom-protocol://${newStr}`} type={`video/mp4`} />
</video>
)}
</div>
);
}
但同样的error。
【问题讨论】:
-
欢迎来到 Stack Overflow!请务必使用tour 并阅读How to Ask,因为它可以帮助您发布对您和社区都产生有利结果的帖子。另外,Please do not upload images of code/errors when asking a question.
标签: javascript html reactjs url html5-video