- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有视频的自定义控件。
太棒了。它工作得比较好。但是,我错过了一个功能。当视频暂停并且我在搜索栏上拖动 slider 时,视频帧不会实时更新,只有在您“放下” slider (鼠标按下)之后。
如你所见here ,使用 native html5 视频功能,它是这样完成的:当您拖动栏时,视频会更新到光标所在的当前帧。对我来说,这非常重要。
那么,我该如何实现呢?问题在于 .addEventListener("change") 的性质,不是吗?
<div class="row">
<div class="col-sm-4" id="video-container">
<!-- Video -->
<video id="video" muted>
<source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
<p>
Your browser doesn't support HTML5 video.
</p>
</video>
<!-- Video Controls -->
<div id="video-controls">
<button type="button" id="play-pause" class="play"><img src="https://storage.googleapis.com/material-icons/external-assets/v4/icons/svg/ic_play_arrow_white_24px.svg"></button>
<input type="range" id="seek-bar" value="0">
<button type="button" id="full-screen"><img src=https://storage.googleapis.com/material-icons/external-assets/v4/icons/svg/ic_fullscreen_white_24px.svg></button>
</div>
</div>
</div>
<script type="text/javascript">
window.onload = function() {
// Video
var video = document.getElementById("video");
// Buttons
var playButton = document.getElementById("play-pause");
var fullScreenButton = document.getElementById("full-screen");
// Sliders
var seekBar = document.getElementById("seek-bar");
// Event listener for the play/pause button
playButton.addEventListener("click", function() {
if (video.paused == true) {
// Play the video
video.play();
// Update the button text to 'Pause'
$('img', playButton).attr("src","https://storage.googleapis.com/material-icons/external-assets/v4/icons/svg/ic_pause_white_24px.svg");
} else {
// Pause the video
video.pause();
// Update the button text to 'Play'
$('img', playButton).attr("src","https://storage.googleapis.com/material-icons/external-assets/v4/icons/svg/ic_play_arrow_white_24px.svg");
}
});
// Event listener for the full-screen button
fullScreenButton.addEventListener("click", function() {
if (video.requestFullscreen) {
video.requestFullscreen();
} else if (video.mozRequestFullScreen) {
video.mozRequestFullScreen(); // Firefox
} else if (video.webkitRequestFullscreen) {
video.webkitRequestFullscreen(); // Chrome and Safari
}
});
// Event listener for the seek bar
seekBar.addEventListener("change", function() {
// Calculate the new time
var time = video.duration * (seekBar.value / 100);
// Update the video time
video.currentTime = time;
});
// Update the seek bar as the video plays
video.addEventListener("timeupdate", function() {
// Calculate the slider value
var value = (100 / video.duration) * video.currentTime;
// Update the slider value
seekBar.value = value;
});
// Pause the video when the seek handle is being dragged
seekBar.addEventListener("mousedown", function() {
video.pause();
});
$('#video-controls').width($('video').width());
$('#seek-bar').width($('video').width() -105);
}
</script>
最佳答案
我通过将 .addEventListener("change") 更改为 .addEventListener("input") 来完成它,但也许这个问题可能对某人有帮助,所以我没有删除它。
关于javascript - HTML5 视频自定义控件 : How to show the current frame of the video while dragging the seekbar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44875941/
我正在尝试使Polymer Dart元素可拖动,并与列表中的另一个项目交换信息。我最近的尝试是使用元素。我正在使用由trackstart,track和trackend的此元素创建的事件。我可以触发它们
我正在使用 Windows 窗体在 C# 中构建桌面应用程序。我有一个自定义控件,我希望能够将它拖放到我的应用程序中(而不是外部)。现在我正在使用通常的 DoDragDrop/OnDragOver/O
我有一个#topleft红色标题栏,其中包含多个“选项卡”按钮,这些按钮应填充除#topright蓝色块之外的所有可用空间。 在#topleft的红色背景上单击并拖动,可以移动 Electron 主窗
我希望能够移动(在灰色背景上,通过拖放)Bootstrap 2 提供的模态表单。谁能告诉我实现此目的的最佳实践是什么? 最佳答案 默认情况下, Bootstrap 不附带任何拖放功能,但您可以添加一些
我只想在屏幕上拖动小部件,而不是拖放。 但是,每当我离开它并再次开始拖动时,它就会从开始的位置开始被拖动。就好像它被重置了。 我的猜测是构建被一次又一次地调用,所以它自动使用原始位置值。我该如何解决?
我只想在屏幕上拖动小部件,而不是拖放。 但是,每当我离开它并再次开始拖动时,它就会从开始的位置开始被拖动。就好像它被重置了。 我的猜测是构建被一次又一次地调用,所以它自动使用原始位置值。我该如何解决?
我试图在拖放过程中更改节点上的光标,但图像没有改变。我打电话 setCursor()在 DragDetectedEventHandler我的节点。我也试过调用 getParent().setCurso
这个问题已经有答案了: D3.js: Remove force.drag from a selection (3 个回答) 已关闭 7 年前。 我将以下内容附加到 svg 元素 var dragger
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
使用 jsTree 3.0.8 我想允许在树中拖放节点,但它应该只允许通过拖动特定按钮或“拖动 handle ”而不是默认的操作来启动该操作允许拖动行上任意位置的行为。 我通过 Html 填充我的树,
当元素开始被拖动时,我需要修改它。 “开始”回调有两个参数,只有第一个参数对我有用。交易是我正在使用 helper: 'clone' 这使得 event.originalTarget 仅指向“原始”元
我有一个可拖动的 img 元素。现在我想手动触发 drag() 事件,就像我们如何触发 'click' 事件一样 $(element).trigger('click')。谢谢。 这是我的函数定义 $(
这是我的 jsfiddle 代码: http://jsfiddle.net/SMqR9/16/ 您会注意到,在 IE7 中,当您向上拖动一个元素时,它在放置之前一直可见。但是,如果您向下拖动一个元素,
我是 knockout JavaScript 的新手。在我的元素中,我使用了 Knockout 拖放功能。最初我有两个部门,一个是可见的,另一个没有属性显示。当我执行拖动输入功能时,我需要隐藏第一个分
上下文:如下面jsp内输入框中的代码所示,要拖放“fruitTree”中的水果节点。 这在拖放时成功发生。每次我从fruitTree中拖放水果时,先前拖放的水果节点都会被新拖放的水果覆盖。 问题:现在
我想移动一定距离。但是,在我的系统中,存在惯性/拖动/负加速度。我正在使用这样的简单计算: v = oldV + ((targetV - oldV) * inertia) 将其应用于多个帧会使运动“上
我正在使用 Kendo Grid UI。下面是一个相同的例子。 Grid / Column resizing
我有这个页面,我只能在浏览器中访问。有一个HTML元素仅在拖放过程中存在,并且我想在Inspector / Firebug中获取/分析其HTML代码。但是一旦我停止拖动,该元素就会被删除。 有什么方法
这真杀了我。我不小心将文件拖到其他位置时遇到问题。与其他编辑器相比,在vscode中,我似乎更经常为此受害。是否有任何插件,设置或其他使我无法使用鼠标技能的东西? 最佳答案 我有同样的问题。当文件夹意
//The following game has been designed as an educational resource //for Key Stage 1 and 2 children.
我是一名优秀的程序员,十分优秀!