2 回答
TA贡献1831条经验 获得超10个赞
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>CadenceVR.com BTLE example</title>
<link href="https://vjs.zencdn.net/7.6.5/video-js.css" rel="stylesheet">
<link rel="icon" sizes="192x192" href="../favicon.png">
<script>window.HELP_IMPROVE_VIDEOJS = false;</script>
<script type="text/javascript" src='https://vjs.zencdn.net/7.6.5/video.js'></script>
<script type="text/javascript" src="heartRateSensor.js"></script>
<script type="text/javascript" src="cyclingSpeedCadence.js"></script>
<script type="text/javascript" src="core.js"></script>
</head>
<body>
<div id="container">
<div id="statusText">Heart : 0 BPM ❤</div>
<div id="SpeedText">Speed : 0,0 KM/H</div>
<div id="CadenceText">Cadence : 0 RPM</div>
<label for="name">Speedrate between 1 and 4:</label>
<input type="text" id="speedrate" name="speedrate" required minlength="1" maxlength="1" size="2">
<button type="button" name="BTLEbutton1" value="BTLEClick1" onclick="onButtonClickSetVideoRate();">Set Video speed rate</button>
<button type="button" name="BTLEbutton2" value="BTLEClick2" onclick="onButtonClickHart();">Discover Heart Devices</button>
<button type="button" name="BTLEbutton3" value="BTLEClick3" onclick="onButtonClickCSC();">Discover S_C Devices</button>
</div>
<video id='cvrvideo' class='video-js' controls preload="auto"
poster='My-jpg' height="320" width="640" data-setup='{}'>
<source src='My-mp4' type='video/mp4'>
<p class='vjs-no-js'>
To view this video please enable JavaScript, and consider upgrading to a web browser that
<a href='https://videojs.com/html5-video-support/' target='_blank'>supports HTML5 video</a>
</p>
</video>
<script>
videojs('cvrvideo').ready(function(){
// Store the video object
var myPlayer = this, id = myPlayer.id();
// Make up an aspect ratio
var aspectRatio = 264/640;
function resizeVideoJS(){
var width = document.getElementById(id).parentElement.offsetWidth;
myPlayer.width(width);
myPlayer.height(width * aspectRatio);
}
// Initialize resizeVideoJS()
resizeVideoJS();
// Then on resize call resizeVideoJS()
window.onresize = resizeVideoJS;
});
</script>
</body>
</html>
TA贡献1865条经验 获得超7个赞
两种情况:
在您设置 PlayRate 之前,视频 Js 对象尚未初始化。在这种情况下,您应该在 body 标记之后移动导入脚本
你只想使用Video Js Object,你可以使用全局有价值的。
在 index.html 中
window['videojsPlayer'] = new videojsPlayer();
在另一个文件中。
window['videojsPlayer'].setPlayrate()
添加回答
举报