html5播放mp4視頻代碼


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

默認yum安裝nginx

centos7安裝nginx時候應該是默認安裝nginx_mod_h264_streaming模塊的

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

nginx在新版本中已經支持了--with-http_mp4_module --with-http_flv_module這2個模塊即可

# 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以后開始限速

        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>

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

    <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>如果你播放不了該視頻,

那是你的設備不支持該文件格式</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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM