我有一个包含剪辑和图像的数组。此代码显示剪辑和图像,但当我有2个以上的剪辑时,智能tivi的浏览器无法显示视频(在PC的浏览器上显示正常)。请帮我展示智能tivi浏览器的错误。以下是 index.html 文件
<!DOCTYPE html>
<html>
<header>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Video</title>
<link href="./css/style.css" media="screen" rel="stylesheet" type="text/css">
<script type="text/javascript" src="jquery/jquery.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</header>
<body>
<div style="text-align:center">
<br><br>
<div class="fullscreen-bg" id="slideshow">
</div>
</div>
</body>
</html>
这里是 index.js 文件。当我在PC的网络浏览器中运行网站时,没关系,但是当我在智能tivi的浏览器上运行网络时,它有错误但我无法显示。如果在PC上,我可以打开浏览器或Android手机上的检查,我可以设置显示错误。请帮助我显示来自smart tivi的错误:
var myVideo = document.getElementById("video1");
var video_list = ["file_upload/mov_bbb.mp4", "file_upload/Jellyfish.jpg", "file_upload/Lighthouse.jpg","file_upload/(1).mp4"];
function img(src) {
var el = document.createElement('img');
el.src = src;
// el.className += "fullscreen-bg__video";
el.style.width = "100%";
el.style.height = "100%";
return el;
}
function vid() {
//Accepts any number of ‘src‘ to a same video ('.mp4', '.ogg' or '.webm')
var el = document.createElement('video');
el.onplay = function () {
clearInterval(sliding);
};
el.onended = function () {
sliding = setInterval(rotateimages, 5000);
rotateimages();
};
var source = document.createElement('source');
for (var i = 0; i < arguments.length; i++) {
source.src = arguments[i];
source.type = "video/" + arguments[i].split('.')[arguments[i].split('.').length - 1];
el.appendChild(source);
}
el.className += "fullscreen-bg__video";
return el;
}
var galleryarray = [];
video_list.forEach(function(item){
if(isImage(item)){
galleryarray.push(img(item));
} else if(isVideo(item)){
galleryarray.push(vid(item));
}
});
var curimg = -1;
function rotateimages() {
$("#slideshow").fadeOut("slow");
setTimeout(function () {
curimg = (curimg < galleryarray.length - 1) ? curimg + 1 : 0;
document.getElementById('slideshow').innerHTML = '';
document.getElementById('slideshow').appendChild(galleryarray[curimg]);
if (galleryarray[curimg].tagName === "VIDEO") {
galleryarray[curimg].play();
}
$("#slideshow").fadeIn("slow");
}, 1000);
}
function getExtension(filename) {
var parts = filename.split('.');
return parts[parts.length - 1];
}
function isImage(filename) {
var ext = getExtension(filename);
switch (ext.toLowerCase()) {
case 'jpg':
case 'gif':
case 'bmp':
case 'png':
//etc
return true;
}
return false;
}
function isVideo(filename) {
var ext = getExtension(filename);
switch (ext.toLowerCase()) {
case 'm4v':
case 'avi':
case 'mpg':
case 'mp4':
// etc
return true;
}
return false;
}
var sliding;
window.onload = function () {
sliding = setInterval(rotateimages, 5000);
rotateimages();
function getExtension(filename) {
var parts = filename.split('.');
return parts[parts.length - 1];
}
function isImage(filename) {
var ext = getExtension(filename);
switch (ext.toLowerCase()) {
case 'jpg':
case 'gif':
case 'bmp':
case 'png':
//etc
return true;
}
return false;
}
function isVideo(filename) {
var ext = getExtension(filename);
switch (ext.toLowerCase()) {
case 'm4v':
case 'avi':
case 'mpg':
case 'mp4':
// etc
return true;
}
return false;
}
}