VB代码:构建一个视频播放器页面
时间: 2024-01-05 12:04:03 浏览: 85
抱歉,我是一名自然语言处理模型,无法直接生成代码,以下是一个简单的视频播放器页面的代码示例,你可以参考着实现:
```
<!DOCTYPE html>
<html>
<head>
<title>Video Player</title>
<style>
body {
background-color: #f2f2f2;
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
.container {
width: 80%;
margin: 0 auto;
padding: 20px;
background-color: #fff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
box-sizing: border-box;
}
.video-container {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
margin-bottom: 20px;
}
.video-container video {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
.controls {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 20px;
}
.controls button {
background-color: #007bff;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
transition: background-color .3s ease-in-out;
}
.controls button:hover {
background-color: #0062cc;
}
</style>
</head>
<body>
<div class="container">
<div class="video-container">
<video id="video-player" controls>
<source src="video.mp4" type="video/mp4">
</video>
</div>
<div class="controls">
<button id="play-pause-button">Play</button>
<input id="volume-slider" type="range" min="0" max="1" step="0.1" value="1">
</div>
</div>
<script>
var videoPlayer = document.getElementById("video-player");
var playPauseButton = document.getElementById("play-pause-button");
var volumeSlider = document.getElementById("volume-slider");
playPauseButton.addEventListener("click", function() {
if (videoPlayer.paused) {
videoPlayer.play();
playPauseButton.textContent = "Pause";
} else {
videoPlayer.pause();
playPauseButton.textContent = "Play";
}
});
volumeSlider.addEventListener("input", function() {
videoPlayer.volume = volumeSlider.value;
});
</script>
</body>
</html>
```
这段代码使用 HTML、CSS 和 JavaScript 实现了一个基本的视频播放器页面,包括视频容器、控制栏和基本的播放和音量控制功能。你可以根据自己的需求进行修改和拓展。
阅读全文