溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

html5中如何自動播放mov格式視頻

發(fā)布時(shí)間:2022-03-01 10:08:23 來源:億速云 閱讀:1535 作者:iii 欄目:開發(fā)技術(shù)

這篇文章主要介紹了html5中如何自動播放mov格式視頻的相關(guān)知識,內(nèi)容詳細(xì)易懂,操作簡單快捷,具有一定借鑒價(jià)值,相信大家閱讀完這篇html5中如何自動播放mov格式視頻文章都會有所收獲,下面我們一起來看看吧。

1、首先網(wǎng)站要支持.MOV格式文件

就是說,網(wǎng)站要能識別.MOV格式文件。

<mimeMap fileExtension=".mov" mimeType="video/quicktime" />

如何識別?設(shè)置MIME類型。以IIS為例。除了可以在IIS界面上直接設(shè)置,還可以在項(xiàng)目的web.config里設(shè)置。給個(gè)完整的例子

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <directoryBrowse enabled="true" />
        <defaultDocument>
            <files>
                <remove value="default.aspx" />
                <remove value="iisstart.htm" />
                <remove value="index.html" />
                <remove value="index.htm" />
                <remove value="Default.asp" />
                <remove value="Default.htm" />
            </files>
        </defaultDocument>
        <staticContent>
   <remove fileExtension=".mp4" />
   <remove fileExtension=".wasm" />
   <remove fileExtension=".woff" />
   <remove fileExtension=".woff2" />
   <remove fileExtension=".mov" />
    
   <mimeMap fileExtension=".mp4" mimeType="video/mpeg" />
            <mimeMap fileExtension=".wasm" mimeType="application/wasm" />
            <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
            <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
   <mimeMap fileExtension=".mov" mimeType="video/quicktime" />
        </staticContent>
        <httpProtocol>
            <customHeaders>
                <add name="Access-Control-Allow-Origin" value="*" />
            </customHeaders>
        </httpProtocol>
        <caching>
            <profiles>
                <add extension=".png" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" />
                <add extension=".jpg" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" />
                <add extension=".css" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" />
                <add extension=".js" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" />
            </profiles>
        </caching>
    </system.webServer>
</configuration>

2、HTML

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style>
body,center{
padding:0;
margin:0;
}
</style>
</head>
<body>
  <center>
  <video id="video"  width="640" height="480" muted controls autoplay="autoplay" preload="auto" >
    <source src="月半灣.mov" />
    您的瀏覽器不支持 HTML5 video 標(biāo)簽。
  </video>
  </center>
</body>
</html>

本例會自動播放。自動播放的關(guān)鍵是“muted”屬性(靜音),否則無論是聲明autoplay=“autoplay”,還是用腳本video.play()都不起作用。這個(gè)應(yīng)該是故意設(shè)計(jì)成這樣的。否則,打開就自動播放,萬一是愛情動作片怎么辦?如果靜音就少了許多顧慮。

關(guān)于“html5中如何自動播放mov格式視頻”這篇文章的內(nèi)容就介紹到這里,感謝各位的閱讀!相信大家對“html5中如何自動播放mov格式視頻”知識都有一定的了解,大家如果還想學(xué)習(xí)更多知識,歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI