feat(release): v0.0.15 - 100% player volume boost script, Android TV auto-update APK downloader & install modal
This commit is contained in:
parent
ef8b7037c1
commit
a80f1c7e4e
7 changed files with 407 additions and 105 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "has",
|
"name": "has",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.14",
|
"version": "0.0.15",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "has"
|
name = "has"
|
||||||
version = "0.0.14"
|
version = "0.0.15"
|
||||||
description = "has"
|
description = "has"
|
||||||
authors = ["autli"]
|
authors = ["autli"]
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||||
|
|
||||||
<!-- AndroidTV support -->
|
<!-- AndroidTV support -->
|
||||||
<uses-feature android:name="android.software.leanback" android:required="false" />
|
<uses-feature android:name="android.software.leanback" android:required="false" />
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "has",
|
"productName": "has",
|
||||||
"version": "0.0.14",
|
"version": "0.0.15",
|
||||||
"identifier": "com.has.tauri-app",
|
"identifier": "com.has.tauri-app",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "npm run dev",
|
"beforeDevCommand": "npm run dev",
|
||||||
|
|
|
||||||
46
src/App.css
46
src/App.css
|
|
@ -443,6 +443,52 @@ svg {
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TV Auto-update Toggle Chip & Countdown */
|
||||||
|
.has-tv-updater-autotoggle {
|
||||||
|
margin-top: 20px;
|
||||||
|
background: rgba(255, 255, 255, 0.06);
|
||||||
|
border: 1px dashed rgba(255, 255, 255, 0.25);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 10px 20px;
|
||||||
|
font-size: 13px;
|
||||||
|
color: #94a3b8;
|
||||||
|
cursor: pointer;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.has-tv-updater-autotoggle.active {
|
||||||
|
background: rgba(16, 185, 129, 0.15);
|
||||||
|
border-color: rgba(16, 185, 129, 0.5);
|
||||||
|
color: #6ee7b7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.has-tv-updater-autotoggle.focused {
|
||||||
|
transform: scale(1.05);
|
||||||
|
border-color: #ffffff !important;
|
||||||
|
box-shadow: 0 0 0 3px #ffffff, 0 0 25px rgba(99, 102, 241, 0.7) !important;
|
||||||
|
color: #ffffff !important;
|
||||||
|
background: rgba(99, 102, 241, 0.35);
|
||||||
|
}
|
||||||
|
|
||||||
|
.has-tv-updater-countdown {
|
||||||
|
margin-bottom: 14px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #38bdf8;
|
||||||
|
font-weight: 700;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 6px 14px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: rgba(56, 189, 248, 0.12);
|
||||||
|
border: 1px solid rgba(56, 189, 248, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
/* TV Progress View */
|
/* TV Progress View */
|
||||||
.has-tv-updater-progress-container {
|
.has-tv-updater-progress-container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
|
||||||
|
|
@ -88,16 +88,24 @@ const isNewerSemver = (remote: string, current: string): boolean => {
|
||||||
|
|
||||||
export function UpdaterBanner({ isTvEnvironment }: UpdaterBannerProps = {}) {
|
export function UpdaterBanner({ isTvEnvironment }: UpdaterBannerProps = {}) {
|
||||||
const [isTv, setIsTv] = useState<boolean>(() => isTvEnvironment ?? detectTvEnvironment());
|
const [isTv, setIsTv] = useState<boolean>(() => isTvEnvironment ?? detectTvEnvironment());
|
||||||
const [currentAppVersion, setCurrentAppVersion] = useState<string>("0.0.14");
|
const [currentAppVersion, setCurrentAppVersion] = useState<string>("0.0.15");
|
||||||
const [updateAvailable, setUpdateAvailable] = useState(false);
|
const [updateAvailable, setUpdateAvailable] = useState(false);
|
||||||
const [updateInfo, setUpdateInfo] = useState<UpdateInfo | null>(null);
|
const [updateInfo, setUpdateInfo] = useState<UpdateInfo | null>(null);
|
||||||
const [downloading, setDownloading] = useState(false);
|
const [downloading, setDownloading] = useState(false);
|
||||||
const [progress, setProgress] = useState(0);
|
const [progress, setProgress] = useState(0);
|
||||||
|
const [statusText, setStatusText] = useState<string>("Загрузка обновления...");
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
const [dismissed, setDismissed] = useState(false);
|
const [dismissed, setDismissed] = useState(false);
|
||||||
|
|
||||||
// TV remote navigation: "update" | "skip" | "exit"
|
// Auto-update preferences for Android TV
|
||||||
const [tvFocusedBtn, setTvFocusedBtn] = useState<"update" | "skip" | "exit">("update");
|
const [autoUpdateTv, setAutoUpdateTv] = useState<boolean>(() => {
|
||||||
|
if (typeof window === "undefined") return false;
|
||||||
|
return localStorage.getItem("has_auto_update_tv") === "true";
|
||||||
|
});
|
||||||
|
const [autoCountdown, setAutoCountdown] = useState<number | null>(null);
|
||||||
|
|
||||||
|
// TV remote navigation: "update" | "skip" | "exit" | "autotoggle"
|
||||||
|
const [tvFocusedBtn, setTvFocusedBtn] = useState<"update" | "skip" | "exit" | "autotoggle">("update");
|
||||||
const updateBtnRef = useRef<HTMLButtonElement | null>(null);
|
const updateBtnRef = useRef<HTMLButtonElement | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -270,16 +278,16 @@ export function UpdaterBanner({ isTvEnvironment }: UpdaterBannerProps = {}) {
|
||||||
case "android_tv":
|
case "android_tv":
|
||||||
return {
|
return {
|
||||||
badge: "📺 Android TV",
|
badge: "📺 Android TV",
|
||||||
title: `Доступно обновление для Android TV (v${version})`,
|
title: "Хотите ли вы обновить приложение HAS?",
|
||||||
desc: "Специальная сборка для телевизоров и ТВ-приставок с поддержкой пульта ДУ (D-Pad), Leanback-интерфейса и плавного воспроизведения.",
|
desc: "Доступна новая оптимизированная версия для телевизоров и ТВ-приставок с поддержкой пульта ДУ, балансеров видео и повышенной стабильностью.",
|
||||||
btnLabel: "🚀 Обновить APK для ТВ",
|
btnLabel: "🚀 Да, обновить сейчас",
|
||||||
icon: "📺",
|
icon: "📺",
|
||||||
};
|
};
|
||||||
case "android_mobile":
|
case "android_mobile":
|
||||||
return {
|
return {
|
||||||
badge: "📱 Android",
|
badge: "📱 Android",
|
||||||
title: `Доступно обновление для Android (v${version})`,
|
title: "Хотите ли вы обновить приложение HAS?",
|
||||||
desc: "Новая версия приложения для мобильных телефонов и планшетов на Android.",
|
desc: "Новая версия приложения для мобильных устройств на Android.",
|
||||||
btnLabel: "🚀 Скачать APK для Android",
|
btnLabel: "🚀 Скачать APK для Android",
|
||||||
icon: "📱",
|
icon: "📱",
|
||||||
};
|
};
|
||||||
|
|
@ -313,7 +321,7 @@ export function UpdaterBanner({ isTvEnvironment }: UpdaterBannerProps = {}) {
|
||||||
const platformInfo = getPlatformDetails();
|
const platformInfo = getPlatformDetails();
|
||||||
|
|
||||||
// Smart download target selector
|
// Smart download target selector
|
||||||
const resolveTargetUrl = (): string => {
|
const resolveTargetUrl = useCallback((): string => {
|
||||||
if (!updateInfo) return "https://github.com/autli5/has/releases/latest";
|
if (!updateInfo) return "https://github.com/autli5/has/releases/latest";
|
||||||
switch (clientPlatform) {
|
switch (clientPlatform) {
|
||||||
case "windows":
|
case "windows":
|
||||||
|
|
@ -329,12 +337,29 @@ export function UpdaterBanner({ isTvEnvironment }: UpdaterBannerProps = {}) {
|
||||||
default:
|
default:
|
||||||
return updateInfo.downloadUrl || "https://github.com/autli5/has/releases/latest";
|
return updateInfo.downloadUrl || "https://github.com/autli5/has/releases/latest";
|
||||||
}
|
}
|
||||||
};
|
}, [clientPlatform, updateInfo]);
|
||||||
|
|
||||||
|
const cancelAutoCountdown = useCallback(() => {
|
||||||
|
setAutoCountdown(null);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const toggleAutoUpdate = useCallback(() => {
|
||||||
|
setAutoUpdateTv((prev) => {
|
||||||
|
const next = !prev;
|
||||||
|
try {
|
||||||
|
localStorage.setItem("has_auto_update_tv", next ? "true" : "false");
|
||||||
|
} catch {}
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
cancelAutoCountdown();
|
||||||
|
}, [cancelAutoCountdown]);
|
||||||
|
|
||||||
const handleInstall = useCallback(async () => {
|
const handleInstall = useCallback(async () => {
|
||||||
|
cancelAutoCountdown();
|
||||||
setDownloading(true);
|
setDownloading(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
setProgress(0);
|
setProgress(0);
|
||||||
|
setStatusText("Подготовка к установке обновления...");
|
||||||
|
|
||||||
// Desktop Windows / macOS / Linux Tauri updater plugin
|
// Desktop Windows / macOS / Linux Tauri updater plugin
|
||||||
if (typeof window !== "undefined" && "__TAURI_INTERNALS__" in window && !isTv) {
|
if (typeof window !== "undefined" && "__TAURI_INTERNALS__" in window && !isTv) {
|
||||||
|
|
@ -346,6 +371,7 @@ export function UpdaterBanner({ isTvEnvironment }: UpdaterBannerProps = {}) {
|
||||||
if (update?.available) {
|
if (update?.available) {
|
||||||
let downloaded = 0;
|
let downloaded = 0;
|
||||||
let total = 0;
|
let total = 0;
|
||||||
|
setStatusText("Загрузка обновления...");
|
||||||
|
|
||||||
await update.downloadAndInstall((event: any) => {
|
await update.downloadAndInstall((event: any) => {
|
||||||
if (event.event === "Started") {
|
if (event.event === "Started") {
|
||||||
|
|
@ -354,9 +380,12 @@ export function UpdaterBanner({ isTvEnvironment }: UpdaterBannerProps = {}) {
|
||||||
downloaded += event.data?.chunkLength ?? 0;
|
downloaded += event.data?.chunkLength ?? 0;
|
||||||
} else if (event.event === "Finished") {
|
} else if (event.event === "Finished") {
|
||||||
setProgress(100);
|
setProgress(100);
|
||||||
|
setStatusText("Перезапуск программы...");
|
||||||
}
|
}
|
||||||
if (total > 0) {
|
if (total > 0) {
|
||||||
setProgress(Math.round((downloaded / total) * 100));
|
const p = Math.round((downloaded / total) * 100);
|
||||||
|
setProgress(p);
|
||||||
|
setStatusText(`Загрузка: ${p}%`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -368,30 +397,82 @@ export function UpdaterBanner({ isTvEnvironment }: UpdaterBannerProps = {}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Direct download and open target platform installer/APK
|
// Android TV / Mobile / Direct APK Download & Installation
|
||||||
const targetUrl = resolveTargetUrl();
|
const targetUrl = resolveTargetUrl();
|
||||||
|
setStatusText("Подключение к серверу загрузки APK...");
|
||||||
|
|
||||||
let p = 0;
|
let streamSucceeded = false;
|
||||||
const progressTimer = setInterval(() => {
|
try {
|
||||||
p += 20;
|
const response = await fetch(targetUrl, { mode: "cors" });
|
||||||
if (p >= 100) {
|
if (response.ok && response.body) {
|
||||||
clearInterval(progressTimer);
|
const contentLength = +(response.headers.get("Content-Length") || 0);
|
||||||
setProgress(100);
|
const reader = response.body.getReader();
|
||||||
setTimeout(async () => {
|
let received = 0;
|
||||||
try {
|
const chunks: Uint8Array[] = [];
|
||||||
const { openUrl } = await import("@tauri-apps/plugin-opener");
|
|
||||||
await openUrl(targetUrl);
|
while (true) {
|
||||||
} catch {
|
const { done, value } = await reader.read();
|
||||||
window.open(targetUrl, "_blank");
|
if (done) break;
|
||||||
|
if (value) {
|
||||||
|
chunks.push(value);
|
||||||
|
received += value.length;
|
||||||
|
if (contentLength > 0) {
|
||||||
|
const pct = Math.min(99, Math.round((received / contentLength) * 100));
|
||||||
|
setProgress(pct);
|
||||||
|
setStatusText(`Скачивание APK: ${pct}% (${(received / 1024 / 1024).toFixed(1)} МБ)`);
|
||||||
|
} else {
|
||||||
|
setStatusText(`Скачивание APK: ${(received / 1024 / 1024).toFixed(1)} МБ`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setDismissed(true);
|
}
|
||||||
setDownloading(false);
|
|
||||||
}, 400);
|
setProgress(100);
|
||||||
} else {
|
setStatusText("APK успешно скачан! Запуск установки...");
|
||||||
setProgress(p);
|
streamSucceeded = true;
|
||||||
|
|
||||||
|
const blob = new Blob(chunks as BlobPart[], { type: "application/vnd.android.package-archive" });
|
||||||
|
const blobUrl = URL.createObjectURL(blob);
|
||||||
|
const a = document.createElement("a");
|
||||||
|
a.href = blobUrl;
|
||||||
|
a.download = `has-tv-v${updateInfo?.version || "update"}.apk`;
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
document.body.removeChild(a);
|
||||||
}
|
}
|
||||||
}, 150);
|
} catch {
|
||||||
}, [isTv, clientPlatform, updateInfo]);
|
// Fetch streaming can be restricted by CORS on certain hosts; fallback below
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!streamSucceeded) {
|
||||||
|
let p = 0;
|
||||||
|
await new Promise<void>((resolve) => {
|
||||||
|
const progressTimer = setInterval(() => {
|
||||||
|
p += 20;
|
||||||
|
if (p >= 100) {
|
||||||
|
clearInterval(progressTimer);
|
||||||
|
setProgress(100);
|
||||||
|
setStatusText("Запуск установщика приложения...");
|
||||||
|
resolve();
|
||||||
|
} else {
|
||||||
|
setProgress(p);
|
||||||
|
setStatusText(`Загрузка: ${p}%`);
|
||||||
|
}
|
||||||
|
}, 120);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { openUrl } = await import("@tauri-apps/plugin-opener");
|
||||||
|
await openUrl(targetUrl);
|
||||||
|
} catch {
|
||||||
|
window.open(targetUrl, "_blank");
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
setDismissed(true);
|
||||||
|
setDownloading(false);
|
||||||
|
}, 1800);
|
||||||
|
}, [cancelAutoCountdown, isTv, updateInfo, resolveTargetUrl]);
|
||||||
|
|
||||||
// Clean Exit from TV application
|
// Clean Exit from TV application
|
||||||
const handleExitApp = useCallback(async () => {
|
const handleExitApp = useCallback(async () => {
|
||||||
|
|
@ -403,6 +484,30 @@ export function UpdaterBanner({ isTvEnvironment }: UpdaterBannerProps = {}) {
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// Auto-update countdown for Android TV
|
||||||
|
useEffect(() => {
|
||||||
|
if (!updateAvailable || dismissed || !isTv || downloading) return;
|
||||||
|
if (!autoUpdateTv) {
|
||||||
|
setAutoCountdown(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setAutoCountdown(5);
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
setAutoCountdown((prev) => {
|
||||||
|
if (prev === null) return null;
|
||||||
|
if (prev <= 1) {
|
||||||
|
clearInterval(interval);
|
||||||
|
handleInstall();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return prev - 1;
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
return () => clearInterval(interval);
|
||||||
|
}, [updateAvailable, dismissed, isTv, downloading, autoUpdateTv, handleInstall]);
|
||||||
|
|
||||||
// Strict Remote Control D-Pad Navigation for TV Update Modal
|
// Strict Remote Control D-Pad Navigation for TV Update Modal
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!updateAvailable || dismissed || !isTv || downloading) return;
|
if (!updateAvailable || dismissed || !isTv || downloading) return;
|
||||||
|
|
@ -415,37 +520,49 @@ export function UpdaterBanner({ isTvEnvironment }: UpdaterBannerProps = {}) {
|
||||||
}, 50);
|
}, 50);
|
||||||
|
|
||||||
const handleTvKeyDown = (e: KeyboardEvent) => {
|
const handleTvKeyDown = (e: KeyboardEvent) => {
|
||||||
// Cycle between "update" -> "skip" -> "exit"
|
cancelAutoCountdown();
|
||||||
if (
|
|
||||||
e.key === "ArrowRight" ||
|
// Down: switch to auto-update toggle
|
||||||
e.key === "ArrowDown" ||
|
if (e.key === "ArrowDown" || e.keyCode === 20) {
|
||||||
e.keyCode === 22 ||
|
|
||||||
e.keyCode === 20 ||
|
|
||||||
e.key === "Tab"
|
|
||||||
) {
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setTvFocusedBtn((prev) => {
|
|
||||||
if (prev === "update") return "skip";
|
|
||||||
if (prev === "skip") return "exit";
|
|
||||||
return "update";
|
|
||||||
});
|
|
||||||
playTvBeep(520, 0.025);
|
playTvBeep(520, 0.025);
|
||||||
|
if (tvFocusedBtn !== "autotoggle") {
|
||||||
|
setTvFocusedBtn("autotoggle");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
// Up: switch back from auto-update toggle to update button
|
||||||
e.key === "ArrowLeft" ||
|
if (e.key === "ArrowUp" || e.keyCode === 19) {
|
||||||
e.key === "ArrowUp" ||
|
|
||||||
e.keyCode === 21 ||
|
|
||||||
e.keyCode === 19
|
|
||||||
) {
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
playTvBeep(520, 0.025);
|
||||||
|
if (tvFocusedBtn === "autotoggle") {
|
||||||
|
setTvFocusedBtn("update");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Left: cycle within top button row
|
||||||
|
if (e.key === "ArrowLeft" || e.keyCode === 21) {
|
||||||
|
e.preventDefault();
|
||||||
|
playTvBeep(520, 0.025);
|
||||||
setTvFocusedBtn((prev) => {
|
setTvFocusedBtn((prev) => {
|
||||||
if (prev === "exit") return "skip";
|
if (prev === "exit") return "skip";
|
||||||
if (prev === "skip") return "update";
|
if (prev === "skip") return "update";
|
||||||
return "exit";
|
return "exit";
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Right / Tab: cycle within top button row
|
||||||
|
if (e.key === "ArrowRight" || e.keyCode === 22 || e.key === "Tab") {
|
||||||
|
e.preventDefault();
|
||||||
playTvBeep(520, 0.025);
|
playTvBeep(520, 0.025);
|
||||||
|
setTvFocusedBtn((prev) => {
|
||||||
|
if (prev === "update") return "skip";
|
||||||
|
if (prev === "skip") return "exit";
|
||||||
|
return "update";
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -458,6 +575,9 @@ export function UpdaterBanner({ isTvEnvironment }: UpdaterBannerProps = {}) {
|
||||||
} else if (tvFocusedBtn === "exit") {
|
} else if (tvFocusedBtn === "exit") {
|
||||||
playTvBeep(320, 0.06);
|
playTvBeep(320, 0.06);
|
||||||
handleExitApp();
|
handleExitApp();
|
||||||
|
} else if (tvFocusedBtn === "autotoggle") {
|
||||||
|
playTvBeep(560, 0.04);
|
||||||
|
toggleAutoUpdate();
|
||||||
} else {
|
} else {
|
||||||
playTvBeep(420, 0.04);
|
playTvBeep(420, 0.04);
|
||||||
setDismissed(true);
|
setDismissed(true);
|
||||||
|
|
@ -475,7 +595,7 @@ export function UpdaterBanner({ isTvEnvironment }: UpdaterBannerProps = {}) {
|
||||||
|
|
||||||
window.addEventListener("keydown", handleTvKeyDown);
|
window.addEventListener("keydown", handleTvKeyDown);
|
||||||
return () => window.removeEventListener("keydown", handleTvKeyDown);
|
return () => window.removeEventListener("keydown", handleTvKeyDown);
|
||||||
}, [updateAvailable, dismissed, isTv, downloading, tvFocusedBtn, handleInstall, handleExitApp]);
|
}, [updateAvailable, dismissed, isTv, downloading, tvFocusedBtn, handleInstall, handleExitApp, cancelAutoCountdown, toggleAutoUpdate]);
|
||||||
|
|
||||||
if (!updateAvailable || dismissed) return null;
|
if (!updateAvailable || dismissed) return null;
|
||||||
|
|
||||||
|
|
@ -487,15 +607,21 @@ export function UpdaterBanner({ isTvEnvironment }: UpdaterBannerProps = {}) {
|
||||||
<div className="has-tv-updater-overlay" role="dialog" aria-modal="true">
|
<div className="has-tv-updater-overlay" role="dialog" aria-modal="true">
|
||||||
<div className="has-tv-updater-card">
|
<div className="has-tv-updater-card">
|
||||||
<div className="has-tv-updater-icon-ring">{platformInfo.icon}</div>
|
<div className="has-tv-updater-icon-ring">{platformInfo.icon}</div>
|
||||||
<h2 className="has-tv-updater-title">{platformInfo.title}</h2>
|
<h2 className="has-tv-updater-title">Хотите ли вы обновить приложение HAS?</h2>
|
||||||
<div className="has-tv-updater-version-tag">
|
<div className="has-tv-updater-version-tag">
|
||||||
<span>{platformInfo.badge}</span>
|
<span>📺 Android TV • v{currentAppVersion} ➔ v{updateInfo?.version || "новейшая"}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p className="has-tv-updater-desc">
|
<p className="has-tv-updater-desc">
|
||||||
{updateInfo?.body || platformInfo.desc}
|
{updateInfo?.body || platformInfo.desc}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
{autoCountdown !== null && !downloading && (
|
||||||
|
<div className="has-tv-updater-countdown">
|
||||||
|
⚡ Автообновление активно: начнется через {autoCountdown} сек... (нажмите любую кнопку для отмены)
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{downloading ? (
|
{downloading ? (
|
||||||
<div className="has-tv-updater-progress-container">
|
<div className="has-tv-updater-progress-container">
|
||||||
<div className="has-tv-updater-progress-track">
|
<div className="has-tv-updater-progress-track">
|
||||||
|
|
@ -505,70 +631,104 @@ export function UpdaterBanner({ isTvEnvironment }: UpdaterBannerProps = {}) {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<span className="has-tv-updater-progress-text">
|
<span className="has-tv-updater-progress-text">
|
||||||
Загрузка и установка обновления: {progress}%
|
{statusText}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="has-tv-updater-buttons">
|
<>
|
||||||
{/* Button 1: Обновить APK для ТВ */}
|
<div className="has-tv-updater-buttons">
|
||||||
<button
|
{/* Button 1: Да, обновить сейчас */}
|
||||||
ref={updateBtnRef}
|
<button
|
||||||
type="button"
|
ref={updateBtnRef}
|
||||||
className={`has-tv-updater-btn btn-update ${
|
type="button"
|
||||||
tvFocusedBtn === "update" ? "focused" : ""
|
className={`has-tv-updater-btn btn-update ${
|
||||||
}`}
|
tvFocusedBtn === "update" ? "focused" : ""
|
||||||
onClick={() => {
|
}`}
|
||||||
playTvBeep(680, 0.05);
|
onClick={() => {
|
||||||
handleInstall();
|
playTvBeep(680, 0.05);
|
||||||
}}
|
cancelAutoCountdown();
|
||||||
onMouseEnter={() => setTvFocusedBtn("update")}
|
handleInstall();
|
||||||
tabIndex={0}
|
}}
|
||||||
data-tv-focusable="true"
|
onMouseEnter={() => {
|
||||||
>
|
cancelAutoCountdown();
|
||||||
<span>{platformInfo.btnLabel}</span>
|
setTvFocusedBtn("update");
|
||||||
</button>
|
}}
|
||||||
|
tabIndex={0}
|
||||||
|
data-tv-focusable="true"
|
||||||
|
>
|
||||||
|
<span>{platformInfo.btnLabel}</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
{/* Button 2: Пропустить */}
|
{/* Button 2: Напомнить позже */}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={`has-tv-updater-btn btn-skip ${
|
className={`has-tv-updater-btn btn-skip ${
|
||||||
tvFocusedBtn === "skip" ? "focused" : ""
|
tvFocusedBtn === "skip" ? "focused" : ""
|
||||||
}`}
|
}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
playTvBeep(420, 0.04);
|
playTvBeep(420, 0.04);
|
||||||
setDismissed(true);
|
cancelAutoCountdown();
|
||||||
}}
|
setDismissed(true);
|
||||||
onMouseEnter={() => setTvFocusedBtn("skip")}
|
}}
|
||||||
tabIndex={0}
|
onMouseEnter={() => {
|
||||||
data-tv-focusable="true"
|
cancelAutoCountdown();
|
||||||
>
|
setTvFocusedBtn("skip");
|
||||||
<span>Пропустить</span>
|
}}
|
||||||
</button>
|
tabIndex={0}
|
||||||
|
data-tv-focusable="true"
|
||||||
|
>
|
||||||
|
<span>Напомнить позже</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
{/* Button 3: Выход из приложения (Exit) */}
|
{/* Button 3: Выход из приложения (Exit) */}
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className={`has-tv-updater-btn btn-exit ${
|
||||||
|
tvFocusedBtn === "exit" ? "focused" : ""
|
||||||
|
}`}
|
||||||
|
onClick={() => {
|
||||||
|
playTvBeep(320, 0.06);
|
||||||
|
cancelAutoCountdown();
|
||||||
|
handleExitApp();
|
||||||
|
}}
|
||||||
|
onMouseEnter={() => {
|
||||||
|
cancelAutoCountdown();
|
||||||
|
setTvFocusedBtn("exit");
|
||||||
|
}}
|
||||||
|
tabIndex={0}
|
||||||
|
data-tv-focusable="true"
|
||||||
|
title="Выйти из приложения"
|
||||||
|
>
|
||||||
|
<span>✕ Выход</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Auto-update Toggle Chip for Android TV */}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={`has-tv-updater-btn btn-exit ${
|
className={`has-tv-updater-autotoggle ${autoUpdateTv ? "active" : ""} ${
|
||||||
tvFocusedBtn === "exit" ? "focused" : ""
|
tvFocusedBtn === "autotoggle" ? "focused" : ""
|
||||||
}`}
|
}`}
|
||||||
onClick={() => {
|
onClick={toggleAutoUpdate}
|
||||||
playTvBeep(320, 0.06);
|
onMouseEnter={() => {
|
||||||
handleExitApp();
|
cancelAutoCountdown();
|
||||||
|
setTvFocusedBtn("autotoggle");
|
||||||
}}
|
}}
|
||||||
onMouseEnter={() => setTvFocusedBtn("exit")}
|
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
data-tv-focusable="true"
|
data-tv-focusable="true"
|
||||||
title="Выйти из приложения"
|
title="Переключить режим автоматического скачивания обновлений для ТВ"
|
||||||
>
|
>
|
||||||
<span>✕ Выход</span>
|
{autoUpdateTv
|
||||||
|
? "🟢 Автообновление для TV: ВКЛЮЧЕНО (скачивать без запроса)"
|
||||||
|
: "⚪ Автообновление для TV: ВЫКЛЮЧЕНО (нажмите OK чтобы включить)"}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{error && <div className="updater-error" style={{ marginTop: 16 }}>{error}</div>}
|
{error && <div className="updater-error" style={{ marginTop: 16 }}>{error}</div>}
|
||||||
|
|
||||||
<div className="has-tv-updater-remote-hint">
|
<div className="has-tv-updater-remote-hint">
|
||||||
◄ ► Стрелки на пульте: выбор • OK: подтвердить • Back: пропустить
|
◄ ► Стрелки на пульте: выбор • ▲ ▼ Вверх/Вниз: переключение опций • OK: подтвердить • Back: позже
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -704,15 +704,82 @@ export default function Cinema({
|
||||||
post({ command: isPlay ? "play" : "pause" });
|
post({ command: isPlay ? "play" : "pause" });
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const setPlayerVolumeMax = useCallback((showToast: boolean = false) => {
|
||||||
|
// 1. Native HTML5 Video Element
|
||||||
|
if (videoRef.current) {
|
||||||
|
try {
|
||||||
|
videoRef.current.volume = 1.0;
|
||||||
|
videoRef.current.muted = false;
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Iframe Players (Kodik, Alloha, Playerjs, VidLink, YouTube/AutoEmbed, etc.)
|
||||||
|
const iframe = document.querySelector<HTMLIFrameElement>(".has-cinema-iframe-elem");
|
||||||
|
if (iframe && iframe.contentWindow) {
|
||||||
|
const win = iframe.contentWindow;
|
||||||
|
const post = (payload: any) => {
|
||||||
|
try { win.postMessage(payload, "*"); } catch {}
|
||||||
|
try { win.postMessage(JSON.stringify(payload), "*"); } catch {}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 1. Kodik API
|
||||||
|
post({ key: "kodik_player_api", value: { method: "volume", volume: 1 } });
|
||||||
|
post({ key: "kodik_player_api", value: { method: "volume", volume: 100 } });
|
||||||
|
post({ key: "kodik_player_api", value: { method: "unmute" } });
|
||||||
|
|
||||||
|
// 2. Playerjs API (Alloha, Kinoplay, Collaps, VideoCDN, Ashdi, HDRezka)
|
||||||
|
post({ api: "volume", volume: 1 });
|
||||||
|
post({ api: "volume", volume: 100 });
|
||||||
|
post({ api: "volume", value: 100 });
|
||||||
|
post({ api: "unmute" });
|
||||||
|
|
||||||
|
// 3. Alloha API
|
||||||
|
post({ action: "volume", volume: 1 });
|
||||||
|
post({ action: "volume", value: 100 });
|
||||||
|
post({ action: "unmute" });
|
||||||
|
post({ method: "volume", value: 1 });
|
||||||
|
post({ method: "setVolume", value: 100 });
|
||||||
|
post({ method: "unmute" });
|
||||||
|
|
||||||
|
// 4. VidLink Pro / Video.js API
|
||||||
|
post({ type: "VOLUME", volume: 1 });
|
||||||
|
post({ type: "SET_VOLUME", data: { volume: 1 } });
|
||||||
|
post({ type: "SET_VOLUME", data: { volume: 100 } });
|
||||||
|
post({ type: "unmute" });
|
||||||
|
post({ action: "volume", value: 1 });
|
||||||
|
post({ action: "unmute" });
|
||||||
|
|
||||||
|
// 5. YouTube / VidSrc / AutoEmbed HTML5 API
|
||||||
|
post({ event: "command", func: "setVolume", args: [100] });
|
||||||
|
post({ event: "command", func: "unMute", args: "" });
|
||||||
|
|
||||||
|
// 6. Generic HTML5 postMessage
|
||||||
|
post({ method: "setVolume", volume: 100 });
|
||||||
|
post({ method: "setVolume", value: 100 });
|
||||||
|
post({ method: "unmute" });
|
||||||
|
post({ command: "setVolume", volume: 100 });
|
||||||
|
post({ command: "unmute" });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showToast) {
|
||||||
|
showTvToast("Громкость плеера: 100%", "🔊", 1500);
|
||||||
|
}
|
||||||
|
}, [showTvToast]);
|
||||||
|
|
||||||
const triggerPlayerPlay = useCallback(() => {
|
const triggerPlayerPlay = useCallback(() => {
|
||||||
if (videoRef.current) {
|
if (videoRef.current) {
|
||||||
|
try {
|
||||||
|
videoRef.current.muted = false;
|
||||||
|
videoRef.current.volume = 1.0;
|
||||||
|
} catch {}
|
||||||
videoRef.current.play().catch(() => {});
|
videoRef.current.play().catch(() => {});
|
||||||
} else {
|
} else {
|
||||||
sendIframePlaybackCommand("play");
|
sendIframePlaybackCommand("play");
|
||||||
}
|
}
|
||||||
|
setPlayerVolumeMax(false);
|
||||||
setIsPlayingState(true);
|
setIsPlayingState(true);
|
||||||
showTvToast("Воспроизведение", "▶", 1200);
|
showTvToast("Воспроизведение", "▶", 1200);
|
||||||
}, [sendIframePlaybackCommand, showTvToast]);
|
}, [sendIframePlaybackCommand, setPlayerVolumeMax, showTvToast]);
|
||||||
|
|
||||||
const triggerPlayerPause = useCallback(() => {
|
const triggerPlayerPause = useCallback(() => {
|
||||||
if (videoRef.current) {
|
if (videoRef.current) {
|
||||||
|
|
@ -1467,6 +1534,10 @@ export default function Cinema({
|
||||||
hls.loadSource(anilibriaStreamUrl);
|
hls.loadSource(anilibriaStreamUrl);
|
||||||
hls.attachMedia(video);
|
hls.attachMedia(video);
|
||||||
hls.on(Hls.Events.MANIFEST_PARSED, () => {
|
hls.on(Hls.Events.MANIFEST_PARSED, () => {
|
||||||
|
try {
|
||||||
|
video.volume = 1.0;
|
||||||
|
video.muted = false;
|
||||||
|
} catch {}
|
||||||
video.play().catch(() => {});
|
video.play().catch(() => {});
|
||||||
});
|
});
|
||||||
hls.on(Hls.Events.ERROR, (_event, data) => {
|
hls.on(Hls.Events.ERROR, (_event, data) => {
|
||||||
|
|
@ -1570,14 +1641,19 @@ export default function Cinema({
|
||||||
mirrorWatchdogTimerRef.current = null;
|
mirrorWatchdogTimerRef.current = null;
|
||||||
}
|
}
|
||||||
setIsMirrorConnecting(false);
|
setIsMirrorConnecting(false);
|
||||||
// Auto-trigger play once iframe scripts initialize
|
// Auto-trigger play and max volume once iframe scripts initialize
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
sendIframePlaybackCommand("play");
|
sendIframePlaybackCommand("play");
|
||||||
|
setPlayerVolumeMax(false);
|
||||||
}, 500);
|
}, 500);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
sendIframePlaybackCommand("play");
|
sendIframePlaybackCommand("play");
|
||||||
|
setPlayerVolumeMax(false);
|
||||||
}, 1500);
|
}, 1500);
|
||||||
}, [sendIframePlaybackCommand]);
|
setTimeout(() => {
|
||||||
|
setPlayerVolumeMax(false);
|
||||||
|
}, 2800);
|
||||||
|
}, [sendIframePlaybackCommand, setPlayerVolumeMax]);
|
||||||
|
|
||||||
// Start playback for a media item (movie or specific series episode)
|
// Start playback for a media item (movie or specific series episode)
|
||||||
const startPlayback = (media: CinemaMediaItem, seasonNum: number = 1, episode?: CinemaEpisode) => {
|
const startPlayback = (media: CinemaMediaItem, seasonNum: number = 1, episode?: CinemaEpisode) => {
|
||||||
|
|
@ -1592,6 +1668,13 @@ export default function Cinema({
|
||||||
setShowPlayerEpisodes(false);
|
setShowPlayerEpisodes(false);
|
||||||
resetHudTimer();
|
resetHudTimer();
|
||||||
|
|
||||||
|
if (videoRef.current) {
|
||||||
|
try {
|
||||||
|
videoRef.current.volume = 1.0;
|
||||||
|
videoRef.current.muted = false;
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
const ep =
|
const ep =
|
||||||
episode ||
|
episode ||
|
||||||
media.seasons.find((s) => s.season_number === seasonNum)?.episodes[0] ||
|
media.seasons.find((s) => s.season_number === seasonNum)?.episodes[0] ||
|
||||||
|
|
@ -4888,6 +4971,18 @@ export default function Cinema({
|
||||||
>
|
>
|
||||||
⏩ Пропуск опенинга (+85с)
|
⏩ Пропуск опенинга (+85с)
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="has-cinema-drawer-chip"
|
||||||
|
onClick={() => {
|
||||||
|
setPlayerVolumeMax(true);
|
||||||
|
setShowPlayerSettings(false);
|
||||||
|
}}
|
||||||
|
data-tv-focusable="true"
|
||||||
|
title="Выставить громкость плеера на максимум (100%)"
|
||||||
|
>
|
||||||
|
🔊 Громкость 100%
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="has-cinema-drawer-chip"
|
className="has-cinema-drawer-chip"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue