我看到的MediaElement接口公开属性,如paused,seeking和ended.但是,从列表中遗漏的是playing.
我知道有playing事件,当元素火开始播放,和timeupdate赛事活动定期一边玩,但是我正在寻找一种方法来确定视频是否正在播放现在.有没有一种简单的方法来确定这个?
我最接近的是:
!(video.paused || video.ended || video.seeking || video.readyState < video.HAVE_FUTURE_DATA)
Run Code Online (Sandbox Code Playgroud) 动态更改视频时,我在服务器控制台下收到以下错误
(index):71 Uncaught (in promise) DOMException: The play() request was interrupted by a new load request.
Run Code Online (Sandbox Code Playgroud)
我发生更改时使用以下代码
function playlocalVID()
{
var player = document.getElementById("video");
var currentVID = document.getElementById('currentVID');
var selectedLocalVID = document.getElementById('howtovideo').files[0];
currentVID.setAttribute('src', URL.createObjectURL(new Blob([selectedLocalVID])));
player.load();
player.play();
}
Run Code Online (Sandbox Code Playgroud)
但是当改变视频3 - 4次或点击删除按钮
我收到了这个问题
Uncaught (in promise) DOMException: The play() request was interrupted by a new load request.
Run Code Online (Sandbox Code Playgroud)
这是我的小提琴
https://jsfiddle.net/q3hhk17e/36/
能告诉我如何解决这个问题吗?
我希望能够在视频到达某些指定帧时稳健地停止视频,以便根据使用 Blender、Manim 制作的视频进行口头演示...
我知道这个问题,但问题是视频没有完全停在好帧处。有时它会继续前进一帧,当我强制它返回到初始帧时,我们会看到视频向后退,这很奇怪。更糟糕的是,如果下一帧完全不同(不同的背景......),这将非常明显。
为了说明我的问题,我在这里创建了一个演示项目(只需单击“下一步”即可看到当视频停止时,有时会倒退)。完整的代码在这里。
我正在使用的代码的重要部分是:
var video = VideoFrame({
id: 'video',
frameRate: 24,
callback: function(curr_frame) {
// Stops the video when arriving on a frames to stop at.
if (stopFrames.includes(curr_frame)) {
console.log("Automatic stop: found stop frame.");
pauseMyVideo();
// Ensure we are on the proper frame.
video.seekTo({frame: curr_frame});
}
}
});
Run Code Online (Sandbox Code Playgroud)
到目前为止,我通过在结束前停止一帧然后使用seekTo(不确定这听起来如何)来避免这个问题,如此处所示。但正如您所看到的,有时当进入下一帧时,它会有点“冻结”:我想这是在seekTo.
PS:如果你知道 JS 中一种可靠的方法来了解给定视频的帧数,我也很感兴趣。
关于在桌面上预先剪切视频的想法,可以使用......但我过去在这方面有过不好的经验,特别是更改视频有时会产生一些故障。此外,它的使用可能会更复杂,这意味着视频应该手动剪切很多时间,重新编码......
编辑是否有任何解决方案,例如基于WebAssembly(与旧浏览器更兼容)或Webcodec(更高效,但尚未广泛传播)?Webcodec 似乎允许非常令人惊奇的事情,但我不知道如何使用它们。我很想听到基于它们的解决方案,因为 Firefox 尚不处理 webcodec。请注意,如果在此过程中音频不会丢失,那就太好了。如果我还可以根据要求显示控件,那就太好了。
编辑:我不确定这里发生了什么( …
我需要一个可以从第三方网站流式传输音频的功能.
假设.
调节器
function getStreamAudio($id){
$audioDetails = Audio::find($id); //Get audio details
$audio_full_url = $audioDetails->audio_path; //www.otherdomain.com/abc/xyz.mp3
//here i need to strem audio through id
}
Run Code Online (Sandbox Code Playgroud)
我有与HTML下面相同的播放列表
<audio src="www.mydomain.com/stream_audio/1"></audio> // src tags are excute the above function
<audio src="www.mydomain.com/stream_audio/2"></audio> // src tags are excute the above function
<audio src="www.mydomain.com/stream_audio/3"></audio> // src tags are excute the above function
Run Code Online (Sandbox Code Playgroud)
我有一个播放音频的播放列表.但目的是保护音频原始URL路径.
我试过Defa Protector来加密音频的URL.以下是网址
https://sites.google.com/site/defaprotectorhelp/
它正在工作,但是当我在播放列表中添加4首或更多歌曲时.它显示我的错误.
未捕获(在promise中)DOMException:play()请求被pause()调用中断.
对于此错误,还尝试了此stackoverflow解决方案.但仍然错误是一样的.
当我使用原始音频路径时.它工作得很好.