Jessibuca是一款开源的纯H5直播流播放器,通过Emscripten将音视频解码库编译成Js(ams.js/wasm)运行于浏览器之中。兼容几乎所有浏览器,可以运行在PC、手机、微信中,无需额外安装插件。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style>
.container {
background: rgb(13, 14, 27);
width: 450px;
height: 250px;
}
</style>
</head>
<body>
<div class="container" id="container"></div>
<script src="js/renderer.js"></script>
<script>
var $container = document.getElementById('container');
var jessibuca = new Jessibuca({
container: $container, //容器
videoBuffer: 0.2, //延迟时间
decoder: "js/ff.js", // 默认是 ff.js
hasAudio: false, //不开启声音
isResize: false, // 是否自适应尺寸
loadingText: '加载中' // 加载文案。 默认'加载中。。。。。'
});
jessibuca.onLog = msg => console.error(msg);
jessibuca.onRecord = (status) => console.log('onRecord', status);
jessibuca.onPause = () => console.log('onPause');
jessibuca.onPlay = () => console.log('onPlay');
jessibuca.onFullscreen = msg => console.log('onFullscreen', msg);
jessibuca.onMute = msg => console.log('onMute', msg);
setTimeout(function() {
jessibuca.play("ws://192.168.1.111:9080/ws.flv?token=8f9d3e2b-9752-a745-f804-220a51eaf14b");
}, 1000);
</script>
</body>
</html>