美文网首页
h5直播播放器

h5直播播放器

作者: 耍帅oldboy | 来源:发表于2022-12-15 20:24 被阅读0次

浏览器协议协议
h5直播只能播放hls协议,flv协议不支持,rtmp协议不支持
pc端浏览器支持hls、flv协议
app端和小程序支持rtmp协议、flv协议
hls协议延时高达到20-30s
rtmp和flv延时2-10s

阿里播放器

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="IE=edge" >
    <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"/>
    <title>Aliplayer Online Settings</title>
    <link rel="stylesheet" href="https://g.alicdn.com/de/prismplayer/2.13.2/skins/default/aliplayer-min.css" />
    <script type="text/javascript" charset="utf-8" src="https://g.alicdn.com/de/prismplayer/2.13.2/aliplayer-min.js"></script>
</head>
<body>
<div class="prism-player" id="player-con"></div>
<script>
    var player = new Aliplayer({
            "id": "player-con",
            "source": "xxx",
            "width": "100%",
            "height": "500px",
            "autoplay": true,
            "isLive": true,
            "rePlay": false,
            "playsinline": true,
            "preload": true,
            "controlBarVisibility": "hover",
            "useH5Prism": true
        }, function (player) {
            console.log("The player is created");
        }
    );
</script>
</body>
</html>

3、Dplayer播放器

<template>
    <div id="dplayer"></div>
 </template>

<script>
    import DPlayer from 'dplayer'
    import flvjs from 'flv.js'

    export default {
        data() {
            return {
                
            }
        },
        mounted() {
            this.createDplayer()
        },
        onLoad() {
            
        },
        methods: {
            createDplayer(){
                const dp = new DPlayer({
                    container: document.getElementById('dplayer'),
                    live:true,
                    autoplay:true,
                    video: {
                        url: 'xxx',
                        type: 'customFlv',
                        customType: {
                            customFlv: function (video, player) {
                                const flvPlayer = flvjs.createPlayer({
                                    type: 'flv',
                                    url: video.src,
                                });
                                flvPlayer.attachMediaElement(video);
                                flvPlayer.load();
                            },
                        },
                    },
                });
            },
        }
    }
</script>
<style>
</style>

相关文章

网友评论

      本文标题:h5直播播放器

      本文链接:https://www.haomeiwen.com/subject/emnrqdtx.html