萤石云监控

安转依赖
npm install ezuikit-js
使用
import EzUIKit from 'ezuikit-js'

var playr = new EZUIKit.EZUIKitPlayer({
	id: 'video-container', // 视频容器ID
	accessToken: accessToken,
	url: 'ezopen://open.ys7.com/E5927****/1.hd.live', // SN:E5927****,通道号:1,视频类型:hd
	// template: 'simple', // simple - 极简版;standard-标准版;security - 安防版(预览回放);voice-语音版; theme-可配置主题;
	plugin: ['talk'], // 加载插件,talk-对讲
	width: 1000,
	height: 600,
});

播放方式

方式1

div标签自动播放 , 及各种操作指令

<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>

	<body>
		
		<div id="video-container" style="width: 1000px;"></div>

		<div style="margin-top: 10px;">
			<button onClick="play()">play</button>
			<button onClick="stop()">stop</button>
			<button onClick="getOSDTime()">getOSDTime</button>
			<button onClick="getOSDTime2()">getOSDTime2</button>
			<button onClick="capturePicture()">capturePicture</button>
			<button onClick="openSound()">openSound</button>
			<button onClick="closeSound()">closeSound</button>
			<button onClick="startSave()">startSave</button>
			<button onClick="stopSave()">stopSave</button>
			<button onClick="ezopenStartTalk()">开始对讲</button>
			<button onClick="ezopenStopTalk()">结束对讲</button>
			<button onClick="fullScreen()">全屏</button>
		</div>
		
	</body>
	
	<script type="text/javascript" src="js/ezuikit.js"></script>
	<script>
		
		// 官网下载:https://open.ys7.com/mobile/download.html
		// 官网API:http://hls.open.ys7.com/doc/zh/book/index/user.html
		// accessToken获取接口【POST】: https://open.ys7.com/api/lapp/token/get?appKey=ff768f0051284521b2*********9403&appSecret=7f06909efa7a80*********d652dac33
		

		var accessToken = "at.5bjnyfge123nq1vr2x***************************-f7tapedip";
		var playr = new EZUIKit.EZUIKitPlayer({
			id: 'video-container', // 视频容器ID
			accessToken: accessToken,
			url: 'ezopen://open.ys7.com/E5927****/1.hd.live', // SN:E5927****,通道号:1,视频类型:hd
			// template: 'simple', // simple - 极简版;standard-标准版;security - 安防版(预览回放);voice-语音版; theme-可配置主题;
			plugin: ['talk'], // 加载插件,talk-对讲
			width: 1000,
			height: 600,
		});

		// 功能
		function fullScreen() {
			var playPromise = playr.fullScreen();
			playPromise.then((data) => {
				console.log("promise 获取 数据", data)
			})
		}

		function play() {
			var playPromise = playr.play();
			playPromise.then((data) => {
				console.log("promise 获取 数据", data)
			})
		}

		function stop() {
			var stopPromise = playr.stop();
			stopPromise.then((data) => {
				console.log("promise 获取 数据", data)
			})
			// 销毁
			// player.destroy()
		}

		function getOSDTime() {
			var getOSDTimePromise = playr.getOSDTime();
			getOSDTimePromise.then((data) => {
				console.log("promise 获取 数据", data)
			})
		}

		function getOSDTime2() {
			var getOSDTimePromise = playr2.getOSDTime();
			getOSDTimePromise.then((data) => {
				console.log("promise 获取 数据", data)
			})
		}

		function capturePicture() {
			var capturePicturePromise = playr.capturePicture();
			capturePicturePromise.then((data) => {
				console.log("promise 获取 数据", data)
			})
		}

		function openSound() {
			var openSoundPromise = playr.openSound();
			openSoundPromise.then((data) => {
				console.log("promise 获取 数据", data)
			})
		}

		function closeSound() {
			var closeSoundPromise = playr.closeSound();
			closeSoundPromise.then((data) => {
				console.log("promise 获取 数据", data)
			})
		}

		function startSave() {
			var startSavePromise = playr.startSave();
			startSavePromise.then((data) => {
				console.log("promise 获取 数据", data)
			})
		}

		function stopSave() {
			var stopSavePromise = playr.stopSave();
			stopSavePromise.then((data) => {
				console.log("promise 获取 数据", data)
			})
		}

		function ezopenStartTalk() {
			playr.startTalk();
		}

		function ezopenStopTalk() {
			playr.stopTalk();
		}
		
		
		
	</script>

</html>
方式2

使用video播放,但是浏览器会限制自动播放

<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>video播放器实时监控</title>
	</head>

	<body>

		<video id="myPlayer" autoplay controls style="width: 600px;height:400px"></video>

	</body>

	<script type="text/javascript" src="js/ezuikit.js"></script>
	<script>
		
		// 弊端:浏览器默认限制自动播放
		
		// 开始初始化直播源地址(此处官方例子,可直接查看效果)
		var player = new EZUIKit.HLS("myPlayer", "https://open.ys7.com/v3/openlive/G39444019_1_2.m3u8?expire=1687487466&id=461840962679742464&t=c076d5a5ad56090e919a6a2500b96169c20a77874cce866a87a7d65e493e6f2f&ev=100");
		// 播放
		player.play();
		// 结束
		//player.stop();
		
	</script>

</html>
方式3

[iframe]方式,使用的是萤石云的h5界面
长时间播放也不会太卡,多窗口播放时流畅度比上面两种好

// 第一种
<iframe src="https://open.ys7.com/ezopen/h5/iframe_se?url=ezopen://open.ys7.com/E123456/1.hd.live&amp;autoplay=1&amp;audio=1&amp;accessToken=at.5bjnyfge123nq1vr2x***************************-f7tapedip" width="600" height="400" id="fullb" allowfullscreen=""></iframe>

// 第二种,templete:0不显示全屏,1显示全屏
<iframe src="https://open.ys7.com/ezopen/h5/iframe?url=ezopen://open.ys7.com/E123456/1.hd.live&amp;autoplay=1&amp;audio=1&amp;accessToken=at.5bjnyfge123nq1vr2x***************************-f7tapedip&templete=0" width="600" height="400" id="fullb" allowfullscreen=""></iframe>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值