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.
|
|
|
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;
|
|
|
|
|
|
|
|
console.log(mpegts.getFeatureList().mseLivePlayback);
|
|
|
|
|
|
|
|
const player = mpegts.createPlayer({
|
|
|
|
type: "flv",
|
|
|
|
url: url,
|
|
|
|
isLive: true,
|
|
|
|
hasVideo: true,
|
|
|
|
hasAudio: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
player.attachMediaElement(container);
|
|
|
|
|
|
|
|
player.load();
|
|
|
|
player.play();
|
|
|
|
|
|
|
|
return player;
|
|
|
|
}
|