由于我的视频处于全屏状态,所以我想在按ESC键或退出视频后删除视频的声音。
**问题**:在我按ESC键或全屏退出视频后,声音仍然持续存在,这是一个错误,请有人帮我解决这个问题。
我要在退出视频屏幕后停止播放视频声音或停止播放视频声音。
这是我的视频
<video oncontextmenu="return false;" src="../inflightapp/storage/app/public/series_videos/<?php echo ''.$row5['episode_video'].''; ?>" id="<?php echo ''.$row5['id'].'';?>" width="1px" controls controlsList="nodownload"></video>
JavaScript
var video = document.getElementById(title);
document.onkeypress = function(e){
if((e || window.event).keyCode === 32){
video.paused ? video.play() : video.pause();
}
};
$('video.series-video').bind('webkitfullscreenchange mozfullscreenchange fullscreenchange', function(e) {
var state = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;
var event = state ? 'FullscreenOn' : 'FullscreenOff';
答案 0 :(得分:0)
您可以尝试以下代码,
if (document.addEventListener)
{
document.addEventListener('webkitfullscreenchange', exitHandler, false);
document.addEventListener('mozfullscreenchange', exitHandler, false);
document.addEventListener('fullscreenchange', exitHandler, false);
document.addEventListener('MSFullscreenChange', exitHandler, false);
}
function exitHandler()
{
if (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement !== null)
{
/* Run code for exit */
}
}