济菏高速业务端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
813 B

1 year ago
import mpegts from "mpegts.js";
import { getCameraStream } from "@screen/pages/Home/components/RoadAndEvents/utils/httpList.js";
/**
*
* @param {HTMLElement} container 容器
* @param {{camId?: string; url?: string}?} options {camId: 相机ID; url: 直播地址}
* @returns
*/
export async function openVideoStream(container, { camId, url } = {}) {
if (camId) {
const { code, data } = await getCameraStream(camId).catch(() => ({}));
if (code != 200) return;
url = data.liveUrl;
}
if (!url) return;
1 year ago
console.log(mpegts.getFeatureList().mseLivePlayback);
const player = mpegts.createPlayer({
type: "flv",
url: url,
isLive: true,
hasVideo: true,
hasAudio: true,
});
1 year ago
player.attachMediaElement(container);
1 year ago
player.load();
player.play();
1 year ago
return player;
}