溫馨提示×

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

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

html5播放mp4視頻代碼

發(fā)布時(shí)間:2020-07-11 20:10:41 來(lái)源:網(wǎng)絡(luò) 閱讀:7662 作者:guowang327 欄目:移動(dòng)開(kāi)發(fā)

1.nginx支持flv和mp4格式播放

默認(rèn)yum安裝nginx

centos7安裝nginx時(shí)候應(yīng)該是默認(rèn)安裝nginx_mod_h364_streaming模塊的

# nginx -V查看是否安裝nginx_mod_h364_streaming模塊

nginx在新版本中已經(jīng)支持了--with-http_mp4_module --with-http_flv_module這2個(gè)模塊即可

# vi /etc/nginx/nginx.conf

server {

        listen       80 default_server;

        listen       [::]:80 default_server;

        server_name  _;

        root         /usr/share/nginx/html;

        #guowang add

        limit_rate_after 5m;   #在flv視頻文件下載了5M以后開(kāi)始限速

        limit_rate 512k;      #速度限制為512K


        # Load configuration files for the default server block.

        include /etc/nginx/default.d/*.conf;


        location / {

        }


        #guowang add

        location ~ \.flv {

            flv;

        }

        location ~ \.mp4$ {

            mp4;

        }


        error_page 404 /404.html;

            location = /40x.html {

        }


        error_page 500 502 503 504 /50x.html;

            location = /50x.html {

        }

}


2.html5播放mp4視頻代碼

<!DOCTYPE html>

<html>

<head>

    <meta charset="utf-8">

    <title>公司宣傳片</title>

</head>

<body>

    <h3>公司宣傳片</h3>

    <video width="320" height="240" controls autoplay>

        <source src="gs.mp4" type="video/mp4">

        <source src="gs.ogg" type="video/ogg">

        <source src="gs.webm" type="video/webm">

        <object data="gs.mp4" width="320" height="240">

          <embed src="gs.swf" width="320" height="240"><p>如果你播放不了該視頻,

那是你的設(shè)備不支持該文件格式</p>

        </object>

    </video>

</body>

</html>

3.參考:

http://www.runoob.com/html/html-videos.html

http://www.runoob.com/try/try.php?filename=tryhtml_video_html5_4


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

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

AI