<!DOCTYPE html>
    <html lang="vi" xmlns="http://www.w3.org/1999/xhtml" prefix="og: http://ogp.me/ns#">
    <head>
<title>Chèn video trong HTML5</title>
<meta name="description" content="Chèn video trong HTML5 - Savefile - Tin Tức - https&#x3A;&#x002F;&#x002F;www.nguoicodonvn2008.info&#x002F;vi&#x002F;news&#x002F;savefile&#x002F;kien-thuc-may-tinh&#x002F;chen-video-trong-html5-5508.html">
<meta name="author" content=".: Nguoicodonvn2008.info - Cõi lòng người cô đơn :.">
<meta name="copyright" content=".: Nguoicodonvn2008.info - Cõi lòng người cô đơn :. [admin@nguoicodonvn2008.info]">
<meta name="robots" content="index, archive, follow, noodp">
<meta name="googlebot" content="index,archive,follow,noodp">
<meta name="msnbot" content="all,index,follow">
<meta name="generator" content="NukeViet v4.5">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta property="og:title" content="Chèn video trong HTML5">
<meta property="og:type" content="website">
<meta property="og:description" content="Savefile - Tin Tức - https&#x3A;&#x002F;&#x002F;www.nguoicodonvn2008.info&#x002F;vi&#x002F;news&#x002F;savefile&#x002F;kien-thuc-may-tinh&#x002F;chen-video-trong-html5-5508.html">
<meta property="og:site_name" content=".&#x3A; Nguoicodonvn2008.info - Cõi lòng người cô đơn &#x3A;.">
<meta property="og:url" content="https://www.nguoicodonvn2008.info/vi/news/savefile/kien-thuc-may-tinh/chen-video-trong-html5-5508.html">
<link rel="shortcut icon" href="https://www.nguoicodonvn2008.info/favicon.ico">
<link rel="canonical" href="https://www.nguoicodonvn2008.info/vi/news/savefile/kien-thuc-may-tinh/chen-video-trong-html5-5508.html">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/" title="Tin Tức" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/karaoke-dual/" title="Tin Tức - Karaoke Dual" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/nhac-tre/" title="Tin Tức - Nhạc trẻ" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/tru-tinh/" title="Tin Tức - Trữ tình" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/nuoc-ngoai/" title="Tin Tức - Nước ngoài" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/remix/" title="Tin Tức - Remix" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/tam-su-tinh-yeu/" title="Tin Tức - Tâm sự tình yêu" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/tho-suu-tam/" title="Tin Tức - Thơ sưu tầm" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/cuoc-song/" title="Tin Tức - Cuộc sống" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/phan-mem/" title="Tin Tức - Phần mềm" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/kien-thuc-may-tinh/" title="Tin Tức - Kiến thức máy tính" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/hoc-tap/" title="Tin Tức - Học tập" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/tai-lieu/" title="Tin Tức - Tài liệu" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/de-thi/" title="Tin Tức - Đề thi" type="application/rss+xml">
<link rel="preload" as="style" href="https://www.nguoicodonvn2008.info/assets/css/font-awesome.min.css" type="text/css">
<link rel="preload" as="style" href="https://www.nguoicodonvn2008.info/themes/default/css/bootstrap.non-responsive.css" type="text/css">
<link rel="preload" as="style" href="https://www.nguoicodonvn2008.info/themes/default/css/style.css" type="text/css">
<link rel="preload" as="style" href="https://www.nguoicodonvn2008.info/themes/default/css/style.non-responsive.css" type="text/css">
<link rel="preload" as="style" href="https://www.nguoicodonvn2008.info/themes/default/css/news.css" type="text/css">
<link rel="preload" as="style" href="https://www.nguoicodonvn2008.info/themes/default/css/custom.css" type="text/css">
<link rel="preload" as="script" href="https://www.nguoicodonvn2008.info/assets/js/jquery/jquery.min.js" type="text/javascript">
<link rel="preload" as="script" href="https://www.nguoicodonvn2008.info/assets/js/language/vi.js" type="text/javascript">
<link rel="preload" as="script" href="https://www.nguoicodonvn2008.info/assets/js/DOMPurify/purify3.js" type="text/javascript">
<link rel="preload" as="script" href="https://www.nguoicodonvn2008.info/assets/js/global.js" type="text/javascript">
<link rel="preload" as="script" href="https://www.nguoicodonvn2008.info/assets/js/site.js" type="text/javascript">
<link rel="preload" as="script" href="https://www.nguoicodonvn2008.info/themes/default/js/news.js" type="text/javascript">
<link rel="preload" as="script" href="https://www.nguoicodonvn2008.info/themes/default/js/main.js" type="text/javascript">
<link rel="preload" as="script" href="https://www.nguoicodonvn2008.info/themes/default/js/custom.js" type="text/javascript">
<link rel="preload" as="script" href="https://www.nguoicodonvn2008.info/themes/default/js/bootstrap.min.js" type="text/javascript">
<link rel="stylesheet" href="https://www.nguoicodonvn2008.info/assets/css/font-awesome.min.css">
<link rel="stylesheet" href="https://www.nguoicodonvn2008.info/themes/default/css/bootstrap.non-responsive.css">
<link rel="stylesheet" href="https://www.nguoicodonvn2008.info/themes/default/css/style.css">
<link rel="stylesheet" href="https://www.nguoicodonvn2008.info/themes/default/css/style.non-responsive.css">
<link rel="StyleSheet" href="https://www.nguoicodonvn2008.info/themes/default/css/news.css">
<link rel="stylesheet" href="https://www.nguoicodonvn2008.info/themes/default/css/custom.css">
<style type="text/css">
	body{background: #fff;}
</style>
    </head>
    <body>
<div id="print">
	<div id="hd_print">
		<h2 class="pull-left">.&#x3A; Nguoicodonvn2008.info - Cõi lòng người cô đơn &#x3A;.</h2>
		<p class="pull-right"><a title=".&#x3A; Nguoicodonvn2008.info - Cõi lòng người cô đơn &#x3A;." href="https://www.nguoicodonvn2008.info/">https://www.nguoicodonvn2008.info</a></p>
	</div>
	<div class="clear"></div>
	<hr />
	<div id="content">
		<h1>Chèn video trong HTML5</h1>
		<ul class="list-inline">
			<li>Thứ sáu - 22/04/2022 23:19</li>
			<li class="hidden-print txtrequired"><em class="fa fa-print">&nbsp;</em><a title="In ra" href="javascript:;" onclick="window.print()">In ra</a></li>
			<li class="hidden-print txtrequired"><em class="fa fa-power-off">&nbsp;</em><a title="Đóng cửa sổ này" href="javascript:;" onclick="window.close()">Đóng cửa sổ này</a></li>
		</ul>
		<div class="clear"></div>
		<div id="hometext">
		</div>
		<div id="bodytext" class="clearfix">
			<p>Video là một thành phần không thể thiếu trên mỗi website. Việc chèn thêm video giúp cho website của bạn trở nên sinh động và đầy đủ hơn. Bài viết dưới đây, Quản Trị Mạng sẽ giới thiệu cho bạn cách sử dung thẻ &lt;video&gt; để hiển thị video trên website của bạn.</p>

<p>Ví dụ video dưới đây được chèn bằng thẻ video:<br />
&nbsp;</p>

<div style="text-align: center;">
<video controls="controls" height="618" id="video2022323102122" poster="/uploads/news/2022_04/image-20220420114947-1.jpeg" width="563"><source src="https://st.quantrimang.com/photos/file/2021/08/30/google-maps-nes.mp4" type="video/mp4" />Your browser doesn&#039;t support video.<br />
Please download the file: <a href="https://st.quantrimang.com/photos/file/2021/08/30/google-maps-nes.mp4">video/mp4</a></video>
</div>

<h2>Phần tử &lt;video&gt; trong HTML</h2>

<p>Để hiển thị video trên website, bạn hãy sử dụng thẻ &lt;video&gt; theo cấu trúc dưới đây:</p>

<pre id="pre0">
<code>&lt;video width=&quot;320&quot; height=&quot;240&quot; controls&gt;
  &lt;source src=&quot;movie.mp4&quot; type=&quot;video/mp4&quot;&gt;
  &lt;source src=&quot;movie.ogg&quot; type=&quot;video/ogg&quot;&gt;
Trình duyệt của bạn không hỗ trợ thẻ video.
&lt;/video&gt;</code></pre>

<p><strong>Giải thích ví dụ trên:</strong></p>

<p>- Thuộc tính&nbsp;<strong>controls</strong>&nbsp;trong ví dụ trên sẽ thêm thanh điều khiển video vào, như: phát, tạm dừng, phóng to và âm lượng...</p>

<p>- Bạn nên thêm thuộc tính&nbsp;<strong>width</strong>&nbsp;và&nbsp;<strong>height</strong>&nbsp;để đảm bảo cố định khung video sẽ được hiện trong quá trình load site.</p>

<p>- Phần tử&nbsp;<strong>source&nbsp;</strong>cho phép bạn chỉ định các tệp video thay thế mà trình duyệt có thể chọn. Mặc định, trình duyệt sẽ sử dụng định dạng được nhận dạng đầu tiên.</p>

<p>- Phần nội dung Text giữa các thẻ&nbsp;<strong>&lt;video&gt;</strong>&nbsp;và&nbsp;<strong>&lt;/video&gt;</strong>&nbsp;sẽ chỉ hiển thị khi chạy trên các trình duyệt không hỗ trợ thẻ &lt;video&gt;.</p>

<h2>Thiết lập video tự động chạy</h2>

<p>Để video tự động chạy ngay sau khi load xong trình duyệt, bạn hãy sử dụng thuộc tính&nbsp;<strong>autoplay</strong>. Ví dụ như đoạn code dưới đây:</p>

<pre id="pre1">
<code>&lt;video width=&quot;320&quot; height=&quot;240&quot; autoplay&gt;
  &lt;source src=&quot;movie.mp4&quot; type=&quot;video/mp4&quot;&gt;
  &lt;source src=&quot;movie.ogg&quot; type=&quot;video/ogg&quot;&gt;
Trình duyệt của bạn không hỗ trợ thẻ video.
&lt;/video&gt;</code></pre>

<p><strong>Lưu ý</strong>: Trong hầu hết các trường hợp, trình duyệt nhân Chromium khoog cho phép tự động phát. Nếu có, thì video luôn bị tắt tiếng khi tự chạy.</p>

<p>Thêm&nbsp;<strong>muted&nbsp;</strong>sau&nbsp;<strong>autoplay&nbsp;</strong>để video của bạn luôn tự động phát (nhưng bị tắt tiếng):</p>

<pre id="pre2">
<code>&lt;video width=&quot;320&quot; height=&quot;240&quot; autoplay muted&gt;
  &lt;source src=&quot;movie.mp4&quot; type=&quot;video/mp4&quot;&gt;
  &lt;source src=&quot;movie.ogg&quot; type=&quot;video/ogg&quot;&gt;
Trình duyệt của bạn không hỗ trợ thẻ video.
&lt;/video&gt;</code></pre>

<h2>Thẻ &lt;video&gt; được hỗ trợ trên các trình duyệt nào?</h2>

<p>Thường thẻ video được hỗ trợ cho các trình duyệt với các phiên bản tương ứng như sau:</p>

<ul>
	<li>Chrome 4.0 trở lên</li>
	<li>Edge 9.0 trở lên</li>
	<li>Firefox 3.5 trở lên</li>
	<li>Safari 4.0 trở lên</li>
	<li>Opera 10.5 trở lên</li>
</ul>

<h2>Định dạng video HTML</h2>

<p>Có ba định dạng video được hỗ trợ trên trình duyệt là: MP4, WebM và Ogg. Trình duyệt hỗ trợ các định dạng khác nhau theo bảng dưới đây:</p>

<table border="1" cellpadding="5" cellspacing="0">
	<tbody>
		<tr>
			<td><strong>Trình duyệt</strong></td>
			<td><strong>MP4</strong></td>
			<td><strong>WebM</strong></td>
			<td><strong>Ogg</strong></td>
		</tr>
		<tr>
			<td>Edge</td>
			<td>Có</td>
			<td>Có</td>
			<td>Có</td>
		</tr>
		<tr>
			<td>Chrome</td>
			<td>Có</td>
			<td>Có</td>
			<td>Có</td>
		</tr>
		<tr>
			<td>Firefox</td>
			<td>Có</td>
			<td>Có</td>
			<td>Có</td>
		</tr>
		<tr>
			<td>Safari</td>
			<td>Có</td>
			<td>Có</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>Opera</td>
			<td>Có</td>
			<td>Có</td>
			<td>Có</td>
		</tr>
	</tbody>
</table>

<h3>Video HTML - Các loại media</h3>

<table border="1" cellpadding="5" cellspacing="0" id="table1">
	<tbody>
		<tr>
			<th>File Format</th>
			<th>Media Type</th>
		</tr>
		<tr>
			<td>MP4</td>
			<td>video/mp4</td>
		</tr>
		<tr>
			<td>WebM</td>
			<td>video/webm</td>
		</tr>
		<tr>
			<td>Ogg</td>
			<td>video/ogg</td>
		</tr>
	</tbody>
</table>
		</div>
				<div id="author">
						<p>
				<strong>Nguồn tin:</strong>
				Quantrimang.com
			</p>
		</div>
	</div>
	<div id="footer" class="clearfix">
		<div id="url">
			<strong>URL của bản tin này: </strong><a href="https://www.nguoicodonvn2008.info/vi/news/savefile/kien-thuc-may-tinh/chen-video-trong-html5-5508.html" title="Chèn video trong HTML5">https://www.nguoicodonvn2008.info/vi/news/savefile/kien-thuc-may-tinh/chen-video-trong-html5-5508.html</a>

		</div>
		<div class="clear"></div>
		<div class="copyright">
			&copy; .&#x3A; Nguoicodonvn2008.info - Cõi lòng người cô đơn &#x3A;.
		</div>
		<div id="contact">
			<a href="mailto:admin@nguoicodonvn2008.info">admin@nguoicodonvn2008.info</a>
		</div>
	</div>
</div>
        <div id="timeoutsess" class="chromeframe">
            Bạn đã không sử dụng Site, <a onclick="timeoutsesscancel();" href="https://www.nguoicodonvn2008.info/#">Bấm vào đây để duy trì trạng thái đăng nhập</a>. Thời gian chờ: <span id="secField"> 60 </span> giây
        </div>
        <div id="openidResult" class="nv-alert" style="display:none"></div>
        <div id="openidBt" data-result="" data-redirect=""></div>
		</script>
		<div class="car-top">
  <span><img src="https://www.nguoicodonvn2008.info/themes/default/images/car.png" alt=""></span>
</div>
<div id="run_cronjobs" style="visibility:hidden;display:none;"><img alt="cron" src="/index.php?second=cronjobs&amp;p=i1aFf0az" width="1" height="1" /></div>
<script src="https://www.nguoicodonvn2008.info/assets/js/jquery/jquery.min.js"></script>
<script>var nv_base_siteurl="/",nv_lang_data="vi",nv_lang_interface="vi",nv_name_variable="nv",nv_fc_variable="op",nv_lang_variable="language",nv_module_name="news",nv_func_name="savefile",nv_is_user=0, nv_my_ofs=-4,nv_my_abbr="EDT",nv_cookie_prefix="nv4c_e856T",nv_check_pass_mstime=1738000,nv_area_admin=0,nv_safemode=0,theme_responsive=0,nv_recaptcha_ver=2,nv_recaptcha_sitekey="",nv_recaptcha_type="image",XSSsanitize=1;</script>
<script src="https://www.nguoicodonvn2008.info/assets/js/language/vi.js"></script>
<script src="https://www.nguoicodonvn2008.info/assets/js/DOMPurify/purify3.js"></script>
<script src="https://www.nguoicodonvn2008.info/assets/js/global.js"></script>
<script src="https://www.nguoicodonvn2008.info/assets/js/site.js"></script>
<script src="https://www.nguoicodonvn2008.info/themes/default/js/news.js"></script>
<script src="https://www.nguoicodonvn2008.info/themes/default/js/main.js"></script>
<script src="https://www.nguoicodonvn2008.info/themes/default/js/custom.js"></script>
<script type="application/ld+json">
        {
            "@context": "https://schema.org",
            "@type": "Organization",
            "url": "https://www.nguoicodonvn2008.info",
            "logo": "https://www.nguoicodonvn2008.info/uploads/angel.gif"
        }
        </script>
<script src="https://www.nguoicodonvn2008.info/themes/default/js/bootstrap.min.js"></script>
<script type="text/javascript">
var $scrolltop = $('.car-top');
$scrolltop.on('click', function () {
    $('html,body').animate({
        scrollTop: 0
    }, 800);
    $(this).addClass("car-run");
    setTimeout(function(){ $scrolltop.removeClass('car-run');}, 1000);
    return false;
});
$(window).on('scroll', function ()
{ 
    if($(window).scrollTop() >= 200)
    {
        $scrolltop.addClass("show");
        $scrolltop.addClass("car-down");
    }
    else
    {
       $scrolltop.removeClass("show");
       setTimeout(function(){ $scrolltop.removeClass('car-down');}, 300);
    }
});
</script>
</body>
</html>