fengchuanyu 1 semana atrás
pai
commit
2f6f1c4d00

+ 53 - 0
6_HTML5/3_媒体标签.html

@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+    <style>
+        video{
+            width: 300px;
+            height: 300px;
+        }
+    </style>
+</head>
+<body>
+    <!-- 音频标签 -->
+     <!-- controls 控制条属性 如果没有当前属性页面无法显示播放器 -->
+    <audio src="./media/song.mp3" ></audio> 
+    <button id="btnPlay">播放</button>
+    <button id="btnPause">暂停</button>
+    <button id="btnVolume">
+        调整音量
+    </button>
+
+    <!-- 视频标签 -->
+     <!-- controls 控制条属性 如果没有当前属性页面无法显示播放器 -->
+    <video src="./media/media.mp4" ></video>
+
+    <script>
+        // 获取元素
+        var audio = document.querySelector("audio");
+        var btnPlay = document.querySelector("#btnPlay");
+        var btnPause = document.querySelector("#btnPause");
+        var btnVolume = document.querySelector("#btnVolume");
+        var video = document.querySelector("video");
+        // 播放 play()
+        btnPlay.onclick = function(){
+            // audio.play();
+            video.play();
+        }
+        // 暂停 pause()
+        btnPause.onclick = function(){
+            // audio.pause();
+            video.pause();
+        }
+        // 调整音量
+        btnVolume.onclick = function(){
+            // audio.volume = 0.1;
+            video.volume = 0.1;
+        }
+        
+    </script>
+</body>
+</html>

+ 39 - 0
6_HTML5/4_canvas.html

@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+    <style>
+        #canvas{
+            background-color: black;
+        }
+    </style>
+</head>
+<body>
+    <!-- canvas 画布标签 -->
+    <canvas id="canvas" width="200" height="200"></canvas>
+    <script>
+        // 获取元素
+        var canvas = document.querySelector("#canvas");
+        // 获取上下文
+        var ctx = canvas.getContext("2d");
+        // 绘制一条线
+        // 设置线的颜色
+        ctx.strokeStyle = "white";
+        // 设置线的宽度
+        ctx.lineWidth = 5;
+        // 开始绘制 beginPath
+        ctx.beginPath();
+        // moveTo 移动到指定位置(落笔点)
+        ctx.moveTo(10, 10);
+        // lineTo 绘制一条线到指定位置
+        ctx.lineTo(100, 100);
+        ctx.lineTo(80, 150);
+        ctx.lineTo(100, 180);
+
+        // stroke 绘制线
+        ctx.stroke();
+    </script> 
+</body>
+</html>

BIN
6_HTML5/media/media.mp4


BIN
6_HTML5/media/song.mp3