我正在尝试在基于浏览器的游戏中播放车辆驱动的声音(连续不间断)。
我的 .wav 文件长度为 1 秒,并且从头到尾具有相同的频率。但是在下一次迭代之前,声音需要休息一下。
这是代码:
function playSound()
{
//alert("");
myAudio = new Audio('http://ithmbwp.com/feedback/SoundsTest/sounds/tank_driven.wav');
if (typeof myAudio.loop == 'boolean')
{
myAudio.loop = true;
}
else
{
myAudio.addEventListener('ended', function() {
this.currentTime = 0;
this.play();
}, false);
}
myAudio.volume = 0.3;
myAudio.play();
}
Run Code Online (Sandbox Code Playgroud)
谁能帮我连续播放声音?
function playSound()
{
//alert("");
myAudio = new Audio('http://ithmbwp.com/feedback/SoundsTest/sounds/tank_driven.wav');
if (typeof myAudio.loop == 'boolean')
{
myAudio.loop = true;
}
else
{
myAudio.addEventListener('ended', function() {
this.currentTime = 0;
this.play();
}, false);
}
myAudio.volume = 0.3; …Run Code Online (Sandbox Code Playgroud)我创建了一个100%(浏览器)宽度的HTML页面,其中包含大量内容.内容在页面中固定,这些大小都以像素和百分比表示.
现在我需要添加20%浏览器宽度的广告面板.并且想要将页面容器及其所有内容(包括文本)缩放到80%(就像在所有Web浏览器中可用的缩放,但它应该是内部缩放).
不幸的是,我的页面没有响应,我不想重新开发它或从头开始调整其所有内容.
HTML中是否有可用的缩放功能?
我在JavaScript中有以下AudioContext()声音对象。
其体积为100%。我想以10%的音量播放(音量= 0.1)。
如何将其音量减小到10%?
const aCtx = new AudioContext();
let source = aCtx.createBufferSource();
let buf;
fetch('https://dl.dropboxusercontent.com/s/knpo4d2yooe2u4h/tank_driven.wav') // can be XHR as well
.then(resp => resp.arrayBuffer())
.then(buf => aCtx.decodeAudioData(buf)) // can be callback as well
.then(decoded => {
source.buffer = buf = decoded;
source.loop = true;
source.connect(aCtx.destination);
check.disabled = false;
});
check.onchange = e => {
if (check.checked) {
source.start(0); // start our bufferSource
} else {
source.stop(0); // this destroys the buffer source
source = aCtx.createBufferSource(); // so we need …Run Code Online (Sandbox Code Playgroud)我想沿着角度以度为单位的直线将点转换为特定距离。
var initialPoint = [0,0]; //Starting Point
var distance = 100; //Distance in pixels to be translated
var degree = 45; //Direction of move
var translatedPoint = moveByDegree(initialPoint, degree, distance);
function moveByDegree(initialPoint, degree, distance)
{
//formula to generate translatedPoint by degree & distance
// . . .
return translatedPoint;
}
Run Code Online (Sandbox Code Playgroud)
给我简单的算法或JavaScript代码。
我试图在梯形形状的div内设置一个div.
但无论如何,内在的div是无形的.
我也试过z-indexes.
.trapezoid
{
border-color: transparent transparent rgba(255,0,0,0.2) transparent;
border-width: 0px 10px 38px 10px;
border-style: solid;
height: 0;
width: 40px;
background-size: 430px;
overflow: hidden;
background-repeat: no-repeat;
display: block;
text-indent: -99999px;
margin-top: 25px;
margin-bottom: 25px;
margin-left: 25px;
margin-right: 25px;
cursor: pointer;
}
.innerIcon
{
width: 100%;
height: 38px;
border-radius: 16px;
background-color: rgba(0,0,0,0.4);
}Run Code Online (Sandbox Code Playgroud)
<div class="trapezoid" title="Fire Range Down">
<!-- This inner div is invisible -->
<div class="innerIcon"></div>
</div>Run Code Online (Sandbox Code Playgroud)
请给我一些解决方案.
javascript ×4
html ×3
audio ×2
css ×2
html5 ×2
audiobuffer ×1
css3 ×1
geometry ×1
html5-audio ×1
jquery ×1
math ×1
trigonometry ×1