我在html5视频标签上有这种奇怪的行为.我有4个视频,我想同时播放.所以我创建了自己的控制栏来播放/暂停,所以当点击播放按钮时,播放所有4个视频,与暂停按钮相同.
在野生动物园,它有奇怪的问题,视频没有同时播放,当我点击播放时,1或2个视频有延迟,所以不是所有视频同时播放.
在Chrome和Firefox上,它的工作正常,safari有什么问题?
我正在使用javascript .play()函数播放所有视频.
我还确保在播放视频之前加载视频.就像是,
<video id="example_video_1" class="video-js vjs-default-skin" preload="auto">
<source src="asset/video/al_vertrag_kranken_v1_part1.ogv" type='video/ogg' />
<source src="asset/video/al_vertrag_kranken_v1_part1.mp4" type='video/mp4' />
<source src="asset/video/al_vertrag_kranken_v1_part1.webm" type='video/webm' />
</video>
video_1 = document.getElementById('example_video_1');
if (video_1.readyState == 4 && video_2.readyState == 4 && video_3.readyState == 4 && video_4.readyState == 4) {
video_1.play();
video_2.play();
video_3.play();
}
Run Code Online (Sandbox Code Playgroud)
还有3个像这样的视频标签,1只是一个例子.
我的index.js文件是
var express = require('express');
var app = express();
var path = require('path');
var router = express.Router();
var data = require('./data/jsonData');
var createDatabase = require('./data/db');
var careateTable = require('./data/createTable');
var insert = require('./data/insert');
var bodyParser = require('body-parser');
var select = require('./data/select');
app.use(express.static(path.join(__dirname, 'www')));
app.use(express.static(path.join(__dirname, 'form')));
app.use(bodyParser());
app.get('/' , function (req , res) {
res.sendFile(path.join(__dirname + '/www/index.html'));
});
app.get('/data' ,function (req , res) {
res.json(data);
});
app.get('/form' ,function (req , res) {
res.sendFile(path.join(__dirname + '/form/index.html'));
});
app.post('/form' ,function (req , res) …Run Code Online (Sandbox Code Playgroud) 我有一小段使用setInterval方法的代码:
function MyController($scope) {
$scope.clock = new Date();
var updateClock = function() {
$scope.clock = new Date();
};
setInterval(updateClock, 1000);
};
Run Code Online (Sandbox Code Playgroud)
和html如下:
<!doctype html>
<html ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular.js"></script>
</head>
<body>
<div ng-controller="MyController">
<h1>Hello {{ clock }}!</h1>
</div>
<script type="text/javascript" src="script.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
但是,setInterval在MyController不更新时间.哪里可能有问题?
它按照这本书的方式工作:
function MyController($scope) {
$scope.clock = new Date();
var updateClock = function() {
$scope.clock = new Date();
};
setInterval(function() {
$scope.$apply(updateClock);
}, 1000);
updateClock();
};
Run Code Online (Sandbox Code Playgroud)
如果没有使用@ scope,为什么会出现问题?$ apply?
我已通过 Node Express 中的 API 将 Base64 img 字符串上传到 Google Drive。上传图片后,在云端硬盘中无法查看该图片。我不确定如何解决此格式问题。我知道我可以先在本地保存 img,然后上传保存的 img 文件,但我希望有一种更简单的方法。
我的代码:
const uploadImg = async (folderId,img)=>{
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0
const scopes = [
'https://www.googleapis.com/auth/drive'
];
const auth = new google.auth.JWT(
demoApiCreds.client_email, null,
demoApiCreds.private_key, scopes
);
const drive = google.drive({ version: 'v3', auth });
const fileMetadata = {
'name': 'Client_Design_ScreenShotTest',
'mimeType':'image/jpeg',
'parents':[folderId]
};
const uploadImg = img.split(/,(.+)/)[1];
const media = {
body: uploadImg
}
let res = await drive.files.create({
resource: fileMetadata,
media: media,
fields: 'id',
});
console.log('the …Run Code Online (Sandbox Code Playgroud) 我收到一个包含大量信息的JSON,但我想删除一个特定的数据,例如,如果我收到变量名,我想在我的数据库中添加我的JSON之前删除这个变量.这是我的功能POST:
app.post("/:coleccion", function (req, res, next) {
POST
if(req.body.name)
// Here I need delete "name" if I receive this variable <------
req.collection.insert(req.body, {}, function (e, result) {
if(e) return next(e);
res.send(result);
});
});
Run Code Online (Sandbox Code Playgroud) javascript ×3
node.js ×3
angularjs ×1
express ×1
file-upload ×1
html ×1
html5 ×1
html5-video ×1
json ×1
mysql ×1
request ×1
video.js ×1