npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ezuikit/control-broadcast

v0.0.1

Published

broadcast voice control

Readme

@ezuikit/control-broadcast

云广播喊话控制模块

功能特性

  • 🎤 语音录制(3-60秒)
  • 📋 默认语音列表查询
  • 📤 临时语音下发
  • 🔊 默认语音下发
  • 🎵 录音播放预览
  • 🌍 国际化支持(中英文)
  • 🔌 事件驱动架构,解耦接口调用

架构说明

Broadcast 模块采用事件驱动架构,不直接调用接口,而是通过 EventEmitter 与上层通信:

  1. Broadcast 触发请求事件(requestQueryVoiceListrequestSendVoiceOncerequestSendVoice
  2. 上层(ezopen)监听这些事件,调用实际的接口方法
  3. 上层将结果通过事件返回给 Broadcast(voiceListLoadedvoiceSent 等)
  4. Broadcast 监听结果事件,更新 UI 和内部状态

详细说明请参考 EVENT_DRIVEN_ARCHITECTURE.md

安装

npm install @ezuikit/control-broadcast
# or 
yarn add @ezuikit/control-broadcast
# or
pnpm install @ezuikit/control-broadcast

使用

基础使用

import Broadcast from '@ezuikit/control-broadcast';

const broadcast = new Broadcast({
  deviceSerial: 'BA5551167',
  channelNo: '1',
  accessToken: 'your-access-token',
  env: {
    domain: 'https://open.ys7.com',
  },
});

// 打开云广播界面
broadcast.open();

// 监听事件
broadcast.on('voiceListLoaded', (data) => {
  console.log('语音列表加载完成', data);
});

broadcast.on('voiceSent', (data) => {
  console.log('语音下发成功', data);
});

// 销毁
broadcast.destroy();

与上层集成(ezopen)

上层需要监听 Broadcast 的请求事件并调用实际接口:

// 监听查询语音列表请求
broadcast.eventEmitter.on('requestQueryVoiceList', async (data) => {
  try {
    const result = await player.queryVoiceList({
      deviceSerial: data.params.deviceSerial,
      channelNo: data.params.channelNo,
      pageSize: data.params.pageSize,
    });

    broadcast.eventEmitter.emit('voiceListLoaded', {
      eventType: 'voiceListLoaded',
      code: 0,
      data: result.data,
      msg: '语音列表加载成功',
    });
  } catch (error) {
    broadcast.eventEmitter.emit('voiceListError', {
      eventType: 'voiceListError',
      code: -1,
      msg: error.message,
      error,
    });
  }
});

// 监听临时语音下发请求
broadcast.eventEmitter.on('requestSendVoiceOnce', async (data) => {
  try {
    const result = await player.sendVoiceOnce({
      deviceSerial: data.deviceSerial,
      channelNo: data.channelNo,
      voiceFile: data.voiceFile,
    });

    broadcast.eventEmitter.emit('voiceSent', {
      eventType: 'voiceSent',
      code: 0,
      data: result,
      msg: '临时语音下发成功',
    });
  } catch (error) {
    broadcast.eventEmitter.emit('voiceSendError', {
      eventType: 'voiceSendError',
      code: -1,
      msg: error.message,
      error,
    });
  }
});

// 监听默认语音下发请求
broadcast.eventEmitter.on('requestSendVoice', async (data) => {
  try {
    const result = await player.sendVoice({
      deviceSerial: data.deviceSerial,
      channelNo: data.channelNo,
      fileUrl: data.fileUrl,
    });

    broadcast.eventEmitter.emit('voiceSent', {
      eventType: 'voiceSent',
      code: 0,
      data: result,
      msg: '默认语音下发成功',
    });
  } catch (error) {
    broadcast.eventEmitter.emit('voiceSendError', {
      eventType: 'voiceSendError',
      code: -1,
      msg: error.message,
      error,
    });
  }
});

API

构造函数

new Broadcast(options: BroadcastOptions)

方法

  • open() - 打开云广播界面
  • close() - 关闭云广播界面
  • destroy() - 销毁实例
  • on(event, callback) - 监听事件
  • off(event, callback) - 移除事件监听
  • updateOptions(options) - 更新配置

请求事件(上层需要监听)

  • requestQueryVoiceList - 请求查询语音列表
  • requestSendVoiceOnce - 请求下发临时语音
  • requestSendVoice - 请求下发默认语音

结果事件(上层需要触发)

  • voiceListLoaded - 语音列表加载成功
  • voiceListError - 语音列表加载失败
  • voiceSent - 语音下发成功
  • voiceSendError - 语音下发失败

对外事件(应用层可监听)

  • open - 界面打开
  • close - 界面关闭
  • recordStart - 开始录音
  • recordStop - 停止录音
  • recordComplete - 录音完成
  • recordError - 录音错误
  • error - 通用错误

License

Copyright © Ezviz-OpenBiz