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

@ray-js/lock-video-player

v0.0.2

Published

门锁实时视频播放组件

Readme

English | 简体中文

@ray-js/lock-video-player

latest download

Real-time IPC video player for smart lock panels. Exposes talk, recording, snapshot, voice-effect, and full-screen APIs via ref.

Installation

npm install @ray-js/lock-video-player
# or
yarn add @ray-js/lock-video-player

Dependencies

| Package | Notes | | ------------------------------------------------ | -------------------------------------------- | | @ray-js/ray | peerDependency — install in your app | | @ray-js/components | dependency — provides the native IpcPlayer | | @ray-js/panel-sdk | dependency — i18n | | ahooks, use-immer, immer, lodash, clsx | dependencies — installed with the package |

For camera rotation in lock panels, optionally install @ray-js/lock-sdk (see Example).

Quick start

import React, { useRef } from 'react';
import LockVideoPlayer, { type ILockVideoPlayerRef } from '@ray-js/lock-video-player';

export default function VideoPage() {
  const playerRef = useRef<ILockVideoPlayerRef>(null);

  return (
    <LockVideoPlayer
      ref={playerRef}
      devId="your-device-id"
      className="video-area"
      rotateZ={0}
      awakeStatus
      reConnect
      onCtx={ctx => {
        console.log('ipc ctx', ctx);
      }}
      onChangeStreamStatus={data => {
        console.log('stream status', data);
      }}
    />
  );
}

Props

Besides the table below, most props of the vendored player core are forwarded (e.g. awakeStatus, reConnect, scalable). See src/ipc-player/typings/index.d.ts for the full list.

| Prop | Type | Default | Description | | ---------------------- | ---------------------------------------------------------------- | ------------ | ------------------------- | | devId | string | required | Device ID | | className | string | - | Root class name | | style | CSSProperties | - | Root inline style | | onlineStatus | boolean | true | Whether device is online | | privateState | boolean | false | Privacy mode | | defaultMute | boolean | false | Mute by default | | clarity | 'normal' \| 'hd' \| 'ss' \| 'ud' \| 'ssp' \| 'auto' \| 'audio' | 'hd' | Stream clarity | | rotateZ | number | 0 | Video rotation (degrees) | | objectFit | 'contain' \| 'fillCrop' | 'contain' | Object fit mode | | brandColor | string | '#FF592A' | Brand color | | onChangeStreamStatus | (data: any) => void | - | Stream status callback | | onCtx | (ctx: ILockVideoPlayerCtx) => void | - | Underlying player context |

Ref API

Call methods on ref after the player is mounted (or after onCtx fires).

startTalk / stopTalk

Two-way audio. startTalk requests scope.record first.

playerRef.current?.startTalk({
  success: () => setIsTalking(true),
  fail: () => showToast({ title: 'start talk failed' }),
});

playerRef.current?.stopTalk({
  success: () => setIsTalking(false),
  fail: () => showToast({ title: 'stop talk failed' }),
});

startRecord / stopRecord

Screen recording. startRecord requests scope.writePhotosAlbum first.

| Param | Type | Default | Description | | ------------------------------- | ------------------ | ------- | ----------------------------------- | | saveToAlbum | 0 \| 1 | 0 | 0 = system album, 1 = IPC album | | rotate | 0 \| 1 \| 2 \| 3 | - | Rotation | | success / fail / complete | function | - | Callbacks |

snapshot

Takes a snapshot. Requests scope.writePhotosAlbum first. When saveToAlbum is 0, saves to the system album via saveImageToPhotosAlbum after capture.

success may receive tempImagePath or filePath.

changeVoiceEffect

Calls ipc.enableVoiceEffect using the component devId.

| effectType | Effect | | ------------ | ---------- | | 0 | Original | | 1 | Young male | | 2 | Uncle | | 3 | Robot | | 4 | Loli |

playerRef.current?.changeVoiceEffect({
  effectType: 0,
  success: () => showToast({ title: 'voice effect updated' }),
  fail: () => showToast({ title: 'voice effect failed' }),
});

setPageOrientation

Set the page orientation (landscape / portrait). pageOrientation defaults to 'landscape'. Wraps Ray's setPageOrientation; the player layout and the built-in back button adapt automatically via onResize.

| Param | Type | Default | Description | | ------------------------------- | --------------------------- | ------------- | ------------------ | | pageOrientation | 'portrait' \| 'landscape' | 'landscape' | Target orientation | | success / fail / complete | function | - | Callbacks |

// enter landscape (full screen)
playerRef.current?.setPageOrientation();

// back to portrait
playerRef.current?.setPageOrientation({
  pageOrientation: 'portrait',
  success: () => showToast({ title: 'back to portrait' }),
  fail: () => showToast({ title: 'orientation change failed' }),
});

onCtx & retry

onCtx provides the underlying player context (retry, startTalk, stopRecord, etc.). Use retry() when the stream fails to connect:

const ipcCtxRef = useRef<ILockVideoPlayerCtx | null>(null);

<LockVideoPlayer
  devId={deviceId}
  onCtx={ctx => {
    ipcCtxRef.current = ctx;
  }}
/>;

useEffect(() => {
  const timer = setTimeout(() => ipcCtxRef.current?.retry?.(), 800);
  return () => clearTimeout(timer);
}, [connected]);

Permissions

| Feature | Scope | | ------------------------- | ------------------------ | | startTalk | scope.record | | startRecord, snapshot | scope.writePhotosAlbum |

Authorization is handled inside the component. Denied permission triggers the method fail callback.

Callback pattern

All ref methods support success, fail, and complete (Ray miniapp style). Recommended:

  • Update UI in success (e.g. talking / recording state)
  • Show errors in fail; avoid optimistic UI updates on click

Types

import LockVideoPlayer, {
  type IProps,
  type ILockVideoPlayerRef,
  type ILockVideoPlayerCtx,
} from '@ray-js/lock-video-player';

Full example

See the example/ app for:

  • deviceId from route query → devId
  • MQTT doorbell → open live view
  • Talk / original voice / record / snapshot
  • Enter / exit landscape (setPageOrientation)
  • onCtx + retry
yarn
yarn start:tuya
yarn start:wechat
yarn start:web

Develop the component

yarn
yarn dev
yarn build

License

MIT