Skip to content

armgit / Piik

Public Imported from GitHub
0

Free, open-source screen sharing for private live streams with friends. Watch together in a browser or self-host Piik. 免费开源的私密屏幕共享,支持游戏直播、一起看电影与自部署。

1.4 KB
Raw Blame
import type { ComponentProps } from "react";
import { MicrophoneSettings } from "./MicrophoneSettings";
import { SwitchItem } from "./primitives";
import { useCopy } from "../../ui/copy";
import { Glyph } from "../../ui/icons";

export type ShareMicrophoneSettingsProps = Omit<ComponentProps<typeof MicrophoneSettings>, "host"> & {
  available: boolean;
  roomMicrophone?: boolean;
  onEnabled: (enabled: boolean) => void;
};

// Capture and permission lifetimes stay with the sharing owner.
export function ShareMicrophoneSettings({ available, enabled, disabled, roomMicrophone, onEnabled, ...settings }: ShareMicrophoneSettingsProps) {
  const { t, vis } = useCopy();
  return <div className="lr-door-group lr-audio-settings">
    <SwitchItem checked={enabled} label={t("host.commentary.include")} icon="microphone"
      hint={enabled ? "hint-microphone-off" : "hint-microphone-on"}
      note={t(!available ? "host.commentary.unavailable" : enabled && roomMicrophone ? "host.commentary.duplicate" : "host.commentary.description")}
      disabled={!available || disabled} onChange={onEnabled} />
    {enabled && roomMicrophone ? <small role="status">
      {vis ? <><Glyph name="microphone" size={14} /> ×2<span className="visually-hidden">{t("host.commentary.duplicate")}</span></> : t("host.commentary.duplicate")}
    </small> : null}
    {enabled ? <MicrophoneSettings {...settings} host enabled={enabled} disabled={!available || disabled} /> : null}
  </div>;
}