Javascript 如何在各种浏览器中禁用HTML5视频播放器全屏按钮,尤其是在IE、Edge&;Firefox、Opera、Safari?
我试图通过这样做在chrome中实现这一点Javascript 如何在各种浏览器中禁用HTML5视频播放器全屏按钮,尤其是在IE、Edge&;Firefox、Opera、Safari?,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我试图通过这样做在chrome中实现这一点 video::-webkit-media-controls-fullscreen-button { display: none; } 它有时不起作用。我急需一个永久的解决办法 我请求人民: 对于SO中的任何其他人来说,这不是一个重复的问题 该解决方案不起作用,如果需要,请进行测试 这就是我再次问这个问题的原因。您可以创建自己的控件(您必须进行样式设置,但我认为这应该不是问题) HTML5: <div id="video-containe
video::-webkit-media-controls-fullscreen-button {
display: none;
}
它有时不起作用。我急需一个永久的解决办法
我请求人民:
这就是我再次问这个问题的原因。您可以创建自己的控件(您必须进行样式设置,但我认为这应该不是问题) HTML5:
<div id="video-container">
<!-- Video -->
<video id="video" width="640" height="365">
<source src="https://www.w3schools.com/htmL/mov_bbb.mp4" type="video/mp4">
<p>
Your browser doesn't support HTML5 video.
<a href="https://www.w3schools.com/htmL/mov_bbb.mp4">Download</a> the video instead.
</p>
</video>
<!-- Video Controls -->
<div id="video-controls">
<button type="button" id="play-pause">Play</button>
<input type="range" id="seek-bar" value="0">
<button type="button" id="mute">Mute</button>
<input type="range" id="volume-bar" min="0" max="1" step="0.1" value="1">
<button type="button" id="full-screen" disabled>Full-Screen</button>
</div>
</div>
可能是重复的哦。。不,亲爱的布丁。该解决方案不起作用,仅适用于chrome。你可以在否决投票前查看一下。谢谢我没有否决投票。它看起来和我一模一样,所以我给了你一个例子没关系!!如果您知道这个问题,请向我推荐任何解决方案。@DaraNaveenKumar正如您在链接问题中用户“Paulito”的回答中所看到的,除了chrome之外,其他浏览器不可能使用css。顺便说一句,我认为你不会得到比链接问题中提供的答案更好的答案。无论如何,我认为如果你想删除全屏按钮,你必须使用一个定制的视频播放器。当然,你给了我一个很好的解决方案。但我需要所有的控制(搜索,暂停,播放,静音),除了全屏。在所有浏览器中禁用全屏。@DaraNaveenKumar hmm“但我需要除全屏外的所有控件(搜索、暂停、播放、静音)。在所有浏览器中禁用全屏。”?要启用的控件:搜索、暂停、播放、静音要禁用的控件:全屏。这就是我现在想说的……我认为这是不可能的。因为标签不提供“showFullScreen=false”这样的属性,所以如果你必须使用HTML5视频标签,这是一种方法。如果你需要一个“全屏按钮”但被禁用,你可以添加这个“全屏”(我编辑了我的答案)
$( document ).ready(function() {
// Video
var video = document.getElementById("video");
// Buttons
var playButton = document.getElementById("play-pause");
var muteButton = document.getElementById("mute");
// Sliders
var seekBar = document.getElementById("seek-bar");
var volumeBar = document.getElementById("volume-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'
playButton.innerHTML = "Pause";
} else {
// Pause the video
video.pause();
// Update the button text to 'Play'
playButton.innerHTML = "Play";
}
});
// Event listener for the mute button
muteButton.addEventListener("click", function() {
if (video.muted == false) {
// Mute the video
video.muted = true;
// Update the button text
muteButton.innerHTML = "Unmute";
} else {
// Unmute the video
video.muted = false;
// Update the button text
muteButton.innerHTML = "Mute";
}
});
// 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 slider handle is being dragged
seekBar.addEventListener("mousedown", function() {
video.pause();
});
// Play the video when the slider handle is dropped
seekBar.addEventListener("mouseup", function() {
video.play();
});
// Event listener for the volume bar
volumeBar.addEventListener("change", function() {
// Update the video volume
video.volume = volumeBar.value;
});
});