【发布时间】:2021-07-12 15:50:30
【问题描述】:
我的本地 android 文件中有视频,这些视频是使用 AEC 算法加密的。是否有任何直接的方法可以在 react-native-video 中播放该视频? 我尝试将其转换为 base64 并逐片解密,但 react-native-video 不支持 base64 作为源。 我尝试在 react-native-webview 上播放它,但它不起作用。代码如下
<WebView
injectedJavaScript={debugging}
onMessage={(message) => {
console.log(message);
}}
source={{
baseUrl: '',
html: `<html>
<body>
<video width="100%" height="600" controls controlsList="nodownload" autoplay='autoplay' id='myvideo'>
<source type="video/mp4" src="data:video/mp4;base64,${videoFile}">
</video>
</body>
<script src="${RNFetchBlob.fs.dirs.MainBundleDir}/bundle.js"></script>
<script type="text/javascript">
console.log('check is check')
</script>
<script type="text/javascript">
console.log('check is check 32 and this is from the nepal')
let data = '';
RNFetchBlob.fs
.readStream('file:///' + ${allVideoFile[1].path}, 'base64', 102399, 250)
.then((stream) => {
stream.open();
stream.onData((chunk) => {
data+=chunk;
});
stream.onEnd(() => {});
}).catch(err=>{
console.log('Error is',err)
})
console.log('data is',data)
</script>
</html>`,
}}
/>
我从搜索中尝试了各种其他解决方案,但没有任何帮助。我不知道我在这里错过了什么。
【问题讨论】:
标签: react-native react-native-webview react-native-video react-native-fetch-blob