
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
webrtc-streaming
Advanced tools
webrtc-streaming launcher
import { Launcher } from "webrtc-streaming";
const address = "xxxxxx";
const replaceWs = "xxxxxx";
const appKey = "xxxxxxx";
let appSecret;
let launcher;
async function bootstrap() {
const data = await handleShareInfo();
const { temporaryCredentials } = data;
const baseOptionsType = {
address,
replaceWs,
appKey,
appSecret,
startType: 1,
temporaryCredentials
};
const container = document.querySelector("body");
document.querySelector("body").style.width = "100%";
document.querySelector("body").style.height = "100%";
const uiOptions = {
onPlay: () => {
console.log('出现了有效画面')
//web端->应用
launcher.launcherBase.connection.emitUIInteraction('发给应用的数据').then(res => {
console.log(res ? '发送成功' : '发送失败')
})
},
onChange: (cb) => {
const { phase,fakePercent } = cb;
console.log('百分比:',fakePercent)
if (phase === "signaling-connected") {
//应用->web端
launcher.launcherBase.connection.interaction.on((res)=>{
console.log('收到应用的数据:',res)
})
}
};
};
launcher = new Launcher(baseOptionsType, container, uiOptions);
}
async function handleShareInfo() {
const params = {
appKey,
appSecret,
};
var url = new URL(`${address}/api/front/share/info`);
Object.keys(params).forEach(
(key) => params[key] && url.searchParams.append(key, params[key])
);
return fetch(url)
.then((response) => response.json())
.then((res) => {
if (res.result) {
return res.data;
}
});
}
window.addEventListener('DOMContentLoaded', () => {
if (
navigator.userAgent.includes('miniProgram') ||
navigator.userAgent.includes('MicroMessenger')
) {
new Promise((resolve, reject) => {
document.addEventListener('WeixinJSBridgeReady', resolve)
}).then(bootstrap)
} else {
bootstrap()
}
})
// call when video element start to play
extendOptions: {
onPlay: () => {
//do something
},
}
launcher.changeBandwidthByRenegotiation(
10000, // medians bitrate kbps
)
launcher.toggleStatistics()
window.setInterval(() => {
const { fps, bitrate, packetLossRate, latency, averageJitterBufferDelay } = launcher.report()
console.log(`
FPS: ${fps}
biterate: ${bitrate}kbps
latency: ${latency}ms
averageJitterBufferDelay: ${averageJitterBufferDelay}ms
packetLossRate: ${(packetLossRate * 100).toFixed(3)}%
`)
}, 1000)
/* NOTE: fullscreen need user activation gesture
* @see https://html.spec.whatwg.org/multipage/interaction.html#user-activation-processing-model
*/
someTriggerElement.addEventListener('click', () => launcher.toggleFullscreen())
launcher.destory([errMsg])
FAQs
webrtc-streaming launcher for tianyi
The npm package webrtc-streaming receives a total of 1 weekly downloads. As such, webrtc-streaming popularity was classified as not popular.
We found that webrtc-streaming demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.