mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-03 09:52:50 +08:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d299343835 | ||
|
|
10ae24a99f |
No files matched your search
+31
-8
@@ -2588,17 +2588,18 @@ function SegmentedChoice<T extends string | number>({
|
||||
}
|
||||
|
||||
function StreamSettingsDialog({
|
||||
defaultName,
|
||||
ownName,
|
||||
onStart,
|
||||
onCancel,
|
||||
}: {
|
||||
defaultName: string;
|
||||
ownName: string;
|
||||
onStart: (options: StreamPublishOptions) => void;
|
||||
onCancel: () => void;
|
||||
}) {
|
||||
const t = useT();
|
||||
const backdrop = useBackdropDismiss(onCancel);
|
||||
const [preset, setPreset] = useState<string | null>("720");
|
||||
const [source, setSource] = useState<"display" | "camera">("display");
|
||||
const [audio, setAudio] = useState(true);
|
||||
const [accessibility, setAccessibility] = useState<number>(StreamAccess.PUBLIC);
|
||||
const [advanced, setAdvanced] = useState(false);
|
||||
@@ -2644,6 +2645,18 @@ function StreamSettingsDialog({
|
||||
<p className="ts-alpha-note">{t("publish.alphaNote")}</p>
|
||||
<h4 className="ts-stream-settings-section">{t("publish.dialog.basic")}</h4>
|
||||
|
||||
<div className="ts-stream-settings-row">
|
||||
<span>{t("publish.kind")}</span>
|
||||
<SegmentedChoice
|
||||
value={source}
|
||||
onChange={setSource}
|
||||
options={[
|
||||
{ value: "display", label: `🖥️ ${t("publish.kind.display")}` },
|
||||
{ value: "camera", label: `📷 ${t("publish.camera")}` },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="ts-stream-settings-row">
|
||||
<span>{t("publish.preset")}</span>
|
||||
<SegmentedChoice
|
||||
@@ -2659,8 +2672,16 @@ function StreamSettingsDialog({
|
||||
|
||||
<div className="ts-stream-settings-row">
|
||||
<span>{t("publish.audio")}</span>
|
||||
<label className="ts-stream-settings-toggle">
|
||||
<input type="checkbox" checked={audio} onChange={(e) => setAudio(e.target.checked)} />
|
||||
<label
|
||||
className="ts-stream-settings-toggle"
|
||||
title={source === "camera" ? t("publish.audio.cameraHint") : undefined}
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={audio && source === "display"}
|
||||
disabled={source === "camera"}
|
||||
onChange={(e) => setAudio(e.target.checked)}
|
||||
/>
|
||||
<span />
|
||||
</label>
|
||||
</div>
|
||||
@@ -2731,7 +2752,7 @@ function StreamSettingsDialog({
|
||||
<SegmentedChoice
|
||||
value={audioBitrateKbps}
|
||||
onChange={custom(setAudioBitrateKbps)}
|
||||
disabled={!audio}
|
||||
disabled={!audio || source === "camera"}
|
||||
options={AUDIO_BITRATE_CHOICES.map((v) => ({ value: v, label: String(v) }))}
|
||||
/>
|
||||
</div>
|
||||
@@ -2787,8 +2808,9 @@ function StreamSettingsDialog({
|
||||
className="ts-stream-settings-go"
|
||||
onClick={() =>
|
||||
onStart({
|
||||
name: defaultName,
|
||||
audio,
|
||||
name: `${ownName} - ${t(source === "camera" ? "publish.camera" : "publish.screen")}`,
|
||||
source,
|
||||
audio: audio && source === "display",
|
||||
accessibility,
|
||||
mode,
|
||||
viewerLimit,
|
||||
@@ -6448,6 +6470,7 @@ function AnwendungPanel({
|
||||
<option value="zh-CN">{t("app.language.zh-CN")}</option>
|
||||
<option value="fa">{t("app.language.fa")}</option>
|
||||
<option value="cs-CZ">{t("app.language.cs-CZ")}</option>
|
||||
<option value="ru">{t("app.language.ru")}</option>
|
||||
</select>
|
||||
</label>
|
||||
<p className="ts-options-hint">
|
||||
@@ -13975,7 +13998,7 @@ function AppInner() {
|
||||
|
||||
{streamSettingsOpen && (
|
||||
<StreamSettingsDialog
|
||||
defaultName={`${ownClient?.name ?? "WebSpeak3"} - ${t("publish.screen")}`}
|
||||
ownName={ownClient?.name ?? "WebSpeak3"}
|
||||
onStart={handleStartPublishing}
|
||||
onCancel={() => setStreamSettingsOpen(false)}
|
||||
/>
|
||||
|
||||
+5
-2
@@ -5,8 +5,9 @@ import en from "./locales/en.json";
|
||||
import zhCN from "./locales/zh-CN.json";
|
||||
import fa from "./locales/fa.json";
|
||||
import csCZ from "./locales/cs-CZ.json";
|
||||
import ru from "./locales/ru.json";
|
||||
|
||||
export type Lang = "de" | "en" | "zh-CN" | "fa" | "cs-CZ";
|
||||
export type Lang = "de" | "en" | "zh-CN" | "fa" | "cs-CZ" | "ru";
|
||||
const RTL_LANGS = new Set<Lang>(["fa"]);
|
||||
export type LangPref = "auto" | Lang;
|
||||
|
||||
@@ -24,6 +25,7 @@ const translations: Record<Lang, Record<string, string>> = {
|
||||
"zh-CN": zhCN,
|
||||
fa,
|
||||
"cs-CZ": csCZ,
|
||||
ru,
|
||||
};
|
||||
|
||||
function detectSystemLang(): Lang {
|
||||
@@ -32,6 +34,7 @@ function detectSystemLang(): Lang {
|
||||
if (normalized.startsWith("zh")) return "zh-CN";
|
||||
if (normalized.startsWith("fa")) return "fa";
|
||||
if (normalized.startsWith("cs")) return "cs-CZ";
|
||||
if (normalized.startsWith("ru")) return "ru";
|
||||
return normalized.startsWith("de") ? "de" : "en";
|
||||
}
|
||||
|
||||
@@ -41,7 +44,7 @@ export function resolveLang(pref: LangPref): Lang {
|
||||
|
||||
export function loadLangPref(): LangPref {
|
||||
const raw = localStorage.getItem(LANGUAGE_KEY);
|
||||
return raw === "de" || raw === "en" || raw === "zh-CN" || raw === "fa" || raw === "cs-CZ" || raw === "auto" ? raw : "auto";
|
||||
return raw === "de" || raw === "en" || raw === "zh-CN" || raw === "fa" || raw === "cs-CZ" || raw === "ru" || raw === "auto" ? raw : "auto";
|
||||
}
|
||||
|
||||
export function saveLangPref(pref: LangPref) {
|
||||
|
||||
@@ -407,6 +407,7 @@
|
||||
"app.language.zh-CN": "简体中文",
|
||||
"app.language.fa": "فارسی (بتا)",
|
||||
"app.language.cs-CZ": "Čeština",
|
||||
"app.language.ru": "Русский (бета)",
|
||||
"app.language.helpTranslate": "Missing your language or spotted wrong translation? Help out on Weblate →",
|
||||
"app.serverBanner": "Zobrazovat bannery serveru",
|
||||
"app.serverBanner.hint": "Banner se načítá přímo z adresy nastavené administrátorem serveru a tento hostitel vidí vaši IP adresu.",
|
||||
@@ -489,10 +490,13 @@
|
||||
"publish.alphaTitle": "Alfa – nestabilní, může se kdykoli změnit nebo přestat fungovat",
|
||||
"publish.demoUnavailable": "Streamování není v demu dostupné – vyžaduje skutečný server TeamSpeak 6.",
|
||||
"publish.alphaNote": "Streamování je ve fázi alfa. Používá nezdokumentovaný protokol Stream/Call služby TeamSpeak 6, takže připojení, kvalita obrazu i práce s diváky mohou selhat nebo se bez upozornění změnit. Není určeno pro produkční použití.",
|
||||
"publish.start": "Sdílet obrazovku",
|
||||
"publish.start": "Sdílet obrazovku nebo kameru",
|
||||
"publish.stop": "Zastavit sdílení",
|
||||
"publish.title": "Vaše vysílání",
|
||||
"publish.screen": "Obrazovka",
|
||||
"publish.camera": "Kamera",
|
||||
"publish.kind": "Sdílet",
|
||||
"publish.kind.display": "Obrazovka / okno",
|
||||
"publish.starting": "Spouštění…",
|
||||
"publish.viewers": "Sleduje {count} diváků",
|
||||
"publish.request.allow": "Povolit",
|
||||
@@ -507,6 +511,7 @@
|
||||
"publish.preset": "Předvolba",
|
||||
"publish.preset.presentation": "Prezentace",
|
||||
"publish.audio": "Snímat zvuk",
|
||||
"publish.audio.cameraHint": "U kamery jde tvůj zvuk jako obvykle přes mikrofon.",
|
||||
"publish.privacy": "Soukromí",
|
||||
"publish.privacy.public": "Veřejné",
|
||||
"publish.privacy.contacts": "Kontakty",
|
||||
|
||||
@@ -407,6 +407,7 @@
|
||||
"app.language.zh-CN": "简体中文",
|
||||
"app.language.fa": "فارسی (بتا)",
|
||||
"app.language.cs-CZ": "Čeština",
|
||||
"app.language.ru": "Русский (бета)",
|
||||
"app.language.helpTranslate": "Fehlt deine Sprache oder eine Übersetzung ist ungenau? Hilf mit auf Weblate →",
|
||||
"app.serverBanner": "Server-Banner anzeigen",
|
||||
"app.serverBanner.hint": "Das Banner lädt direkt von der Adresse, die der Serverbetreiber eingetragen hat. Dieser Host sieht dabei deine IP-Adresse.",
|
||||
@@ -489,10 +490,13 @@
|
||||
"publish.alphaTitle": "Alpha – instabil, kann sich jederzeit ändern oder brechen",
|
||||
"publish.demoUnavailable": "Übertragen ist in der Demo nicht verfügbar – dafür braucht es einen echten TeamSpeak-6-Server.",
|
||||
"publish.alphaNote": "Streaming ist Alpha. Es spricht TeamSpeak 6s Stream/Call-Protokoll, das nicht dokumentiert ist – Verbindungsaufbau, Bildqualität und Zuschauerverwaltung können fehlschlagen oder sich ohne Vorankündigung ändern. Nicht für produktive Nutzung gedacht.",
|
||||
"publish.start": "Bildschirm übertragen",
|
||||
"publish.start": "Bildschirm oder Kamera übertragen",
|
||||
"publish.stop": "Übertragung beenden",
|
||||
"publish.title": "Deine Übertragung",
|
||||
"publish.screen": "Bildschirm",
|
||||
"publish.camera": "Kamera",
|
||||
"publish.kind": "Übertragen",
|
||||
"publish.kind.display": "Bildschirm / Fenster",
|
||||
"publish.starting": "Wird gestartet…",
|
||||
"publish.viewers": "{count} Zuschauer",
|
||||
"publish.request.allow": "Zulassen",
|
||||
@@ -507,6 +511,7 @@
|
||||
"publish.preset": "Voreinstellung",
|
||||
"publish.preset.presentation": "Präsentation",
|
||||
"publish.audio": "Audio aufnehmen",
|
||||
"publish.audio.cameraHint": "Bei der Kamera läuft dein Ton wie gewohnt übers Mikrofon.",
|
||||
"publish.privacy": "Privatsphäre",
|
||||
"publish.privacy.public": "Öffentlich",
|
||||
"publish.privacy.contacts": "Kontakte",
|
||||
|
||||
@@ -407,6 +407,7 @@
|
||||
"app.language.zh-CN": "简体中文",
|
||||
"app.language.fa": "فارسی (بتا)",
|
||||
"app.language.cs-CZ": "Čeština",
|
||||
"app.language.ru": "Русский (бета)",
|
||||
"app.language.helpTranslate": "Missing your language or spotted a wrong translation? Help out on Weblate →",
|
||||
"app.serverBanner": "Show server banners",
|
||||
"app.serverBanner.hint": "The banner loads straight from the address the server admin set, and that host sees your IP address.",
|
||||
@@ -489,10 +490,13 @@
|
||||
"publish.alphaTitle": "Alpha - unstable, may change or break at any time",
|
||||
"publish.demoUnavailable": "Streaming is not available in the demo - it needs a real TeamSpeak 6 server.",
|
||||
"publish.alphaNote": "Streaming is alpha. It speaks TeamSpeak 6's undocumented Stream/Call protocol, so connecting, picture quality and viewer handling can fail or change without notice. Not meant for production use.",
|
||||
"publish.start": "Share your screen",
|
||||
"publish.start": "Share your screen or camera",
|
||||
"publish.stop": "Stop sharing",
|
||||
"publish.title": "Your broadcast",
|
||||
"publish.screen": "Screen",
|
||||
"publish.camera": "Camera",
|
||||
"publish.kind": "Share",
|
||||
"publish.kind.display": "Screen / window",
|
||||
"publish.starting": "Starting…",
|
||||
"publish.viewers": "{count} watching",
|
||||
"publish.request.allow": "Allow",
|
||||
@@ -507,6 +511,7 @@
|
||||
"publish.preset": "Preset",
|
||||
"publish.preset.presentation": "Presentation",
|
||||
"publish.audio": "Capture audio",
|
||||
"publish.audio.cameraHint": "With the camera, your sound goes out through your microphone as usual.",
|
||||
"publish.privacy": "Privacy",
|
||||
"publish.privacy.public": "Public",
|
||||
"publish.privacy.contacts": "Contacts",
|
||||
|
||||
@@ -407,6 +407,7 @@
|
||||
"app.language.zh-CN": "简体中文",
|
||||
"app.language.fa": "فارسی (بتا)",
|
||||
"app.language.cs-CZ": "Čeština",
|
||||
"app.language.ru": "Русский (бета)",
|
||||
"app.language.helpTranslate": "زبان شما موجود نیست یا ترجمهای اشتباه دیدید؟ در Weblate کمک کنید →",
|
||||
"app.serverBanner": "نمایش بنر سرور",
|
||||
"app.serverBanner.hint": "بنر مستقیماً از نشانیای بارگیری میشود که مدیر سرور تعیین کرده است و آن میزبان نشانی IP شما را میبیند.",
|
||||
@@ -488,10 +489,13 @@
|
||||
"publish.alphaTitle": "آلفا - ناپایدار، ممکن است هر زمان تغییر کند یا از کار بیفتد",
|
||||
"publish.demoUnavailable": "پخش زنده در حالت دمو در دسترس نیست - به یک سرور واقعی TeamSpeak 6 نیاز دارد.",
|
||||
"publish.alphaNote": "پخش زنده در مرحله آلفا است. این ویژگی از پروتکل مستندنشده Stream/Call در TeamSpeak 6 استفاده میکند، بنابراین اتصال، کیفیت تصویر و مدیریت بینندگان ممکن است بدون اطلاع قبلی دچار خطا شوند یا تغییر کنند. برای استفاده تولیدی مناسب نیست.",
|
||||
"publish.start": "اشتراکگذاری صفحه",
|
||||
"publish.start": "اشتراکگذاری صفحه یا دوربین",
|
||||
"publish.stop": "توقف اشتراکگذاری",
|
||||
"publish.title": "پخش زنده تو",
|
||||
"publish.screen": "صفحه نمایش",
|
||||
"publish.camera": "دوربین",
|
||||
"publish.kind": "اشتراکگذاری",
|
||||
"publish.kind.display": "صفحه / پنجره",
|
||||
"publish.starting": "در حال شروع…",
|
||||
"publish.viewers": "{count} بیننده",
|
||||
"publish.request.allow": "اجازه دادن",
|
||||
@@ -506,6 +510,7 @@
|
||||
"publish.preset": "پیشتنظیم",
|
||||
"publish.preset.presentation": "ارائه",
|
||||
"publish.audio": "ضبط صدا",
|
||||
"publish.audio.cameraHint": "با دوربین، صدای شما مثل همیشه از طریق میکروفون ارسال میشود.",
|
||||
"publish.privacy": "حریم خصوصی",
|
||||
"publish.privacy.public": "عمومی",
|
||||
"publish.privacy.contacts": "مخاطبین",
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -301,6 +301,7 @@
|
||||
"app.language.zh-CN": "简体中文",
|
||||
"app.language.fa": "فارسی (بتا)",
|
||||
"app.language.cs-CZ": "Čeština",
|
||||
"app.language.ru": "Русский (бета)",
|
||||
"app.language.helpTranslate": "没有你的语言,或发现翻译有误?欢迎到 Weblate 参与改进 →",
|
||||
"app.serverBanner": "显示服务器横幅",
|
||||
"app.serverBanner.hint": "横幅直接从服务器管理员设置的地址加载,该主机会看到你的 IP 地址。",
|
||||
@@ -701,10 +702,13 @@
|
||||
"publish.alphaTitle": "内测阶段 —— 不稳定,可能随时变更或失效",
|
||||
"publish.demoUnavailable": "演示模式下无法使用直播功能 —— 需要真实的 TeamSpeak 6 服务器。",
|
||||
"publish.alphaNote": "直播功能处于内测阶段,使用的是 TeamSpeak 6 未公开文档的 Stream/Call 协议,因此连接、画质和观众处理可能会出错或在无预警的情况下发生变化,不建议用于正式场合。",
|
||||
"publish.start": "共享屏幕",
|
||||
"publish.start": "共享屏幕或摄像头",
|
||||
"publish.stop": "停止共享",
|
||||
"publish.title": "你的直播",
|
||||
"publish.screen": "屏幕",
|
||||
"publish.camera": "摄像头",
|
||||
"publish.kind": "共享内容",
|
||||
"publish.kind.display": "屏幕 / 窗口",
|
||||
"publish.starting": "启动中…",
|
||||
"publish.viewers": "{count} 人观看",
|
||||
"publish.request.allow": "允许",
|
||||
@@ -719,6 +723,7 @@
|
||||
"publish.preset": "预设",
|
||||
"publish.preset.presentation": "演示",
|
||||
"publish.audio": "采集音频",
|
||||
"publish.audio.cameraHint": "使用摄像头时,你的声音照常通过麦克风发送。",
|
||||
"publish.privacy": "可见范围",
|
||||
"publish.privacy.public": "公开",
|
||||
"publish.privacy.contacts": "联系人",
|
||||
|
||||
+15
-9
@@ -46,6 +46,8 @@ export const StreamMode = {
|
||||
|
||||
export interface StreamPublishOptions {
|
||||
name: string;
|
||||
/** Screen/window via the browser's picker, or the webcam. */
|
||||
source: "display" | "camera";
|
||||
/** Send the capture's audio track too, when the source has one. */
|
||||
audio: boolean;
|
||||
/** One of StreamAccess. */
|
||||
@@ -112,15 +114,16 @@ export class StreamPublisher {
|
||||
}
|
||||
|
||||
/**
|
||||
* Captures a screen and announces the stream.
|
||||
* Captures a screen or the webcam and announces the stream.
|
||||
*
|
||||
* `getDisplayMedia` is secure-context-only, so this throws on a plain-http
|
||||
* Both capture APIs are secure-context-only, so this fails on a plain-http
|
||||
* origin - the same limitation the microphone already has.
|
||||
*/
|
||||
async start(options: StreamPublishOptions): Promise<void> {
|
||||
if (this.state === "live" || this.state === "starting") return;
|
||||
if (!navigator.mediaDevices?.getDisplayMedia) {
|
||||
this.fail("Screen sharing requires HTTPS (or localhost) - the site is not a secure context.");
|
||||
const camera = options.source === "camera";
|
||||
if (!(camera ? navigator.mediaDevices?.getUserMedia : navigator.mediaDevices?.getDisplayMedia)) {
|
||||
this.fail("Streaming requires HTTPS (or localhost) - the site is not a secure context.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -132,13 +135,15 @@ export class StreamPublisher {
|
||||
if (options.fps > 0) video.frameRate = { ideal: options.fps };
|
||||
|
||||
try {
|
||||
this.media = await navigator.mediaDevices.getDisplayMedia({
|
||||
video: Object.keys(video).length > 0 ? video : true,
|
||||
audio: options.audio,
|
||||
});
|
||||
const constraints = { video: Object.keys(video).length > 0 ? video : true };
|
||||
// A camera's "audio" would be the microphone, which already goes out as
|
||||
// voice - sending it again would only echo.
|
||||
this.media = camera
|
||||
? await navigator.mediaDevices.getUserMedia({ ...constraints, audio: false })
|
||||
: await navigator.mediaDevices.getDisplayMedia({ ...constraints, audio: options.audio });
|
||||
} catch (err) {
|
||||
this.setState("idle");
|
||||
this.fail(`Could not capture the screen: ${describe(err)}`);
|
||||
this.fail(`Could not capture the ${camera ? "camera" : "screen"}: ${describe(err)}`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -423,6 +428,7 @@ export class StreamPublisher {
|
||||
* advance. A browser tab has no TS6 equivalent and reads closest to a window.
|
||||
*/
|
||||
private detectSourceType(): number {
|
||||
if (this.options?.source === "camera") return StreamSource.CAMERA;
|
||||
const surface = this.media?.getVideoTracks()[0]?.getSettings().displaySurface;
|
||||
return surface === "monitor" ? StreamSource.SCREEN : StreamSource.WINDOW;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user