将项目放在主根目录下的文件夹中,我创建了一个简单的hello world项目。加载到chrome中的HTML文件效果很好,但是,将文件加载到主项目文件夹或子文件夹中会得到一个net :: ERR_FILE_NOT_FOUND
我希望在后台使用基本的叠加层和按钮(已经设置为可以在桌面上运行)自动播放视频。
试图将文件位置移动到主文件夹,并将目录重命名为没有空格。
也尝试使用file:///而不是通过chrome浏览器打开文件。
在Pixel 2XL上使用Android v10
<body>
<div id="mainCont">
<spread class="header">Main Test</spread><br>
<button> <a href="ALTs/L1.html">Layout 1</a></button>
</div>
<div>
<video playsinline autoplay muted loop id="bgVideo">
<source src="Link/VerticalTest.mp4" type="video/mp4">
</video>
</div>
</body>
<style>
@font-face {
font-family: Lato;
src: url(/FontRef/ProximaNova-Bold.otf) format('opentype'),
url(/FontRef/ProximaNova-Light.otf) format('opentype'),
url(/FontRef/ProximaNova-Reg.otf) format('opentype'),
url(/FontRef/ProximaNova-It.otf) format('opentype'),
url(/FontRef/ProximaNova-Sbold.otf) format('opentype'),
}
body{
text-align: center;
font-family: ProximaNova-Reg, sans-serif;
}
#bgVideo {
z-index:-1;
position: fixed;
right: 0;
top: 0;
width: 100%;
}
#mainCont{
padding: 5em;
z-index:10000;
positoin: absolute;
top:50%;
transform: translateY(100%);
}
a{
color:white;
text-decoration: none;
}
button{
padding:10px;
margin:2em;
color: #494949 !important;
text-transform: uppercase;
text-decoration: none;
background: none;
border: 1px solid white !important;
display: inline-block;
transition: all 0.4s ease 0s
}
button:hover{
color: #ffffff !important;
background: #f6b93b;
border-color: #f6b93b !important;
transition: all 0.4s ease 0s;
}
.header{
font-family: ProximaNova-Sbold, sans-serif;
font-size: calc(2.87em - 1vw);
color:white;
font-weight:400;
text-transform:uppercase;
letter-spacing:.6em;
margin-top:calc(6em - 1vw);
}
在我的Android设备上使用Chrome中的远程调试器,net :: ERR_FILE_NOT_FOUND是我收到的有关视频文件的唯一问题。出于某种原因而应用的字体没有这种错误吗?
答案 0 :(得分:0)
我一直将文件放置在android'assets'文件夹中。然后,您可以对HTML执行以下操作:
webView.loadUrl("file:///android_asset/L1.html");
或者,如果您正在引用图像或电影文件,则我使用了类似的方法:
@SuppressLint({ "SetJavaScriptEnabled", "DefaultLocale" })
private void displayDetail()
{
webView.getSettings().setJavaScriptEnabled(true);
String imageName = animalName.toLowerCase();
imageName = imageName.replaceAll(" ", "_");
imageName = imageName.replaceAll("-", "_");
imageName = imageName.replaceAll("\\(", "");
imageName = imageName.replaceAll("\\)", "");
imageName = imageName + ".jpg";
String html = "<html><body style='font-size: 18px; font-family: \"arial\";'><center><img alt='Embedded Image' src='" + imageName + "'/></center><br><div style='position: relative; margin-left: 10px; margin-right:10px;'>" + breedDetails + "</div></body></html>";
String mime = "text/html";
String encoding = "utf-8";
webView.loadDataWithBaseURL("file:///android_asset/", html, mime, encoding, null);
}
还要确保您有权读取外部存储。