Compare commits

..

1 Commits

Author SHA1 Message Date
Gauvain
fd87cb05ea ci: [test] enable tvOS builds, disable other jobs (throwaway branch) 2026-05-28 20:25:25 +02:00
106 changed files with 1647 additions and 2856 deletions

View File

@@ -1,54 +1,91 @@
<!-- <!--
Use a conventional commit title for the PR title, Pull Request Template for Streamyfin
for example `feat(auth): add MFA` ====================================
All sections below are required. Write N/A if a section is not applicable. Use this template to help reviewers understand the purpose of your PR
If you use AI to help implement this PR, you must declare it below. It's very important that the feature or fix implemented has been tested thoroughly by you personally on all target platforms. Only adding AI generated code without proper testing is not allowed and this PR will be closed immediately. and to ensure all necessary checks are completed before merging.
--> -->
# 📦 Pull Request # 📦 Pull Request
## 🔖 Summary
<!-- <!--
🤖 AI ASSISTED? A concise description of the changes introduced by this PR.
Uncomment the line below if AI was used to assist with this PR: Example:
--> “Add real-time currency conversion widget to dashboard.”
<!--
[![AI Assisted](https://img.shields.io/badge/AI_Assisted-18181b?style=for-the-badge&logo=openai&logoColor=white)](#) -->
## 📝 Description
<!--
A short description of the changes and why you're making them.
Example: “Add option to clean image cache, to mitigate stuck/blank movie poster issues.”
--> -->
## 🏷️ Ticket / Issue ## 🏷️ Ticket / Issue
<!-- <!--
Link to the related ticket, issue or user story. Link to the related ticket, issue or user story.
Example: Fixes #123 You can also indicate if this PR supersedes a previous one.
Example:
- Closes #123
- Fixes STREAMYFIN-456
- Resolves #789
- Supersedes #120
- Related: #130
--> -->
### 🖼️ Screenshots / GIFs (if UI) ## 🛠️ Whats Changed
<!-- <!-- Use a Conventional Commit in the PR title, e.g., `feat(auth): add MFA`.
Include screenshots of relevant UI changes for both Android and iOS. If this PR introduces a breaking change, include a `BREAKING CHANGE:` block in the description.
Before/After, responsive states (if relevant). Spec: https://www.conventionalcommits.org/ -->
- Type: feat | fix | docs | style | refactor | perf | test | chore | build | ci | revert
- Scope (optional): e.g., auth, billing, mobile
- Short summary: what changed and why (12 lines)
--> -->
## 📋 Details
<!--
Provide more context or background. Explain any non-obvious decisions.
Include screenshots or GIFs for UI changes if applicable.
-->
### ⚠️ Breaking Changes
<!-- List any breaking API/contract changes and migration guidance. If none, write “None”. -->
### 🔐 Security & Privacy Impact
<!-- Data touched, new permissions/scopes, PII, secrets, threat considerations. If none, write “None”. -->
### ⚡ Performance Impact
<!-- Hot paths, memory/CPU/latency implications, benchmarks if available. -->
### 🖼️ Screenshots / GIFs (if UI)
<!-- Before/After, dark mode, responsive states. -->
## ✅ Checklist ## ✅ Checklist
<!-- <!--
Review and check off items as you complete them. Review and check off items as you complete them.
--> -->
- [ ] Ive read the [contribution guidelines](CONTRIBUTING.md) - [ ] Ive read the [contribution guidelines](CONTRIBUTING.md)
- [ ] Verified that changes behave as expected for all platforms - [ ] Code follows project style and passes lint/format (`npm|pnpm|yarn|bun` scripts)
- [ ] Code passes lint/formatting and type checks (`tsc`/`biome`) - [ ] Type checks pass (tsc/biome/etc.)
- [ ] No secrets, hardcoded credentials, or private config files are included - [ ] Docs updated (README/ADR/usage/API)
- [ ] I've declared if AI was used to assist with this PR (by uncommenting the line at the bottom, or not) - [ ] No secrets/credentials included; env vars documented
- [ ] Release notes/CHANGELOG entry added (if applicable)
- [ ] Verified locally that changes behave as expected
## 🔍 Testing Instructions ## 🔍 Testing Instructions
<!-- <!--
Describe how reviewers can test your changes. This will help the PR get merged faster. Describe how reviewers can test your changes.
Example: Example:
1. Open the settings page and scroll to the bottom 1. `git fetch origin pull/<PR_ID>/head:branchname && git checkout branchname`
2. Verify that the clear data button is visible and pressable 2. Install deps: `npm|pnpm|yarn|bun install`
3. Verify that when you click the clear data button, a dialog appears prompting you to confirm 3. Start service/app: `npm|pnpm|yarn|bun run [target]` (e.g., `npm run ios` or `bun run android:tv`)
4. Verify that when you click the confirm button, the data is cleared and a toast message is displayed 4. Run tests: `npm|pnpm|yarn|bun test`
5. Verification steps:
- [ ] Expected UI/endpoint behavior
- [ ] Logs show no errors
- [ ] Edge cases covered (list)
--> -->
## ⚙️ Deployment Notes
<!--
Describe any deployment considerations such as config, environment vars, or native builds.
-->
## 📝 Additional Notes
<!--
Any other information or references related to this PR.
-->

19
.github/renovate.json vendored
View File

@@ -25,25 +25,6 @@
"osvVulnerabilityAlerts": true, "osvVulnerabilityAlerts": true,
"configMigration": true, "configMigration": true,
"separateMinorPatch": true, "separateMinorPatch": true,
"customManagers": [
{
"customType": "regex",
"managerFilePatterns": ["/\\.ya?ml$/"],
"matchStrings": [
"# renovate: datasource=(?<datasource>\\S+) depName=(?<depName>\\S+)(?: versioning=(?<versioning>\\S+))?\\s+xcode-version:\\s*[\"']?(?<currentValue>[^\"'\\s]+)"
],
"versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}loose{{/if}}"
}
],
"customDatasources": {
"xcode": {
"defaultRegistryUrlTemplate": "https://xcodereleases.com/data.json",
"format": "json",
"transformTemplates": [
"{ \"releases\": [$[version.release.release=true].{\"version\": version.number}] }"
]
}
},
"lockFileMaintenance": { "lockFileMaintenance": {
"vulnerabilityAlerts": { "vulnerabilityAlerts": {
"enabled": true, "enabled": true,

View File

@@ -13,7 +13,7 @@ on:
jobs: jobs:
build-android-phone: build-android-phone:
if: (!contains(github.event.head_commit.message, '[skip ci]')) if: false # [tvos-test] temporarily disabled to only run tvOS builds
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
name: 🤖 Build Android APK (Phone) name: 🤖 Build Android APK (Phone)
permissions: permissions:
@@ -96,7 +96,7 @@ jobs:
retention-days: 7 retention-days: 7
build-android-tv: build-android-tv:
if: (!contains(github.event.head_commit.message, '[skip ci]')) if: false # [tvos-test] temporarily disabled to only run tvOS builds
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
name: 🤖 Build Android APK (TV) name: 🤖 Build Android APK (TV)
permissions: permissions:
@@ -179,7 +179,7 @@ jobs:
retention-days: 7 retention-days: 7
build-ios-phone: build-ios-phone:
if: (!contains(github.event.head_commit.message, '[skip ci]') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'streamyfin/streamyfin')) if: false # [tvos-test] temporarily disabled to only run tvOS builds
runs-on: macos-26 runs-on: macos-26
name: 🍎 Build iOS IPA (Phone) name: 🍎 Build iOS IPA (Phone)
permissions: permissions:
@@ -218,8 +218,7 @@ jobs:
- name: 🔧 Setup Xcode - name: 🔧 Setup Xcode
uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1 uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1
with: with:
# renovate: datasource=custom.xcode depName=xcode versioning=loose xcode-version: "26.2"
xcode-version: "26.4"
- name: 🏗️ Setup EAS - name: 🏗️ Setup EAS
uses: expo/expo-github-action@b184ff86a3c926240f1b6db41764c83a01c02eef # main uses: expo/expo-github-action@b184ff86a3c926240f1b6db41764c83a01c02eef # main
@@ -244,7 +243,7 @@ jobs:
retention-days: 7 retention-days: 7
build-ios-phone-unsigned: build-ios-phone-unsigned:
if: (!contains(github.event.head_commit.message, '[skip ci]')) if: false # [tvos-test] temporarily disabled to only run tvOS builds
runs-on: macos-26 runs-on: macos-26
name: 🍎 Build iOS IPA (Phone - Unsigned) name: 🍎 Build iOS IPA (Phone - Unsigned)
permissions: permissions:
@@ -283,8 +282,7 @@ jobs:
- name: 🔧 Setup Xcode - name: 🔧 Setup Xcode
uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1 uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1
with: with:
# renovate: datasource=custom.xcode depName=xcode versioning=loose xcode-version: "26.2"
xcode-version: "26.4"
- name: 🚀 Build iOS app - name: 🚀 Build iOS app
env: env:
@@ -304,7 +302,7 @@ jobs:
build-ios-tv: build-ios-tv:
# Temporarily disabled until feat/tv-interface is merged (TV UI not ready). # Temporarily disabled until feat/tv-interface is merged (TV UI not ready).
# Re-enable by removing the `false &&` prefix below. # Re-enable by removing the `false &&` prefix below.
if: false && (!contains(github.event.head_commit.message, '[skip ci]') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'streamyfin/streamyfin')) if: (!contains(github.event.head_commit.message, '[skip ci]') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'streamyfin/streamyfin'))
runs-on: macos-26 runs-on: macos-26
name: 🍎 Build tvOS IPA name: 🍎 Build tvOS IPA
permissions: permissions:
@@ -343,8 +341,7 @@ jobs:
- name: 🔧 Setup Xcode - name: 🔧 Setup Xcode
uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1 uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1
with: with:
# renovate: datasource=custom.xcode depName=xcode versioning=loose xcode-version: "26.2"
xcode-version: "26.4"
- name: 🏗️ Setup EAS - name: 🏗️ Setup EAS
uses: expo/expo-github-action@b184ff86a3c926240f1b6db41764c83a01c02eef # main uses: expo/expo-github-action@b184ff86a3c926240f1b6db41764c83a01c02eef # main
@@ -369,9 +366,8 @@ jobs:
retention-days: 7 retention-days: 7
build-ios-tv-unsigned: build-ios-tv-unsigned:
# Unsigned tvOS build is enabled (compiles without Apple credentials). # Temporarily disabled until feat/tv-interface is merged (TV UI not ready).
# The signed tvOS job above stays disabled until tvOS provisioning # Re-enable by removing the `false &&` prefix below.
# profiles are set up in EAS (app + TopShelf targets).
if: (!contains(github.event.head_commit.message, '[skip ci]')) if: (!contains(github.event.head_commit.message, '[skip ci]'))
runs-on: macos-26 runs-on: macos-26
name: 🍎 Build tvOS IPA (Unsigned) name: 🍎 Build tvOS IPA (Unsigned)
@@ -411,8 +407,7 @@ jobs:
- name: 🔧 Setup Xcode - name: 🔧 Setup Xcode
uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1 uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1
with: with:
# renovate: datasource=custom.xcode depName=xcode versioning=loose xcode-version: "26.2"
xcode-version: "26.4"
- name: 🚀 Build iOS app - name: 🚀 Build iOS app
env: env:

2
.gitignore vendored
View File

@@ -74,5 +74,3 @@ modules/background-downloader/android/build/*
# ios:unsigned-build Artifacts # ios:unsigned-build Artifacts
build/ build/
.claude/ .claude/
.agents/skills/**
skills-lock.json

View File

@@ -78,16 +78,15 @@
"expo-build-properties", "expo-build-properties",
{ {
"ios": { "ios": {
"deploymentTarget": "16.4", "deploymentTarget": "15.6",
"useFrameworks": "static", "useFrameworks": "static"
"forceStaticLinking": ["ExpoUI", "GlassEffectView", "GlassPoster"]
}, },
"android": { "android": {
"buildArchs": ["arm64-v8a", "x86_64", "armeabi-v7a"], "buildArchs": ["arm64-v8a", "x86_64", "armeabi-v7a"],
"compileSdkVersion": 36, "compileSdkVersion": 36,
"targetSdkVersion": 35, "targetSdkVersion": 35,
"buildToolsVersion": "35.0.0", "buildToolsVersion": "35.0.0",
"kotlinVersion": "2.1.20", "kotlinVersion": "2.0.21",
"minSdkVersion": 26, "minSdkVersion": 26,
"usesCleartextTraffic": true, "usesCleartextTraffic": true,
"packagingOptions": { "packagingOptions": {
@@ -144,8 +143,8 @@
[ [
"./plugins/withGitPod.js", "./plugins/withGitPod.js",
{ {
"podName": "MPVKit", "podName": "MPVKit-GPL",
"podspecUrl": "https://raw.githubusercontent.com/mpv-ios/MPVKit/0.41.0-av/MPVKit.podspec" "podspecUrl": "https://raw.githubusercontent.com/streamyfin/MPVKit/0.40.0-av/MPVKit-GPL.podspec"
} }
] ]
], ],

View File

@@ -16,7 +16,7 @@ export interface MenuLink {
icon: string; icon: string;
} }
export default function CustomLinksPage() { export default function menuLinks() {
const [api] = useAtom(apiAtom); const [api] = useAtom(apiAtom);
const insets = useSafeAreaInsets(); const insets = useSafeAreaInsets();
const [menuLinks, setMenuLinks] = useState<MenuLink[]>([]); const [menuLinks, setMenuLinks] = useState<MenuLink[]>([]);

View File

@@ -5,7 +5,7 @@ import { Favorites } from "@/components/home/Favorites";
import { Favorites as TVFavorites } from "@/components/home/Favorites.tv"; import { Favorites as TVFavorites } from "@/components/home/Favorites.tv";
import { useInvalidatePlaybackProgressCache } from "@/hooks/useRevalidatePlaybackProgressCache"; import { useInvalidatePlaybackProgressCache } from "@/hooks/useRevalidatePlaybackProgressCache";
export default function FavoritesPage() { export default function favorites() {
const invalidateCache = useInvalidatePlaybackProgressCache(); const invalidateCache = useInvalidatePlaybackProgressCache();
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);

View File

@@ -9,7 +9,6 @@ import useRouter from "@/hooks/useAppRouter";
const Chromecast = Platform.isTV ? null : require("@/components/Chromecast"); const Chromecast = Platform.isTV ? null : require("@/components/Chromecast");
import { useAtom } from "jotai"; import { useAtom } from "jotai";
import { HeaderBackButton } from "@/components/common/HeaderBackButton";
import { useSessions, type useSessionsProps } from "@/hooks/useSessions"; import { useSessions, type useSessionsProps } from "@/hooks/useSessions";
import { userAtom } from "@/providers/JellyfinProvider"; import { userAtom } from "@/providers/JellyfinProvider";
@@ -48,7 +47,15 @@ export default function IndexLayout() {
headerBlurEffect: "none", headerBlurEffect: "none",
headerTransparent: Platform.OS === "ios", headerTransparent: Platform.OS === "ios",
title: t("home.downloads.downloads_title"), title: t("home.downloads.downloads_title"),
headerLeft: () => <HeaderBackButton />, headerLeft: () => (
<Pressable
onPress={() => _router.back()}
className='pl-0.5'
style={{ marginRight: Platform.OS === "android" ? 16 : 0 }}
>
<Feather name='chevron-left' size={28} color='white' />
</Pressable>
),
}} }}
/> />
<Stack.Screen <Stack.Screen
@@ -59,7 +66,15 @@ export default function IndexLayout() {
headerBlurEffect: "none", headerBlurEffect: "none",
headerTransparent: Platform.OS === "ios", headerTransparent: Platform.OS === "ios",
headerShadowVisible: false, headerShadowVisible: false,
headerLeft: () => <HeaderBackButton />, headerLeft: () => (
<Pressable
onPress={() => _router.back()}
className='pl-0.5'
style={{ marginRight: Platform.OS === "android" ? 16 : 0 }}
>
<Feather name='chevron-left' size={28} color='white' />
</Pressable>
),
}} }}
/> />
<Stack.Screen <Stack.Screen
@@ -89,7 +104,15 @@ export default function IndexLayout() {
headerBlurEffect: "none", headerBlurEffect: "none",
headerTransparent: Platform.OS === "ios", headerTransparent: Platform.OS === "ios",
headerShadowVisible: false, headerShadowVisible: false,
headerLeft: () => <HeaderBackButton />, headerLeft: () => (
<Pressable
onPress={() => _router.back()}
className='pl-0.5'
style={{ marginRight: Platform.OS === "android" ? 16 : 0 }}
>
<Feather name='chevron-left' size={28} color='white' />
</Pressable>
),
}} }}
/> />
<Stack.Screen <Stack.Screen
@@ -100,7 +123,15 @@ export default function IndexLayout() {
headerBlurEffect: "none", headerBlurEffect: "none",
headerTransparent: Platform.OS === "ios", headerTransparent: Platform.OS === "ios",
headerShadowVisible: false, headerShadowVisible: false,
headerLeft: () => <HeaderBackButton />, headerLeft: () => (
<Pressable
onPress={() => _router.back()}
className='pl-0.5'
style={{ marginRight: Platform.OS === "android" ? 16 : 0 }}
>
<Feather name='chevron-left' size={28} color='white' />
</Pressable>
),
}} }}
/> />
<Stack.Screen <Stack.Screen
@@ -111,7 +142,15 @@ export default function IndexLayout() {
headerBlurEffect: "none", headerBlurEffect: "none",
headerTransparent: Platform.OS === "ios", headerTransparent: Platform.OS === "ios",
headerShadowVisible: false, headerShadowVisible: false,
headerLeft: () => <HeaderBackButton />, headerLeft: () => (
<Pressable
onPress={() => _router.back()}
className='pl-0.5'
style={{ marginRight: Platform.OS === "android" ? 16 : 0 }}
>
<Feather name='chevron-left' size={28} color='white' />
</Pressable>
),
}} }}
/> />
<Stack.Screen <Stack.Screen
@@ -122,7 +161,15 @@ export default function IndexLayout() {
headerBlurEffect: "none", headerBlurEffect: "none",
headerTransparent: Platform.OS === "ios", headerTransparent: Platform.OS === "ios",
headerShadowVisible: false, headerShadowVisible: false,
headerLeft: () => <HeaderBackButton />, headerLeft: () => (
<Pressable
onPress={() => _router.back()}
className='pl-0.5'
style={{ marginRight: Platform.OS === "android" ? 16 : 0 }}
>
<Feather name='chevron-left' size={28} color='white' />
</Pressable>
),
}} }}
/> />
<Stack.Screen <Stack.Screen
@@ -133,7 +180,15 @@ export default function IndexLayout() {
headerBlurEffect: "none", headerBlurEffect: "none",
headerTransparent: Platform.OS === "ios", headerTransparent: Platform.OS === "ios",
headerShadowVisible: false, headerShadowVisible: false,
headerLeft: () => <HeaderBackButton />, headerLeft: () => (
<Pressable
onPress={() => _router.back()}
className='pl-0.5'
style={{ marginRight: Platform.OS === "android" ? 16 : 0 }}
>
<Feather name='chevron-left' size={28} color='white' />
</Pressable>
),
}} }}
/> />
<Stack.Screen <Stack.Screen
@@ -144,7 +199,15 @@ export default function IndexLayout() {
headerBlurEffect: "none", headerBlurEffect: "none",
headerTransparent: Platform.OS === "ios", headerTransparent: Platform.OS === "ios",
headerShadowVisible: false, headerShadowVisible: false,
headerLeft: () => <HeaderBackButton />, headerLeft: () => (
<Pressable
onPress={() => _router.back()}
className='pl-0.5'
style={{ marginRight: Platform.OS === "android" ? 16 : 0 }}
>
<Feather name='chevron-left' size={28} color='white' />
</Pressable>
),
}} }}
/> />
<Stack.Screen <Stack.Screen
@@ -174,7 +237,15 @@ export default function IndexLayout() {
headerBlurEffect: "none", headerBlurEffect: "none",
headerTransparent: Platform.OS === "ios", headerTransparent: Platform.OS === "ios",
headerShadowVisible: false, headerShadowVisible: false,
headerLeft: () => <HeaderBackButton />, headerLeft: () => (
<Pressable
onPress={() => _router.back()}
className='pl-0.5'
style={{ marginRight: Platform.OS === "android" ? 16 : 0 }}
>
<Feather name='chevron-left' size={28} color='white' />
</Pressable>
),
}} }}
/> />
<Stack.Screen <Stack.Screen
@@ -185,7 +256,15 @@ export default function IndexLayout() {
headerBlurEffect: "none", headerBlurEffect: "none",
headerTransparent: Platform.OS === "ios", headerTransparent: Platform.OS === "ios",
headerShadowVisible: false, headerShadowVisible: false,
headerLeft: () => <HeaderBackButton />, headerLeft: () => (
<Pressable
onPress={() => _router.back()}
className='pl-0.5'
style={{ marginRight: Platform.OS === "android" ? 16 : 0 }}
>
<Feather name='chevron-left' size={28} color='white' />
</Pressable>
),
}} }}
/> />
<Stack.Screen <Stack.Screen
@@ -196,7 +275,15 @@ export default function IndexLayout() {
headerBlurEffect: "none", headerBlurEffect: "none",
headerTransparent: Platform.OS === "ios", headerTransparent: Platform.OS === "ios",
headerShadowVisible: false, headerShadowVisible: false,
headerLeft: () => <HeaderBackButton />, headerLeft: () => (
<Pressable
onPress={() => _router.back()}
className='pl-0.5'
style={{ marginRight: Platform.OS === "android" ? 16 : 0 }}
>
<Feather name='chevron-left' size={28} color='white' />
</Pressable>
),
}} }}
/> />
<Stack.Screen <Stack.Screen
@@ -207,7 +294,15 @@ export default function IndexLayout() {
headerBlurEffect: "none", headerBlurEffect: "none",
headerTransparent: Platform.OS === "ios", headerTransparent: Platform.OS === "ios",
headerShadowVisible: false, headerShadowVisible: false,
headerLeft: () => <HeaderBackButton />, headerLeft: () => (
<Pressable
onPress={() => _router.back()}
className='pl-0.5'
style={{ marginRight: Platform.OS === "android" ? 16 : 0 }}
>
<Feather name='chevron-left' size={28} color='white' />
</Pressable>
),
}} }}
/> />
<Stack.Screen <Stack.Screen
@@ -218,7 +313,15 @@ export default function IndexLayout() {
headerBlurEffect: "none", headerBlurEffect: "none",
headerTransparent: Platform.OS === "ios", headerTransparent: Platform.OS === "ios",
headerShadowVisible: false, headerShadowVisible: false,
headerLeft: () => <HeaderBackButton />, headerLeft: () => (
<Pressable
onPress={() => _router.back()}
className='pl-0.5'
style={{ marginRight: Platform.OS === "android" ? 16 : 0 }}
>
<Feather name='chevron-left' size={28} color='white' />
</Pressable>
),
}} }}
/> />
<Stack.Screen <Stack.Screen
@@ -229,7 +332,15 @@ export default function IndexLayout() {
headerBlurEffect: "none", headerBlurEffect: "none",
headerTransparent: Platform.OS === "ios", headerTransparent: Platform.OS === "ios",
headerShadowVisible: false, headerShadowVisible: false,
headerLeft: () => <HeaderBackButton />, headerLeft: () => (
<Pressable
onPress={() => _router.back()}
className='pl-0.5'
style={{ marginRight: Platform.OS === "android" ? 16 : 0 }}
>
<Feather name='chevron-left' size={28} color='white' />
</Pressable>
),
}} }}
/> />
<Stack.Screen <Stack.Screen
@@ -240,7 +351,15 @@ export default function IndexLayout() {
headerBlurEffect: "none", headerBlurEffect: "none",
headerTransparent: Platform.OS === "ios", headerTransparent: Platform.OS === "ios",
headerShadowVisible: false, headerShadowVisible: false,
headerLeft: () => <HeaderBackButton />, headerLeft: () => (
<Pressable
onPress={() => _router.back()}
className='pl-0.5'
style={{ marginRight: Platform.OS === "android" ? 16 : 0 }}
>
<Feather name='chevron-left' size={28} color='white' />
</Pressable>
),
}} }}
/> />
{Object.entries(nestedTabPageScreenOptions).map(([name, options]) => ( {Object.entries(nestedTabPageScreenOptions).map(([name, options]) => (
@@ -250,7 +369,11 @@ export default function IndexLayout() {
name='collections/[collectionId]' name='collections/[collectionId]'
options={{ options={{
title: "", title: "",
headerLeft: () => <HeaderBackButton />, headerLeft: () => (
<Pressable onPress={() => _router.back()} className='pl-0.5'>
<Feather name='chevron-left' size={28} color='white' />
</Pressable>
),
headerShown: !Platform.isTV, headerShown: !Platform.isTV,
headerBlurEffect: "prominent", headerBlurEffect: "prominent",
headerTransparent: Platform.OS === "ios", headerTransparent: Platform.OS === "ios",

View File

@@ -20,7 +20,7 @@ import { OfflineModeProvider } from "@/providers/OfflineModeProvider";
import { queueAtom } from "@/utils/atoms/queue"; import { queueAtom } from "@/utils/atoms/queue";
import { writeToLog } from "@/utils/log"; import { writeToLog } from "@/utils/log";
export default function DownloadsPage() { export default function page() {
const navigation = useNavigation(); const navigation = useNavigation();
const { t } = useTranslation(); const { t } = useTranslation();
const [_queue, _setQueue] = useAtom(queueAtom); const [_queue, _setQueue] = useAtom(queueAtom);

View File

@@ -23,7 +23,7 @@ import { formatBitrate } from "@/utils/bitrate";
import { getPrimaryImageUrl } from "@/utils/jellyfin/image/getPrimaryImageUrl"; import { getPrimaryImageUrl } from "@/utils/jellyfin/image/getPrimaryImageUrl";
import { formatTimeString } from "@/utils/time"; import { formatTimeString } from "@/utils/time";
export default function SessionsPage() { export default function page() {
const { sessions, isLoading } = useSessions({} as useSessionsProps); const { sessions, isLoading } = useSessions({} as useSessionsProps);
const { t } = useTranslation(); const { t } = useTranslation();
@@ -72,7 +72,7 @@ const SessionCard = ({ session }: SessionCardProps) => {
}; };
const getProgressPercentage = () => { const getProgressPercentage = () => {
if (!session.NowPlayingItem?.RunTimeTicks) { if (!session.NowPlayingItem || !session.NowPlayingItem.RunTimeTicks) {
return 0; return 0;
} }

View File

@@ -59,17 +59,17 @@ function SettingsMobile() {
<QuickConnect className='mb-4' /> <QuickConnect className='mb-4' />
<View className='mb-4'> <TouchableOpacity
<ListGroup title={t("pairing.pair_with_phone_title")}> className='mb-4 p-4 rounded-xl bg-neutral-900 border border-neutral-800'
<ListItem onPress={() => router.push("/(auth)/(tabs)/(home)/companion-login")}
onPress={() => >
router.push("/(auth)/(tabs)/(home)/companion-login") <Text className='text-white font-bold text-base mb-1'>
} {t("pairing.pair_with_phone_title")}
title={t("pairing.pair_with_phone")} </Text>
textColor='blue' <Text className='text-neutral-400 text-sm'>
/> {t("pairing.pair_with_phone_description")}
</ListGroup> </Text>
</View> </TouchableOpacity>
<View className='mb-4'> <View className='mb-4'>
<AppLanguageSelector /> <AppLanguageSelector />

View File

@@ -12,7 +12,7 @@ import DisabledSetting from "@/components/settings/DisabledSetting";
import { apiAtom, userAtom } from "@/providers/JellyfinProvider"; import { apiAtom, userAtom } from "@/providers/JellyfinProvider";
import { useSettings } from "@/utils/atoms/settings"; import { useSettings } from "@/utils/atoms/settings";
export default function AppearanceHideLibrariesPage() { export default function page() {
const { settings, updateSettings, pluginSettings } = useSettings(); const { settings, updateSettings, pluginSettings } = useSettings();
const user = useAtomValue(userAtom); const user = useAtomValue(userAtom);
const api = useAtomValue(apiAtom); const api = useAtomValue(apiAtom);

View File

@@ -11,7 +11,7 @@ import DisabledSetting from "@/components/settings/DisabledSetting";
import { apiAtom, userAtom } from "@/providers/JellyfinProvider"; import { apiAtom, userAtom } from "@/providers/JellyfinProvider";
import { useSettings } from "@/utils/atoms/settings"; import { useSettings } from "@/utils/atoms/settings";
export default function HideLibrariesPage() { export default function page() {
const { settings, updateSettings, pluginSettings } = useSettings(); const { settings, updateSettings, pluginSettings } = useSettings();
const user = useAtomValue(userAtom); const user = useAtomValue(userAtom);
const api = useAtomValue(apiAtom); const api = useAtomValue(apiAtom);

View File

@@ -4,7 +4,7 @@ import DisabledSetting from "@/components/settings/DisabledSetting";
import { JellyseerrSettings } from "@/components/settings/Jellyseerr"; import { JellyseerrSettings } from "@/components/settings/Jellyseerr";
import { useSettings } from "@/utils/atoms/settings"; import { useSettings } from "@/utils/atoms/settings";
export default function JellyseerrPluginPage() { export default function page() {
const { pluginSettings } = useSettings(); const { pluginSettings } = useSettings();
const insets = useSafeAreaInsets(); const insets = useSafeAreaInsets();

View File

@@ -4,7 +4,7 @@ import DisabledSetting from "@/components/settings/DisabledSetting";
import { KefinTweaksSettings } from "@/components/settings/KefinTweaks"; import { KefinTweaksSettings } from "@/components/settings/KefinTweaks";
import { useSettings } from "@/utils/atoms/settings"; import { useSettings } from "@/utils/atoms/settings";
export default function KefinTweaksPage() { export default function page() {
const { pluginSettings } = useSettings(); const { pluginSettings } = useSettings();
const insets = useSafeAreaInsets(); const insets = useSafeAreaInsets();

View File

@@ -18,7 +18,7 @@ import DisabledSetting from "@/components/settings/DisabledSetting";
import { useNetworkAwareQueryClient } from "@/hooks/useNetworkAwareQueryClient"; import { useNetworkAwareQueryClient } from "@/hooks/useNetworkAwareQueryClient";
import { useSettings } from "@/utils/atoms/settings"; import { useSettings } from "@/utils/atoms/settings";
export default function MarlinSearchPage() { export default function page() {
const navigation = useNavigation(); const navigation = useNavigation();
const { t } = useTranslation(); const { t } = useTranslation();

View File

@@ -17,7 +17,7 @@ import { ListItem } from "@/components/list/ListItem";
import { useNetworkAwareQueryClient } from "@/hooks/useNetworkAwareQueryClient"; import { useNetworkAwareQueryClient } from "@/hooks/useNetworkAwareQueryClient";
import { useSettings } from "@/utils/atoms/settings"; import { useSettings } from "@/utils/atoms/settings";
export default function StreamystatsPage() { export default function page() {
const { t } = useTranslation(); const { t } = useTranslation();
const navigation = useNavigation(); const navigation = useNavigation();
const insets = useSafeAreaInsets(); const insets = useSafeAreaInsets();

View File

@@ -37,10 +37,8 @@ const Page: React.FC = () => {
ItemFields.MediaStreams, ItemFields.MediaStreams,
]); ]);
// Lazily preload item with full media sources in background — never cache // Lazily preload item with full media sources in background
const { data: itemWithSources } = useItemQuery(id, isOffline, undefined, [], { const { data: itemWithSources } = useItemQuery(id, isOffline, undefined, []);
gcTime: 0,
});
const opacity = useSharedValue(1); const opacity = useSharedValue(1);
const animatedStyle = useAnimatedStyle(() => { const animatedStyle = useAnimatedStyle(() => {

View File

@@ -13,7 +13,7 @@ import {
} from "@/utils/jellyseerr/server/models/Search"; } from "@/utils/jellyseerr/server/models/Search";
import { COMPANY_LOGO_IMAGE_FILTER } from "@/utils/jellyseerr/src/components/Discover/NetworkSlider"; import { COMPANY_LOGO_IMAGE_FILTER } from "@/utils/jellyseerr/src/components/Discover/NetworkSlider";
export default function JellyseerrCompanyPage() { export default function page() {
const local = useLocalSearchParams(); const local = useLocalSearchParams();
const { jellyseerrApi, isJellyseerrMovieOrTvResult } = useJellyseerr(); const { jellyseerrApi, isJellyseerrMovieOrTvResult } = useJellyseerr();

View File

@@ -9,7 +9,7 @@ import JellyseerrPoster from "@/components/posters/JellyseerrPoster";
import { Endpoints, useJellyseerr } from "@/hooks/useJellyseerr"; import { Endpoints, useJellyseerr } from "@/hooks/useJellyseerr";
import { DiscoverSliderType } from "@/utils/jellyseerr/server/constants/discover"; import { DiscoverSliderType } from "@/utils/jellyseerr/server/constants/discover";
export default function JellyseerrGenrePage() { export default function page() {
const local = useLocalSearchParams(); const local = useLocalSearchParams();
const { jellyseerrApi, isJellyseerrMovieOrTvResult } = useJellyseerr(); const { jellyseerrApi, isJellyseerrMovieOrTvResult } = useJellyseerr();

View File

@@ -11,7 +11,7 @@ import JellyseerrPoster from "@/components/posters/JellyseerrPoster";
import { useJellyseerr } from "@/hooks/useJellyseerr"; import { useJellyseerr } from "@/hooks/useJellyseerr";
import type { PersonCreditCast } from "@/utils/jellyseerr/server/models/Person"; import type { PersonCreditCast } from "@/utils/jellyseerr/server/models/Person";
export default function JellyseerrPersonPage() { export default function page() {
const local = useLocalSearchParams(); const local = useLocalSearchParams();
const { t } = useTranslation(); const { t } = useTranslation();

View File

@@ -1,13 +1,13 @@
import { Slot, Stack, withLayoutContext } from "expo-router";
import { import {
createMaterialTopTabNavigator, createMaterialTopTabNavigator,
MaterialTopTabNavigationEventMap, MaterialTopTabNavigationEventMap,
MaterialTopTabNavigationOptions, MaterialTopTabNavigationOptions,
} from "expo-router/js-top-tabs"; } from "@react-navigation/material-top-tabs";
import type { import type {
ParamListBase, ParamListBase,
TabNavigationState, TabNavigationState,
} from "expo-router/react-navigation"; } from "@react-navigation/native";
import { Slot, Stack, withLayoutContext } from "expo-router";
import { Platform } from "react-native"; import { Platform } from "react-native";
const { Navigator } = createMaterialTopTabNavigator(); const { Navigator } = createMaterialTopTabNavigator();

View File

@@ -8,7 +8,7 @@ import { ItemImage } from "@/components/common/ItemImage";
import { Text } from "@/components/common/Text"; import { Text } from "@/components/common/Text";
import { apiAtom, userAtom } from "@/providers/JellyfinProvider"; import { apiAtom, userAtom } from "@/providers/JellyfinProvider";
export default function LiveTvChannelsPage() { export default function page() {
const [api] = useAtom(apiAtom); const [api] = useAtom(apiAtom);
const [user] = useAtom(userAtom); const [user] = useAtom(userAtom);
const _insets = useSafeAreaInsets(); const _insets = useSafeAreaInsets();

View File

@@ -17,7 +17,7 @@ const ITEMS_PER_PAGE = 20;
const MemoizedLiveTVGuideRow = React.memo(LiveTVGuideRow); const MemoizedLiveTVGuideRow = React.memo(LiveTVGuideRow);
export default function LiveTvGuidePage() { export default function page() {
const [api] = useAtom(apiAtom); const [api] = useAtom(apiAtom);
const [user] = useAtom(userAtom); const [user] = useAtom(userAtom);
const insets = useSafeAreaInsets(); const insets = useSafeAreaInsets();

View File

@@ -2,7 +2,7 @@ import { useTranslation } from "react-i18next";
import { View } from "react-native"; import { View } from "react-native";
import { Text } from "@/components/common/Text"; import { Text } from "@/components/common/Text";
export default function LiveTvRecordingsPage() { export default function page() {
const { t } = useTranslation(); const { t } = useTranslation();
return ( return (
<View className='flex items-center justify-center h-full -mt-12'> <View className='flex items-center justify-center h-full -mt-12'>

View File

@@ -40,7 +40,6 @@ import { useScaledTVPosterSizes } from "@/constants/TVPosterSizes";
import { useScaledTVTypography } from "@/constants/TVTypography"; import { useScaledTVTypography } from "@/constants/TVTypography";
import useRouter from "@/hooks/useAppRouter"; import useRouter from "@/hooks/useAppRouter";
import { useOrientation } from "@/hooks/useOrientation"; import { useOrientation } from "@/hooks/useOrientation";
import { useRefreshLibraryOnFocus } from "@/hooks/useRefreshLibraryOnFocus";
import { useTVItemActionModal } from "@/hooks/useTVItemActionModal"; import { useTVItemActionModal } from "@/hooks/useTVItemActionModal";
import { useTVOptionModal } from "@/hooks/useTVOptionModal"; import { useTVOptionModal } from "@/hooks/useTVOptionModal";
import * as ScreenOrientation from "@/packages/expo-screen-orientation"; import * as ScreenOrientation from "@/packages/expo-screen-orientation";
@@ -105,10 +104,6 @@ const Page = () => {
const { orientation } = useOrientation(); const { orientation } = useOrientation();
// Fallback refresh for newly added content when returning to the library
// (primary path is the LibraryChanged WebSocket event).
useRefreshLibraryOnFocus();
const { t } = useTranslation(); const { t } = useTranslation();
const router = useRouter(); const router = useRouter();
const { showOptions } = useTVOptionModal(); const { showOptions } = useTVOptionModal();

View File

@@ -1,13 +1,13 @@
import { Stack, useLocalSearchParams, withLayoutContext } from "expo-router";
import { import {
createMaterialTopTabNavigator, createMaterialTopTabNavigator,
MaterialTopTabNavigationEventMap, MaterialTopTabNavigationEventMap,
MaterialTopTabNavigationOptions, MaterialTopTabNavigationOptions,
} from "expo-router/js-top-tabs"; } from "@react-navigation/material-top-tabs";
import type { import type {
ParamListBase, ParamListBase,
TabNavigationState, TabNavigationState,
} from "expo-router/react-navigation"; } from "@react-navigation/native";
import { Stack, useLocalSearchParams, withLayoutContext } from "expo-router";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
const { Navigator } = createMaterialTopTabNavigator(); const { Navigator } = createMaterialTopTabNavigator();

View File

@@ -1,8 +1,8 @@
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api"; import { getItemsApi } from "@jellyfin/sdk/lib/utils/api";
import { useRoute } from "@react-navigation/native";
import { FlashList } from "@shopify/flash-list"; import { FlashList } from "@shopify/flash-list";
import { useInfiniteQuery } from "@tanstack/react-query"; import { useInfiniteQuery } from "@tanstack/react-query";
import { useLocalSearchParams } from "expo-router"; import { useLocalSearchParams } from "expo-router";
import { useRoute } from "expo-router/react-navigation";
import { useAtom } from "jotai"; import { useAtom } from "jotai";
import { useCallback, useMemo } from "react"; import { useCallback, useMemo } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";

View File

@@ -1,8 +1,8 @@
import { getArtistsApi } from "@jellyfin/sdk/lib/utils/api"; import { getArtistsApi } from "@jellyfin/sdk/lib/utils/api";
import { useRoute } from "@react-navigation/native";
import { FlashList } from "@shopify/flash-list"; import { FlashList } from "@shopify/flash-list";
import { useInfiniteQuery } from "@tanstack/react-query"; import { useInfiniteQuery } from "@tanstack/react-query";
import { useLocalSearchParams } from "expo-router"; import { useLocalSearchParams } from "expo-router";
import { useRoute } from "expo-router/react-navigation";
import { useAtom } from "jotai"; import { useAtom } from "jotai";
import { useCallback, useMemo } from "react"; import { useCallback, useMemo } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";

View File

@@ -1,9 +1,9 @@
import { Ionicons } from "@expo/vector-icons"; import { Ionicons } from "@expo/vector-icons";
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api"; import { getItemsApi } from "@jellyfin/sdk/lib/utils/api";
import { useNavigation, useRoute } from "@react-navigation/native";
import { FlashList } from "@shopify/flash-list"; import { FlashList } from "@shopify/flash-list";
import { useInfiniteQuery } from "@tanstack/react-query"; import { useInfiniteQuery } from "@tanstack/react-query";
import { useLocalSearchParams } from "expo-router"; import { useLocalSearchParams } from "expo-router";
import { useNavigation, useRoute } from "expo-router/react-navigation";
import { useAtom } from "jotai"; import { useAtom } from "jotai";
import { useCallback, useLayoutEffect, useMemo, useState } from "react"; import { useCallback, useLayoutEffect, useMemo, useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";

View File

@@ -1,9 +1,9 @@
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models"; import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api"; import { getItemsApi } from "@jellyfin/sdk/lib/utils/api";
import { useRoute } from "@react-navigation/native";
import { FlashList } from "@shopify/flash-list"; import { FlashList } from "@shopify/flash-list";
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import { useLocalSearchParams } from "expo-router"; import { useLocalSearchParams } from "expo-router";
import { useRoute } from "expo-router/react-navigation";
import { useAtom } from "jotai"; import { useAtom } from "jotai";
import { useCallback, useMemo, useState } from "react"; import { useCallback, useMemo, useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";

View File

@@ -66,7 +66,7 @@ const exampleSearches = [
"The Mandalorian", "The Mandalorian",
]; ];
export default function SearchPage() { export default function search() {
const params = useLocalSearchParams(); const params = useLocalSearchParams();
const insets = useSafeAreaInsets(); const insets = useSafeAreaInsets();
const router = useRouter(); const router = useRouter();
@@ -221,7 +221,7 @@ export default function SearchPage() {
const ids = response1.data.ids; const ids = response1.data.ids;
if (!ids?.length) { if (!ids || !ids.length) {
return []; return [];
} }

View File

@@ -3,11 +3,11 @@ import {
type NativeBottomTabNavigationEventMap, type NativeBottomTabNavigationEventMap,
type NativeBottomTabNavigationOptions, type NativeBottomTabNavigationOptions,
} from "@bottom-tabs/react-navigation"; } from "@bottom-tabs/react-navigation";
import { withLayoutContext } from "expo-router";
import type { import type {
ParamListBase, ParamListBase,
TabNavigationState, TabNavigationState,
} from "expo-router/react-navigation"; } from "@react-navigation/native";
import { withLayoutContext } from "expo-router";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { Platform, View } from "react-native"; import { Platform, View } from "react-native";
import { SystemBars } from "react-native-edge-to-edge"; import { SystemBars } from "react-native-edge-to-edge";

View File

@@ -63,7 +63,7 @@ import { writeToLog } from "@/utils/log";
import { msToTicks, ticksToSeconds } from "@/utils/time"; import { msToTicks, ticksToSeconds } from "@/utils/time";
import { generateDeviceProfile } from "../../../utils/profiles/native"; import { generateDeviceProfile } from "../../../utils/profiles/native";
export default function DirectPlayerPage() { export default function page() {
const videoRef = useRef<MpvPlayerViewRef>(null); const videoRef = useRef<MpvPlayerViewRef>(null);
const user = useAtomValue(userAtom); const user = useAtomValue(userAtom);
const api = useAtomValue(apiAtom); const api = useAtomValue(apiAtom);
@@ -185,11 +185,11 @@ export default function DirectPlayerPage() {
return undefined; return undefined;
}, [audioIndexFromUrl, offline, downloadedItem?.userData?.audioStreamIndex]); }, [audioIndexFromUrl, offline, downloadedItem?.userData?.audioStreamIndex]);
// Initialize TV audio/subtitle indices from URL params. // Initialize TV audio/subtitle indices from URL params
// No undefined guard: when a new episode's URL omits audioIndex, reset to
// undefined (media default) rather than leaking the previous episode's track.
useEffect(() => { useEffect(() => {
setCurrentAudioIndex(audioIndex); if (audioIndex !== undefined) {
setCurrentAudioIndex(audioIndex);
}
}, [audioIndex]); }, [audioIndex]);
useEffect(() => { useEffect(() => {
@@ -317,7 +317,7 @@ export default function DirectPlayerPage() {
} }
let result: Stream | null = null; let result: Stream | null = null;
if (offline && downloadedItem?.mediaSource) { if (offline && downloadedItem && downloadedItem.mediaSource) {
const url = downloadedItem.videoFilePath; const url = downloadedItem.videoFilePath;
if (item) { if (item) {
result = { result = {
@@ -470,11 +470,8 @@ export default function DirectPlayerPage() {
return { return {
ItemId: item.Id, ItemId: item.Id,
// Report the live selection so server-side session/resume state reflects AudioStreamIndex: audioIndex ? audioIndex : undefined,
// mid-playback track changes. Note: index 0 is valid (don't treat as SubtitleStreamIndex: subtitleIndex ? subtitleIndex : undefined,
// falsy); -1 means "off" and is reported as-is.
AudioStreamIndex: currentAudioIndex,
SubtitleStreamIndex: currentSubtitleIndex,
MediaSourceId: mediaSourceId, MediaSourceId: mediaSourceId,
PositionTicks: msToTicks(progress.get()), PositionTicks: msToTicks(progress.get()),
IsPaused: !isPlaying, IsPaused: !isPlaying,
@@ -488,8 +485,8 @@ export default function DirectPlayerPage() {
}, [ }, [
stream, stream,
item?.Id, item?.Id,
currentAudioIndex, audioIndex,
currentSubtitleIndex, subtitleIndex,
mediaSourceId, mediaSourceId,
progress, progress,
isPlaying, isPlaying,
@@ -556,8 +553,8 @@ export default function DirectPlayerPage() {
}, },
[ [
item?.Id, item?.Id,
currentAudioIndex, audioIndex,
currentSubtitleIndex, subtitleIndex,
mediaSourceId, mediaSourceId,
isPlaying, isPlaying,
stream, stream,
@@ -825,10 +822,12 @@ export default function DirectPlayerPage() {
], ],
); );
/** PiP handler for MPV */
const _onPictureInPictureChange = useCallback( const _onPictureInPictureChange = useCallback(
(e: { nativeEvent: { isActive: boolean } }) => { (e: { nativeEvent: { isActive: boolean } }) => {
const { isActive } = e.nativeEvent; const { isActive } = e.nativeEvent;
setIsPipMode(isActive); setIsPipMode(isActive);
// Hide controls when entering PiP
if (isActive) { if (isActive) {
_setShowControls(false); _setShowControls(false);
} }
@@ -846,9 +845,6 @@ export default function DirectPlayerPage() {
// Memoize video ref functions to prevent unnecessary re-renders // Memoize video ref functions to prevent unnecessary re-renders
const startPictureInPicture = useCallback(async () => { const startPictureInPicture = useCallback(async () => {
// Hide controls BEFORE entering PiP so the window captures a clean view
_setShowControls(false);
setIsPipMode(true);
return videoRef.current?.startPictureInPicture?.(); return videoRef.current?.startPictureInPicture?.();
}, []); }, []);
@@ -1013,9 +1009,8 @@ export default function DirectPlayerPage() {
subtitleIndex: defaultSubtitleIndex, subtitleIndex: defaultSubtitleIndex,
} = getDefaultPlaySettings(previousItem, settings, { } = getDefaultPlaySettings(previousItem, settings, {
indexes: { indexes: {
// Use the live selection, not the stale URL params (see goToNextItem). subtitleIndex: subtitleIndex,
subtitleIndex: currentSubtitleIndex, audioIndex: audioIndex,
audioIndex: currentAudioIndex,
}, },
source: stream?.mediaSource ?? undefined, source: stream?.mediaSource ?? undefined,
}); });
@@ -1034,8 +1029,8 @@ export default function DirectPlayerPage() {
}, [ }, [
previousItem, previousItem,
settings, settings,
currentSubtitleIndex, subtitleIndex,
currentAudioIndex, audioIndex,
stream?.mediaSource, stream?.mediaSource,
bitrateValue, bitrateValue,
router, router,
@@ -1080,10 +1075,8 @@ export default function DirectPlayerPage() {
subtitleIndex: defaultSubtitleIndex, subtitleIndex: defaultSubtitleIndex,
} = getDefaultPlaySettings(nextItem, settings, { } = getDefaultPlaySettings(nextItem, settings, {
indexes: { indexes: {
// Use the live selection (updated when the user changes tracks subtitleIndex: subtitleIndex,
// mid-playback), not the stale URL params the episode started with. audioIndex: audioIndex,
subtitleIndex: currentSubtitleIndex,
audioIndex: currentAudioIndex,
}, },
source: stream?.mediaSource ?? undefined, source: stream?.mediaSource ?? undefined,
}); });
@@ -1102,8 +1095,8 @@ export default function DirectPlayerPage() {
}, [ }, [
nextItem, nextItem,
settings, settings,
currentSubtitleIndex, subtitleIndex,
currentAudioIndex, audioIndex,
stream?.mediaSource, stream?.mediaSource,
bitrateValue, bitrateValue,
router, router,
@@ -1254,7 +1247,6 @@ export default function DirectPlayerPage() {
nowPlayingMetadata={nowPlayingMetadata} nowPlayingMetadata={nowPlayingMetadata}
onProgress={onProgress} onProgress={onProgress}
onPlaybackStateChange={onPlaybackStateChanged} onPlaybackStateChange={onPlaybackStateChanged}
onPictureInPictureChange={_onPictureInPictureChange}
onLoad={() => setIsVideoLoaded(true)} onLoad={() => setIsVideoLoaded(true)}
onError={(e: { nativeEvent: MpvOnErrorEventPayload }) => { onError={(e: { nativeEvent: MpvOnErrorEventPayload }) => {
console.error("Video Error:", e.nativeEvent); console.error("Video Error:", e.nativeEvent);

View File

@@ -1248,7 +1248,7 @@ const styles = StyleSheet.create({
color: "#fff", color: "#fff",
}, },
downloadingOverlay: { downloadingOverlay: {
...StyleSheet.absoluteFill, ...StyleSheet.absoluteFillObject,
backgroundColor: "rgba(0,0,0,0.5)", backgroundColor: "rgba(0,0,0,0.5)",
borderRadius: scaleSize(14), borderRadius: scaleSize(14),
justifyContent: "center", justifyContent: "center",

View File

@@ -2,12 +2,12 @@ import "@/augmentations";
import { ActionSheetProvider } from "@expo/react-native-action-sheet"; import { ActionSheetProvider } from "@expo/react-native-action-sheet";
import { BottomSheetModalProvider } from "@gorhom/bottom-sheet"; import { BottomSheetModalProvider } from "@gorhom/bottom-sheet";
import NetInfo from "@react-native-community/netinfo"; import NetInfo from "@react-native-community/netinfo";
import { DarkTheme, ThemeProvider } from "@react-navigation/native";
import { createSyncStoragePersister } from "@tanstack/query-sync-storage-persister"; import { createSyncStoragePersister } from "@tanstack/query-sync-storage-persister";
import { onlineManager, QueryClient } from "@tanstack/react-query"; import { onlineManager, QueryClient } from "@tanstack/react-query";
import { PersistQueryClientProvider } from "@tanstack/react-query-persist-client"; import { PersistQueryClientProvider } from "@tanstack/react-query-persist-client";
import * as BackgroundTask from "expo-background-task"; import * as BackgroundTask from "expo-background-task";
import * as Device from "expo-device"; import * as Device from "expo-device";
import { DarkTheme, ThemeProvider } from "expo-router/react-navigation";
import { Platform } from "react-native"; import { Platform } from "react-native";
import { GlobalModal } from "@/components/GlobalModal"; import { GlobalModal } from "@/components/GlobalModal";
import { enableTVMenuKeyInterception } from "@/hooks/useTVBackHandler"; import { enableTVMenuKeyInterception } from "@/hooks/useTVBackHandler";
@@ -395,9 +395,8 @@ function Layout() {
maxAge: 1000 * 60 * 60 * 24, // 24 hours max cache age maxAge: 1000 * 60 * 60 * 24, // 24 hours max cache age
dehydrateOptions: { dehydrateOptions: {
shouldDehydrateQuery: (query) => { shouldDehydrateQuery: (query) => {
return ( // Only persist successful queries
query.state.status === "success" && query.options.gcTime !== 0 return query.state.status === "success";
);
}, },
}, },
}} }}

View File

@@ -1,5 +1,5 @@
{ {
"$schema": "https://biomejs.dev/schemas/2.4.16/schema.json", "$schema": "https://biomejs.dev/schemas/2.3.11/schema.json",
"files": { "files": {
"includes": [ "includes": [
"**/*", "**/*",

View File

@@ -0,0 +1,29 @@
diff --git a/lib/generators/modules/GenerateModuleObjCpp/index.js b/lib/generators/modules/GenerateModuleObjCpp/index.js
index 927711514d2deaa3c795fb98e676e0a1f596eddc..0364d66204a76fccd3e06a0dc72bf801aa04a50d 100644
--- a/lib/generators/modules/GenerateModuleObjCpp/index.js
+++ b/lib/generators/modules/GenerateModuleObjCpp/index.js
@@ -67,9 +67,12 @@ const HeaderFileTemplate = ({
* must have a single output. More files => more genrule()s => slower builds.
*/
-#ifndef __cplusplus
-#error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm.
-#endif
+// Patched: guard the Obj-C++ body with __cplusplus instead of hard-#error-ing.
+// With use_frameworks! :static + New Arch, plain Obj-C .m TUs can trigger a
+// Clang module build (via Swift-interop -Swift.h umbrellas) that pulls this
+// header in Obj-C mode. Skipping the body (instead of erroring) lets the module
+// build; .mm consumers still get the full Obj-C++ contents unchanged.
+#if defined(__cplusplus)
// Avoid multiple includes of ${headerFileNameWithNoExt} symbols
#ifndef ${headerFileNameWithNoExt}_H
@@ -93,7 +96,7 @@ const HeaderFileTemplate = ({
structInlineMethods +
(assumeNonnull ? '\nNS_ASSUME_NONNULL_END\n' : '\n') +
`#endif // ${headerFileNameWithNoExt}_H` +
- '\n'
+ '\n#endif // defined(__cplusplus)\n'
);
};
const SourceFileTemplate = ({headerFileName, moduleImplementations}) => `/**

View File

@@ -1,28 +0,0 @@
diff --git a/ios/Sources/Extensions+Helpers/RCTView+Helpers.swift b/ios/Sources/Extensions+Helpers/RCTView+Helpers.swift
index 09be306d5aa39337c5114c2ad6ba7513218e0751..24ff8ee2c36fef8632a7e012514fd04db9bf89fd 100644
--- a/ios/Sources/Extensions+Helpers/RCTView+Helpers.swift
+++ b/ios/Sources/Extensions+Helpers/RCTView+Helpers.swift
@@ -25,15 +25,14 @@ public extension RCTView {
return rootView.recursivelyFindSubview(whereType: targetType);
};
- var closestParentReactContentView: RCTRootContentView? {
- let targetType = RCTRootContentView.self;
-
- if let match = self.recursivelyFindParentView(whereType: targetType) {
- return match;
- };
-
- guard let rootView = self.rootViewForCurrentWindow else { return nil };
- return rootView.recursivelyFindSubview(whereType: targetType);
+ // PATCH (streamyfin): RCTRootContentView is a legacy paper class that the prebuilt
+ // new-architecture React (RN 0.85) does not export, so any reference to it fails to
+ // link (Undefined symbols: _OBJC_CLASS_$_RCTRootContentView). The app runs the new
+ // architecture, where this content-view lookup is unused; short-circuit to nil.
+ // Return type widened to RCTView? so the caller's `.reactTouchHandlers` (an RCTView
+ // extension) still resolves.
+ var closestParentReactContentView: RCTView? {
+ return nil;
};
var reactTouchHandlers: [RCTTouchHandler]? {

View File

@@ -0,0 +1,191 @@
diff --git a/node_modules/react-native-screens/.bun-tag-10a3b0add1bd4de6 b/.bun-tag-10a3b0add1bd4de6
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/node_modules/react-native-screens/.bun-tag-6a8504b742d5cfff b/.bun-tag-6a8504b742d5cfff
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/node_modules/react-native-screens/.bun-tag-d28396854bc27a3d b/.bun-tag-d28396854bc27a3d
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/ios/RNSScreenStack.mm b/ios/RNSScreenStack.mm
index 51f021831aed26a4eed3c85014020423b7b3108b..2f621547932806b94ab1e75ecc73772facd209d0 100644
--- a/ios/RNSScreenStack.mm
+++ b/ios/RNSScreenStack.mm
@@ -34,6 +34,11 @@
#import "integrations/RNSDismissibleModalProtocol.h"
#import "utils/UINavigationBar+RNSUtility.h"
+#if TARGET_OS_TV
+#import <React/RCTTVNavigationEventNotification.h>
+#import <React/RCTTVRemoteHandler.h>
+#endif // TARGET_OS_TV
+
#ifdef RNS_GAMMA_ENABLED
#import "RNSFrameCorrectionProvider.h"
#import "Swift-Bridging.h"
@@ -43,6 +48,12 @@
namespace react = facebook::react;
#endif // RCT_NEW_ARCH_ENABLED
+#if TARGET_OS_TV
+@interface RNSNavigationController ()
+@property (nonatomic, strong) UITapGestureRecognizer *rnscreens_menuGestureRecognizer;
+@end
+#endif // TARGET_OS_TV
+
@interface RNSScreenStackView () <
UINavigationControllerDelegate,
UIAdaptivePresentationControllerDelegate,
@@ -62,6 +73,57 @@ namespace react = facebook::react;
@implementation RNSNavigationController
+#if TARGET_OS_TV
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+
+ self.rnscreens_menuGestureRecognizer =
+ [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(rnscreens_menuPressed:)];
+ self.rnscreens_menuGestureRecognizer.allowedPressTypes = @[ @(UIPressTypeMenu) ];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(rnscreens_enableMenuGesture)
+ name:RCTTVEnableMenuKeyNotification
+ object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(rnscreens_disableMenuGesture)
+ name:RCTTVDisableMenuKeyNotification
+ object:nil];
+
+ if ([RCTTVRemoteHandler useMenuKey]) {
+ [self rnscreens_enableMenuGesture];
+ }
+}
+
+- (void)dealloc
+{
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+}
+
+- (void)rnscreens_enableMenuGesture
+{
+ if (![self.view.gestureRecognizers containsObject:self.rnscreens_menuGestureRecognizer]) {
+ [self.view addGestureRecognizer:self.rnscreens_menuGestureRecognizer];
+ }
+}
+
+- (void)rnscreens_disableMenuGesture
+{
+ if ([self.view.gestureRecognizers containsObject:self.rnscreens_menuGestureRecognizer]) {
+ [self.view removeGestureRecognizer:self.rnscreens_menuGestureRecognizer];
+ }
+}
+
+- (void)rnscreens_menuPressed:(UIGestureRecognizer *)recognizer
+{
+ [[NSNotificationCenter defaultCenter] postNavigationPressEventWithType:RCTTVRemoteEventMenu
+ keyAction:recognizer.eventKeyAction
+ tag:nil
+ target:nil];
+}
+#endif // TARGET_OS_TV
+
#if !TARGET_OS_TV
- (UIViewController *)childViewControllerForStatusBarStyle
{
diff --git a/ios/gamma/split-view/RNSSplitViewAppearanceApplicator.swift b/ios/gamma/split-view/RNSSplitViewAppearanceApplicator.swift
index 95c76ccf3528d3a8828e90b272a1d79b0828a139..f29d4df21440d23523ae7a2f6fe71c32154e3928 100644
--- a/ios/gamma/split-view/RNSSplitViewAppearanceApplicator.swift
+++ b/ios/gamma/split-view/RNSSplitViewAppearanceApplicator.swift
@@ -79,11 +79,13 @@ class RNSSplitViewAppearanceApplicator {
maxWidth: splitView.maximumSupplementaryColumnWidth)
#if compiler(>=6.2)
+ #if !os(tvOS)
if #available(iOS 26.0, *) {
validateColumnConstraints(
minWidth: splitView.minimumInspectorColumnWidth,
maxWidth: splitView.maximumInspectorColumnWidth)
}
+ #endif
#endif
// Step 2.2 - applying updates to columns
@@ -126,6 +128,7 @@ class RNSSplitViewAppearanceApplicator {
}
#if compiler(>=6.2)
+ #if !os(tvOS)
if #available(iOS 26.0, *) {
if splitView.minimumSecondaryColumnWidth >= 0 {
splitViewController.minimumSecondaryColumnWidth = splitView.minimumSecondaryColumnWidth
@@ -159,6 +162,7 @@ class RNSSplitViewAppearanceApplicator {
splitView.preferredInspectorColumnWidthOrFraction
}
}
+ #endif
#endif
// Step 2.3 - manipulating with inspector column
diff --git a/ios/gamma/split-view/RNSSplitViewHostController.swift b/ios/gamma/split-view/RNSSplitViewHostController.swift
index 0421e3ea92fc7bcdf57417b5ee3a62348fce34f5..cd878ab638d3c78a661e2df4c4c1b21011dfcf48 100644
--- a/ios/gamma/split-view/RNSSplitViewHostController.swift
+++ b/ios/gamma/split-view/RNSSplitViewHostController.swift
@@ -386,7 +386,7 @@ extension RNSSplitViewHostController: RNSSplitViewNavigationControllerViewFrameO
/// @param inspectors An array of inspector-type RNSSplitViewScreenComponentView subviews.
///
func maybeSetupInspector(_ inspectors: [RNSSplitViewScreenComponentView]) {
-
+ #if !os(tvOS)
if #available(iOS 26.0, *) {
let inspector = inspectors.first
if inspector != nil {
@@ -395,6 +395,7 @@ extension RNSSplitViewHostController: RNSSplitViewNavigationControllerViewFrameO
setViewController(inspectorViewController, for: .inspector)
}
}
+ #endif
}
///
@@ -404,9 +405,11 @@ extension RNSSplitViewHostController: RNSSplitViewNavigationControllerViewFrameO
/// Uses the UISplitViewController's new API introduced in iOS 26 to show the inspector column.
///
func maybeShowInspector() {
+ #if !os(tvOS)
if #available(iOS 26.0, *) {
show(.inspector)
}
+ #endif
}
///
@@ -416,9 +419,11 @@ extension RNSSplitViewHostController: RNSSplitViewNavigationControllerViewFrameO
/// Uses the UISplitViewController's new API introduced in iOS 26 to hide the inspector column.
///
func maybeHideInspector() {
+ #if !os(tvOS)
if #available(iOS 26.0, *) {
hide(.inspector)
}
+ #endif
}
}
#endif
@@ -444,6 +449,7 @@ extension RNSSplitViewHostController: UISplitViewControllerDelegate {
public func splitViewController(
_ svc: UISplitViewController, didHide column: UISplitViewController.Column
) {
+ #if !os(tvOS)
if #available(iOS 26.0, *) {
// TODO: we may consider removing this logic, because it could be handled by onViewDidDisappear on the column level
// On the other hand, maybe dedicated event related to the inspector would be a better approach.
@@ -461,6 +467,7 @@ extension RNSSplitViewHostController: UISplitViewControllerDelegate {
}
}
}
+ #endif
}
#endif

703
bun.lock

File diff suppressed because it is too large Load Diff

View File

@@ -9,7 +9,6 @@ import type {
BaseItemDto, BaseItemDto,
MediaSourceInfo, MediaSourceInfo,
} from "@jellyfin/sdk/lib/generated-client/models"; } from "@jellyfin/sdk/lib/generated-client/models";
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api";
import { type Href } from "expo-router"; import { type Href } from "expo-router";
import { t } from "i18next"; import { t } from "i18next";
import { useAtom } from "jotai"; import { useAtom } from "jotai";
@@ -200,30 +199,9 @@ export const DownloadItems: React.FC<DownloadProps> = ({
); );
} }
const downloadDetailsPromises = items.map(async (item) => { const downloadDetailsPromises = items.map(async (item) => {
// Ensure the snapshot we store offline carries the Chapters array.
// Page-level fetches sometimes use a fields filter that omits it; the
// offline player would then render no chapter ticks / list.
let itemForDownload = item;
if (!itemForDownload.Chapters && itemForDownload.Id) {
try {
const enriched = await getUserLibraryApi(api).getItem({
itemId: itemForDownload.Id,
userId: user.Id!,
});
if (enriched.data) {
itemForDownload = enriched.data;
}
} catch (e) {
console.warn(
"[DownloadItem] failed to refresh item for Chapters, falling back to original",
e,
);
}
}
const { mediaSource, audioIndex, subtitleIndex } = const { mediaSource, audioIndex, subtitleIndex } =
itemsNotDownloaded.length > 1 itemsNotDownloaded.length > 1
? getDefaultPlaySettings(itemForDownload, settings!) ? getDefaultPlaySettings(item, settings!)
: { : {
mediaSource: selectedOptions?.mediaSource, mediaSource: selectedOptions?.mediaSource,
audioIndex: selectedOptions?.audioIndex, audioIndex: selectedOptions?.audioIndex,
@@ -232,7 +210,7 @@ export const DownloadItems: React.FC<DownloadProps> = ({
const downloadDetails = await getDownloadUrl({ const downloadDetails = await getDownloadUrl({
api, api,
item: itemForDownload, item,
userId: user.Id!, userId: user.Id!,
mediaSource: mediaSource!, mediaSource: mediaSource!,
audioStreamIndex: audioIndex ?? -1, audioStreamIndex: audioIndex ?? -1,
@@ -244,7 +222,7 @@ export const DownloadItems: React.FC<DownloadProps> = ({
return { return {
url: downloadDetails?.url, url: downloadDetails?.url,
item: itemForDownload, item,
mediaSource: downloadDetails?.mediaSource, mediaSource: downloadDetails?.mediaSource,
}; };
}); });

View File

@@ -1,3 +1,11 @@
import {
Button,
Host,
Menu,
Picker,
Text as SwiftUIText,
} from "@expo/ui/swift-ui";
import { disabled, tag } from "@expo/ui/swift-ui/modifiers";
import { Ionicons } from "@expo/vector-icons"; import { Ionicons } from "@expo/vector-icons";
import { BottomSheetScrollView } from "@gorhom/bottom-sheet"; import { BottomSheetScrollView } from "@gorhom/bottom-sheet";
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
@@ -12,17 +20,6 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
import { Text } from "@/components/common/Text"; import { Text } from "@/components/common/Text";
import { useGlobalModal } from "@/providers/GlobalModalProvider"; import { useGlobalModal } from "@/providers/GlobalModalProvider";
// @expo/ui's SwiftUI native module (ExpoUI) does not exist in tvOS builds.
// A static top-level import evaluates requireNativeModule('ExpoUI') at module
// load and crashes the entire route tree on tvOS (expo-router requires every
// route file). Load it lazily and only off-TV; TV never renders these.
const { Button, Host, Menu } = Platform.isTV
? ({} as typeof import("@expo/ui/swift-ui"))
: require("@expo/ui/swift-ui");
const { disabled } = Platform.isTV
? ({} as typeof import("@expo/ui/swift-ui/modifiers"))
: require("@expo/ui/swift-ui/modifiers");
// Option types // Option types
export type RadioOption<T = any> = { export type RadioOption<T = any> = {
type: "radio"; type: "radio";
@@ -264,29 +261,25 @@ const PlatformDropdownComponent = ({
} }
}, [isVisible, controlledOpen, controlledOnOpenChange]); }, [isVisible, controlledOpen, controlledOnOpenChange]);
if (Platform.OS === "ios" && !Platform.isTV) { if (Platform.OS === "ios") {
// Pin the wrapper to the measured trigger size. @expo/ui's <Host> (SDK 55)
// fills its parent and reports its own size via setStyleSize, so it can't
// size itself to content. If the wrapper has no size, the Host's `flex: 1`
// height depends on the parent while the parent depends on the Host — a
// circular dependency that collapses to 0 for any selector nested more than
// one level deep (so only the first, shallowest dropdown stays visible).
// Giving the wrapper the measured size breaks the cycle; the Host then
// fills a concrete box.
return ( return (
<View style={triggerSize ?? { opacity: 0 }}> <View>
{/* Hidden measurer: lays the trigger out off-flow to capture its {/* Hidden measurer: lays the trigger out normally to capture its
intrinsic size. Absolutely positioned WITHOUT right/bottom so it intrinsic size, which we then pin onto the Host below. */}
sizes to the trigger's content rather than to its parent. */} <View style={StyleSheet.absoluteFill} pointerEvents='none' aria-hidden>
<View <View
style={{ position: "absolute", top: 0, left: 0, opacity: 0 }} style={{ alignSelf: "flex-start" }}
pointerEvents='none' onLayout={handleMeasureTrigger}
aria-hidden >
onLayout={handleMeasureTrigger} {trigger}
> </View>
{trigger}
</View> </View>
<Host style={[StyleSheet.absoluteFill, expoUIConfig?.hostStyle as any]}> <Host
style={[
triggerSize ?? { opacity: 0 },
expoUIConfig?.hostStyle as any,
]}
>
<Menu label={trigger}> <Menu label={trigger}>
{groups.flatMap((group, groupIndex) => { {groups.flatMap((group, groupIndex) => {
// Check if this group has radio options // Check if this group has radio options
@@ -302,40 +295,41 @@ const PlatformDropdownComponent = ({
const items = []; const items = [];
// Group radio options under a submenu ONLY if there's a title // Add Picker for radio options ONLY if there's a group title
// Otherwise render as individual buttons // Otherwise render as individual buttons
if (radioOptions.length > 0) { if (radioOptions.length > 0) {
if (group.title) { if (group.title) {
// Use a nested Menu as a submenu for grouped options. This // Use Picker for grouped options.
// reads as "Title: Selected" and expands to the choices on // Use the option index (a stable primitive) as the
// tap, keeping the nested look while staying a dropdown. // tag/selection value and React key. Option `value`s can be
// (Menu opens on a single tap and nests cleanly; ContextMenu // objects (e.g. bitrate / media source), which collapse to
// would require a long-press and read as a context menu.) // "[object Object]" as a key and never match the Picker's
const selectedOption = radioOptions.find( // primitive selection.
const selectedRadioIndex = radioOptions.findIndex(
(opt) => opt.selected, (opt) => opt.selected,
); );
const displayTitle = selectedOption
? `${group.title}: ${selectedOption.label}`
: group.title;
items.push( items.push(
<Menu key={`submenu-${groupIndex}`} label={displayTitle}> <Picker
{radioOptions.map((option, optionIndex) => ( key={`picker-${groupIndex}`}
<Button label={group.title}
selection={
selectedRadioIndex >= 0 ? selectedRadioIndex : undefined
}
onSelectionChange={(index) => {
const selectedOption = radioOptions[index as number];
selectedOption?.onPress();
onOptionSelect?.(selectedOption?.value);
}}
>
{radioOptions.map((opt, optionIndex) => (
<SwiftUIText
key={`radio-${groupIndex}-${optionIndex}`} key={`radio-${groupIndex}-${optionIndex}`}
label={option.label} modifiers={[tag(optionIndex)]}
systemImage={ >
option.selected ? "checkmark.circle.fill" : "circle" {opt.label}
} </SwiftUIText>
modifiers={
option.disabled ? [disabled(true)] : undefined
}
onPress={() => {
option.onPress();
onOptionSelect?.(option.value);
}}
/>
))} ))}
</Menu>, </Picker>,
); );
} else { } else {
// Render radio options as direct buttons // Render radio options as direct buttons

View File

@@ -414,7 +414,7 @@ export const PlayButton: React.FC<Props> = ({
]); ]);
const derivedTargetWidth = useDerivedValue(() => { const derivedTargetWidth = useDerivedValue(() => {
if (!item?.RunTimeTicks) return 0; if (!item || !item.RunTimeTicks) return 0;
const userData = item.UserData; const userData = item.UserData;
if (userData?.PlaybackPositionTicks) { if (userData?.PlaybackPositionTicks) {
return userData.PlaybackPositionTicks > 0 return userData.PlaybackPositionTicks > 0

View File

@@ -78,7 +78,7 @@ export const PlayButton: React.FC<Props> = ({
}; };
const derivedTargetWidth = useDerivedValue(() => { const derivedTargetWidth = useDerivedValue(() => {
if (!item?.RunTimeTicks) return 0; if (!item || !item.RunTimeTicks) return 0;
const userData = item.UserData; const userData = item.UserData;
if (userData?.PlaybackPositionTicks) { if (userData?.PlaybackPositionTicks) {
return userData.PlaybackPositionTicks > 0 return userData.PlaybackPositionTicks > 0

View File

@@ -1,196 +0,0 @@
/**
* A modal listing an item's chapters. Each row shows the chapter name and its
* timestamp; the current chapter is highlighted. Tapping a row seeks to that
* chapter and closes the modal. Player-agnostic — the seek is injected.
*/
import { Ionicons } from "@expo/vector-icons";
import type { ChapterInfo } from "@jellyfin/sdk/lib/generated-client/models";
import { memo, useEffect, useMemo, useRef } from "react";
import { useTranslation } from "react-i18next";
import { FlatList, Modal, Pressable, StyleSheet, View } from "react-native";
import { Text } from "@/components/common/Text";
import { Colors } from "@/constants/Colors";
import {
type ChapterEntry,
chapterStartsMs,
formatChapterTime,
sortedChapters,
} from "@/utils/chapters";
interface ChapterListProps {
visible: boolean;
chapters: ChapterInfo[] | null | undefined;
/** Current playback position in milliseconds (to highlight the row). */
currentPositionMs: number;
/** Seek the player to this millisecond position. */
onSeek: (positionMs: number) => void;
onClose: () => void;
}
const ROW_HEIGHT = 48;
function ChapterListComponent({
visible,
chapters,
currentPositionMs,
onSeek,
onClose,
}: ChapterListProps) {
const { t } = useTranslation();
const listRef = useRef<FlatList<ChapterEntry>>(null);
const entries = useMemo(() => sortedChapters(chapters), [chapters]);
// Memoize starts so currentChapterIndex computation doesn't re-sort/filter
// every tick — chapters is the only input that drives the underlying array.
const starts = useMemo(() => chapterStartsMs(chapters), [chapters]);
const activeIndex = useMemo(() => {
let idx = -1;
for (let i = 0; i < starts.length; i++) {
if (currentPositionMs >= starts[i]) idx = i;
else break;
}
return idx;
}, [currentPositionMs, starts]);
// FlatList.initialScrollIndex only fires at first mount; <Modal> keeps its
// children mounted across visible toggles, so subsequent opens never scroll.
// Trigger an imperative scroll each time the sheet becomes visible.
useEffect(() => {
if (!visible || activeIndex < 0 || entries.length === 0) return;
const raf = requestAnimationFrame(() => {
listRef.current?.scrollToIndex({
index: activeIndex,
animated: false,
viewPosition: 0.5,
});
});
return () => cancelAnimationFrame(raf);
}, [visible, activeIndex, entries.length]);
return (
<Modal
visible={visible}
transparent
animationType='slide'
onRequestClose={onClose}
>
<Pressable onPress={onClose} style={styles.backdrop}>
<Pressable onPress={(e) => e.stopPropagation()} style={styles.sheet}>
<View style={styles.header}>
<Text style={styles.title}>{t("chapters.title")}</Text>
<Pressable
onPress={onClose}
hitSlop={10}
accessibilityRole='button'
accessibilityLabel={t("chapters.close")}
>
<Ionicons name='close' size={24} color={Colors.text} />
</Pressable>
</View>
<FlatList
ref={listRef}
data={entries}
keyExtractor={(item, index) => `${item.positionMs}-${index}`}
getItemLayout={(_, index) => ({
length: ROW_HEIGHT,
offset: ROW_HEIGHT * index,
index,
})}
onScrollToIndexFailed={(info) => {
// Required when getItemLayout is provided and the target index
// is outside the currently rendered window. Fallback to an
// offset-based scroll, then retry the precise scroll once a
// frame has elapsed.
listRef.current?.scrollToOffset({
offset: info.averageItemLength * info.index,
animated: false,
});
setTimeout(() => {
listRef.current?.scrollToIndex({
index: info.index,
animated: false,
viewPosition: 0.5,
});
}, 50);
}}
renderItem={({ item, index }) => {
const positionMs = item.positionMs;
const isActive = index === activeIndex;
return (
<Pressable
onPress={() => {
onSeek(positionMs);
onClose();
}}
style={[
styles.row,
isActive && { backgroundColor: `${Colors.primary}33` },
]}
>
<Text
style={[
styles.rowText,
{ color: isActive ? Colors.primary : Colors.text },
]}
numberOfLines={1}
>
{item.chapter.Name ||
t("chapters.chapter_number", { number: index + 1 })}
</Text>
<Text style={styles.rowTime}>
{formatChapterTime(positionMs)}
</Text>
</Pressable>
);
}}
/>
</Pressable>
</Pressable>
</Modal>
);
}
export const ChapterList = memo(ChapterListComponent);
const styles = StyleSheet.create({
backdrop: {
flex: 1,
justifyContent: "flex-end",
backgroundColor: "rgba(0,0,0,0.6)",
},
sheet: {
backgroundColor: Colors.background,
borderTopLeftRadius: 16,
borderTopRightRadius: 16,
maxHeight: "70%",
paddingBottom: 24,
},
header: {
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
padding: 16,
},
title: {
color: Colors.text,
fontSize: 17,
fontWeight: "700",
},
row: {
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
paddingHorizontal: 16,
height: ROW_HEIGHT,
},
rowText: {
fontSize: 15,
flex: 1,
},
rowTime: {
color: Colors.icon,
fontSize: 13,
marginLeft: 12,
},
});

View File

@@ -1,87 +0,0 @@
/**
* Chapter tick marks drawn as an absolute overlay over a progress slider.
* Renders nothing for media with one or zero chapters. `pointerEvents: "none"`
* so the slider underneath still receives touches.
*/
import { memo, useState } from "react";
import { type LayoutChangeEvent, PixelRatio, View } from "react-native";
import type { ChapterMarker } from "@/utils/chapters";
interface ChapterTicksProps {
/** Pre-computed markers (caller memoizes — avoids double-computing here). */
markers: ChapterMarker[];
/** Tick colour. */
color?: string;
/** Tick height in px — slightly less than the slider track thickness. */
height?: number;
/** Tick width in px — integer to avoid sub-pixel anti-aliasing. */
width?: number;
}
function ChapterTicksComponent({
markers,
// Semi-transparent black contrasts against both the filled progress
// (#fff) and the unfilled track (rgba(255,255,255,0.2)) so the ticks
// stay visible across the whole bar as playback advances.
color = "rgba(0,0,0,0.55)",
height = 14,
width = 2,
}: ChapterTicksProps) {
// Hooks must run unconditionally — keep them before any early return.
const [sliderWidth, setSliderWidth] = useState(0);
const handleLayout = (e: LayoutChangeEvent) => {
setSliderWidth(e.nativeEvent.layout.width);
};
// One chapter (typically a single marker at 0) is not worth marking.
if (markers.length <= 1) return null;
return (
<View
pointerEvents='none'
onLayout={handleLayout}
style={{
position: "absolute",
left: 0,
right: 0,
top: 0,
bottom: 0,
// Let ticks taller than this container bleed beyond its bounds.
overflow: "visible",
}}
>
{sliderWidth > 0 &&
markers
// Skip the leading 0ms marker — it overlaps the slider start and
// adds visual noise at an already-rendered boundary.
.filter((marker) => marker.positionMs > 0)
.map((marker, index) => {
// Align both the position AND the width onto the device's
// physical pixel grid. Without this, fractional dp values land
// at different sub-pixel fractions per tick — Android samples
// each one differently and some ticks render visibly thicker.
const centerDp = (marker.percent / 100) * sliderWidth;
const left = PixelRatio.roundToNearestPixel(centerDp - width / 2);
const snappedWidth = PixelRatio.roundToNearestPixel(width);
return (
<View
key={`${marker.positionMs}-${index}`}
style={{
position: "absolute",
left,
top: "50%",
marginTop: -height / 2,
height,
width: snappedWidth,
backgroundColor: color,
}}
/>
);
})}
</View>
);
}
export const ChapterTicks = memo(ChapterTicksComponent);

View File

@@ -10,7 +10,6 @@ import {
type TextInputProps, type TextInputProps,
View, View,
} from "react-native"; } from "react-native";
import { useScaledTVTypography } from "@/constants/TVTypography";
interface InputProps extends TextInputProps { interface InputProps extends TextInputProps {
extraClassName?: string; extraClassName?: string;
@@ -21,9 +20,6 @@ export function Input(props: InputProps) {
const inputRef = useRef<TextInput>(null); const inputRef = useRef<TextInput>(null);
const [isFocused, setIsFocused] = useState(false); const [isFocused, setIsFocused] = useState(false);
const scale = useRef(new Animated.Value(1)).current; const scale = useRef(new Animated.Value(1)).current;
// TV-only: scales the input font with the tvTypographyScale setting.
// Not consumed by the mobile branch below.
const tvTypography = useScaledTVTypography();
const animateFocus = (focused: boolean) => { const animateFocus = (focused: boolean) => {
Animated.timing(scale, { Animated.timing(scale, {
@@ -45,18 +41,8 @@ export function Input(props: InputProps) {
}; };
if (Platform.isTV) { if (Platform.isTV) {
// Scale the whole input (box height, padding, icon) proportionally with the
// font so the component grows/shrinks with the tvTypographyScale setting.
// Uses the `body` token (primary reading size); it resolves to 28 at Default.
const fontSize = tvTypography.body;
const factor = fontSize / 28;
const height = Math.round(56 * factor);
const paddingLeft = Math.round(24 * factor);
const iconSize = Math.round(26 * factor);
const iconMarginRight = Math.round(14 * factor);
const containerStyle = { const containerStyle = {
height, height: 48,
borderRadius: 50, borderRadius: 50,
borderWidth: isFocused ? 1.5 : 1, borderWidth: isFocused ? 1.5 : 1,
borderColor: isFocused borderColor: isFocused
@@ -65,16 +51,16 @@ export function Input(props: InputProps) {
overflow: "hidden" as const, overflow: "hidden" as const,
flexDirection: "row" as const, flexDirection: "row" as const,
alignItems: "center" as const, alignItems: "center" as const,
paddingLeft, paddingLeft: 16,
}; };
const inputElement = ( const inputElement = (
<> <>
<Ionicons <Ionicons
name='search' name='search'
size={iconSize} size={20}
color={isFocused ? "#999" : "#666"} color={isFocused ? "#999" : "#666"}
style={{ marginRight: iconMarginRight }} style={{ marginRight: 12 }}
/> />
<TextInput <TextInput
ref={inputRef} ref={inputRef}
@@ -83,8 +69,8 @@ export function Input(props: InputProps) {
style={[ style={[
{ {
flex: 1, flex: 1,
height, height: 48,
fontSize, fontSize: 18,
fontWeight: "400", fontWeight: "400",
color: "#FFFFFF", color: "#FFFFFF",
backgroundColor: "transparent", backgroundColor: "transparent",

View File

@@ -116,7 +116,7 @@ export const DownloadCard = ({ process, ...props }: DownloadCardProps) => {
}, [process?.progress]); }, [process?.progress]);
// Return null after all hooks have been called // Return null after all hooks have been called
if (!process?.item?.Id) { if (!process || !process.item || !process.item.Id) {
return null; return null;
} }

View File

@@ -35,7 +35,6 @@ import { MediaListSection } from "@/components/medialists/MediaListSection";
import { Colors } from "@/constants/Colors"; import { Colors } from "@/constants/Colors";
import useRouter from "@/hooks/useAppRouter"; import useRouter from "@/hooks/useAppRouter";
import { useNetworkStatus } from "@/hooks/useNetworkStatus"; import { useNetworkStatus } from "@/hooks/useNetworkStatus";
import { useRefreshLibraryOnFocus } from "@/hooks/useRefreshLibraryOnFocus";
import { useInvalidatePlaybackProgressCache } from "@/hooks/useRevalidatePlaybackProgressCache"; import { useInvalidatePlaybackProgressCache } from "@/hooks/useRevalidatePlaybackProgressCache";
import { useDownload } from "@/providers/DownloadProvider"; import { useDownload } from "@/providers/DownloadProvider";
import { useIntroSheet } from "@/providers/IntroSheetProvider"; import { useIntroSheet } from "@/providers/IntroSheetProvider";
@@ -90,10 +89,6 @@ const HomeMobile = () => {
const [loadedSections, setLoadedSections] = useState<Set<string>>(new Set()); const [loadedSections, setLoadedSections] = useState<Set<string>>(new Set());
const { showIntro } = useIntroSheet(); const { showIntro } = useIntroSheet();
// Fallback refresh for newly added content when returning to the home screen
// (primary path is the LibraryChanged WebSocket event).
useRefreshLibraryOnFocus();
// Show intro modal on first launch // Show intro modal on first launch
useEffect(() => { useEffect(() => {
const hasShownIntro = storage.getBoolean("hasShownIntro"); const hasShownIntro = storage.getBoolean("hasShownIntro");

View File

@@ -35,7 +35,6 @@ import { Loader } from "@/components/Loader";
import { useScaledTVTypography } from "@/constants/TVTypography"; import { useScaledTVTypography } from "@/constants/TVTypography";
import useRouter from "@/hooks/useAppRouter"; import useRouter from "@/hooks/useAppRouter";
import { useNetworkStatus } from "@/hooks/useNetworkStatus"; import { useNetworkStatus } from "@/hooks/useNetworkStatus";
import { useRefreshLibraryOnFocus } from "@/hooks/useRefreshLibraryOnFocus";
import { useInvalidatePlaybackProgressCache } from "@/hooks/useRevalidatePlaybackProgressCache"; import { useInvalidatePlaybackProgressCache } from "@/hooks/useRevalidatePlaybackProgressCache";
import { useTVItemActionModal } from "@/hooks/useTVItemActionModal"; import { useTVItemActionModal } from "@/hooks/useTVItemActionModal";
import { import {
@@ -87,10 +86,6 @@ export const Home = () => {
const _invalidateCache = useInvalidatePlaybackProgressCache(); const _invalidateCache = useInvalidatePlaybackProgressCache();
const { showItemActions } = useTVItemActionModal(); const { showItemActions } = useTVItemActionModal();
// Fallback refresh for newly added content when returning to the home screen
// (primary path is the LibraryChanged WebSocket event).
useRefreshLibraryOnFocus();
// Dynamic backdrop state with debounce // Dynamic backdrop state with debounce
const [focusedItem, setFocusedItem] = useState<BaseItemDto | null>(null); const [focusedItem, setFocusedItem] = useState<BaseItemDto | null>(null);
const debounceTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null); const debounceTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);

View File

@@ -351,7 +351,7 @@ export const TVHeroCarousel: React.FC<TVHeroCarouselProps> = ({
// Get subtitle for episodes // Get subtitle for episodes
const episodeSubtitle = useMemo(() => { const episodeSubtitle = useMemo(() => {
if (activeItem?.Type !== "Episode") return null; if (!activeItem || activeItem.Type !== "Episode") return null;
return `S${activeItem.ParentIndexNumber} E${activeItem.IndexNumber} · ${activeItem.Name}`; return `S${activeItem.ParentIndexNumber} E${activeItem.IndexNumber} · ${activeItem.Name}`;
}, [activeItem]); }, [activeItem]);

View File

@@ -180,4 +180,4 @@ const styles = StyleSheet.create({
}, },
}); });
export { CARD_HEIGHT, CARD_WIDTH }; export { CARD_WIDTH, CARD_HEIGHT };

View File

@@ -155,7 +155,7 @@ export const TVLiveTVGuide: React.FC = () => {
); );
// Fetch programs for visible channels // Fetch programs for visible channels
const { data: programsData } = useQuery({ const { data: programsData, isLoading: isLoadingPrograms } = useQuery({
queryKey: [ queryKey: [
"livetv", "livetv",
"tv-guide", "tv-guide",

View File

@@ -382,18 +382,16 @@ export const Login: React.FC = () => {
</View> </View>
</View> </View>
</View> </View>
<View className='absolute bottom-0 left-0 w-full px-4 mb-2' />
</View> </View>
) : ( ) : (
<View className='flex flex-col flex-1 items-center justify-center w-full'> <View className='flex flex-col flex-1 w-full'>
<View className='flex flex-col gap-y-2 px-4 w-full -mt-36'> <View className='flex flex-col gap-y-2 px-4 w-full'>
<Image <Image
style={{ style={{
width: 100, width: 100,
height: 100, height: 100,
marginLeft: -23,
marginBottom: -20, marginBottom: -20,
alignSelf: "center",
}} }}
source={require("@/assets/images/icon-ios-plain.png")} source={require("@/assets/images/icon-ios-plain.png")}
/> />
@@ -431,6 +429,8 @@ export const Login: React.FC = () => {
await handleConnect(server.address); await handleConnect(server.address);
}} }}
/> />
</View>
<View className='px-4 pb-2'>
<PreviousServersList <PreviousServersList
onServerSelect={async (s) => { onServerSelect={async (s) => {
await handleConnect(s.address); await handleConnect(s.address);

View File

@@ -14,7 +14,6 @@ import {
} from "react-native"; } from "react-native";
import { Text } from "@/components/common/Text"; import { Text } from "@/components/common/Text";
import { useTVFocusAnimation } from "@/components/tv"; import { useTVFocusAnimation } from "@/components/tv";
import { useTVBackPress } from "@/hooks/useTVBackPress";
import { scaleSize } from "@/utils/scaleSize"; import { scaleSize } from "@/utils/scaleSize";
interface TVPasswordEntryModalProps { interface TVPasswordEntryModalProps {
@@ -202,13 +201,6 @@ export const TVPasswordEntryModal: React.FC<TVPasswordEntryModalProps> = ({
setIsReady(false); setIsReady(false);
}, [visible]); }, [visible]);
// Close the modal on the TV remote back/menu button while it is open.
useTVBackPress(() => {
if (!visible) return false;
onClose();
return true;
}, [visible, onClose]);
const handleSubmit = async () => { const handleSubmit = async () => {
if (!password) { if (!password) {
setError(t("password.enter_password")); setError(t("password.enter_password"));

View File

@@ -1,17 +1,15 @@
import {
Button,
ContextMenu,
Host,
Picker,
Text as SwiftUIText,
} from "@expo/ui/swift-ui";
import { buttonStyle, tag } from "@expo/ui/swift-ui/modifiers";
import { Platform, View } from "react-native"; import { Platform, View } from "react-native";
import { FilterButton } from "@/components/filters/FilterButton"; import { FilterButton } from "@/components/filters/FilterButton";
import { JellyseerrSearchSort } from "@/components/jellyseerr/JellyseerrIndexPage"; import { JellyseerrSearchSort } from "@/components/jellyseerr/JellyseerrIndexPage";
// @expo/ui's SwiftUI native module (ExpoUI) does not exist in tvOS builds.
// A static top-level import crashes the route tree on tvOS at module load.
// Load it lazily and only off-TV; TV never renders this component.
const { Button, Host, Menu } = Platform.isTV
? ({} as typeof import("@expo/ui/swift-ui"))
: require("@expo/ui/swift-ui");
const { buttonStyle } = Platform.isTV
? ({} as typeof import("@expo/ui/swift-ui/modifiers"))
: require("@expo/ui/swift-ui/modifiers");
interface DiscoverFiltersProps { interface DiscoverFiltersProps {
searchFilterId: string; searchFilterId: string;
orderFilterId: string; orderFilterId: string;
@@ -37,7 +35,7 @@ export const DiscoverFilters: React.FC<DiscoverFiltersProps> = ({
setJellyseerrSortOrder, setJellyseerrSortOrder,
t, t,
}) => { }) => {
if (Platform.OS === "ios" && !Platform.isTV) { if (Platform.OS === "ios") {
return ( return (
<Host <Host
style={{ style={{
@@ -49,54 +47,42 @@ export const DiscoverFilters: React.FC<DiscoverFiltersProps> = ({
marginLeft: "auto", marginLeft: "auto",
}} }}
> >
<Menu <ContextMenu>
label={ <ContextMenu.Trigger>
<Button <Button
modifiers={[buttonStyle("glass")]} modifiers={[buttonStyle("glass")]}
systemImage='line.3.horizontal.decrease.circle' systemImage='line.3.horizontal.decrease.circle'
/> ></Button>
} </ContextMenu.Trigger>
> <ContextMenu.Items>
<Menu <Picker
label={`${t("library.filters.sort_by")}: ${t( label={t("library.filters.sort_by")}
`home.settings.plugins.jellyseerr.order_by.${jellyseerrOrderBy}`, selection={jellyseerrOrderBy as unknown as string}
)}`} onSelectionChange={(value) => {
> setJellyseerrOrderBy(value as unknown as JellyseerrSearchSort);
{sortOptions.map((item) => { }}
const isSelected = >
jellyseerrOrderBy === (item as unknown as JellyseerrSearchSort); {sortOptions.map((item) => (
return ( <SwiftUIText key={item} modifiers={[tag(item)]}>
<Button {t(`home.settings.plugins.jellyseerr.order_by.${item}`)}
key={item} </SwiftUIText>
label={t(`home.settings.plugins.jellyseerr.order_by.${item}`)} ))}
systemImage={isSelected ? "checkmark.circle.fill" : "circle"} </Picker>
onPress={() => <Picker
setJellyseerrOrderBy( label={t("library.filters.sort_order")}
item as unknown as JellyseerrSearchSort, selection={jellyseerrSortOrder}
) onSelectionChange={(value) => {
} setJellyseerrSortOrder(value as "asc" | "desc");
/> }}
); >
})} {orderOptions.map((item) => (
</Menu> <SwiftUIText key={item} modifiers={[tag(item)]}>
<Menu {t(`library.filters.${item}`)}
label={`${t("library.filters.sort_order")}: ${t( </SwiftUIText>
`library.filters.${jellyseerrSortOrder}`, ))}
)}`} </Picker>
> </ContextMenu.Items>
{orderOptions.map((item) => { </ContextMenu>
const isSelected = jellyseerrSortOrder === item;
return (
<Button
key={item}
label={t(`library.filters.${item}`)}
systemImage={isSelected ? "checkmark.circle.fill" : "circle"}
onPress={() => setJellyseerrSortOrder(item)}
/>
);
})}
</Menu>
</Menu>
</Host> </Host>
); );
} }

View File

@@ -1,16 +1,9 @@
import { Button, Host } from "@expo/ui/swift-ui";
import { buttonStyle } from "@expo/ui/swift-ui/modifiers";
import { Platform, TouchableOpacity, View } from "react-native"; import { Platform, TouchableOpacity, View } from "react-native";
import { Text } from "@/components/common/Text";
import { Tag } from "@/components/GenreTags"; import { Tag } from "@/components/GenreTags";
// @expo/ui's SwiftUI native module (ExpoUI) does not exist in tvOS builds.
// A static top-level import crashes the route tree on tvOS at module load.
// Load it lazily and only off-TV; TV never renders this component.
const { Button, Host, HStack, Spacer } = Platform.isTV
? ({} as typeof import("@expo/ui/swift-ui"))
: require("@expo/ui/swift-ui");
const { buttonStyle } = Platform.isTV
? ({} as typeof import("@expo/ui/swift-ui/modifiers"))
: require("@expo/ui/swift-ui/modifiers");
type SearchType = "Library" | "Discover"; type SearchType = "Library" | "Discover";
interface SearchTabButtonsProps { interface SearchTabButtonsProps {
@@ -24,10 +17,18 @@ export const SearchTabButtons: React.FC<SearchTabButtonsProps> = ({
setSearchType, setSearchType,
t, t,
}) => { }) => {
if (Platform.OS === "ios" && !Platform.isTV) { if (Platform.OS === "ios") {
return ( return (
<Host style={{ height: 40, flex: 1 }}> <>
<HStack spacing={8}> <Host
style={{
height: 40,
width: 80,
flexDirection: "row",
gap: 10,
justifyContent: "space-between",
}}
>
<Button <Button
modifiers={[ modifiers={[
buttonStyle( buttonStyle(
@@ -35,8 +36,19 @@ export const SearchTabButtons: React.FC<SearchTabButtonsProps> = ({
), ),
]} ]}
onPress={() => setSearchType("Library")} onPress={() => setSearchType("Library")}
label={t("search.library")} >
/> <Text>{t("search.library")}</Text>
</Button>
</Host>
<Host
style={{
height: 40,
width: 100,
flexDirection: "row",
gap: 10,
justifyContent: "space-between",
}}
>
<Button <Button
modifiers={[ modifiers={[
buttonStyle( buttonStyle(
@@ -44,11 +56,11 @@ export const SearchTabButtons: React.FC<SearchTabButtonsProps> = ({
), ),
]} ]}
onPress={() => setSearchType("Discover")} onPress={() => setSearchType("Discover")}
label={t("search.discover")} >
/> <Text>{t("search.discover")}</Text>
<Spacer /> </Button>
</HStack> </Host>
</Host> </>
); );
} }

View File

@@ -4,11 +4,10 @@ import { useMemo } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { ScrollView, View } from "react-native"; import { ScrollView, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context"; import { useSafeAreaInsets } from "react-native-safe-area-context";
import { Input } from "@/components/common/Input";
import { Text } from "@/components/common/Text"; import { Text } from "@/components/common/Text";
import { TVDiscover } from "@/components/jellyseerr/discover/TVDiscover"; import { TVDiscover } from "@/components/jellyseerr/discover/TVDiscover";
import { useScaledTVSizes } from "@/constants/TVSizes";
import { useScaledTVTypography } from "@/constants/TVTypography"; import { useScaledTVTypography } from "@/constants/TVTypography";
import { TvSearchView } from "@/modules/tv-search";
import { apiAtom } from "@/providers/JellyfinProvider"; import { apiAtom } from "@/providers/JellyfinProvider";
import { getPrimaryImageUrl } from "@/utils/jellyfin/image/getPrimaryImageUrl"; import { getPrimaryImageUrl } from "@/utils/jellyfin/image/getPrimaryImageUrl";
import type DiscoverSlider from "@/utils/jellyseerr/server/entity/DiscoverSlider"; import type DiscoverSlider from "@/utils/jellyseerr/server/entity/DiscoverSlider";
@@ -17,46 +16,36 @@ import type {
PersonResult, PersonResult,
TvResult, TvResult,
} from "@/utils/jellyseerr/server/models/Search"; } from "@/utils/jellyseerr/server/models/Search";
import { scaleSize } from "@/utils/scaleSize";
import { TVJellyseerrSearchResults } from "./TVJellyseerrSearchResults"; import { TVJellyseerrSearchResults } from "./TVJellyseerrSearchResults";
import { TVSearchSection } from "./TVSearchSection"; import { TVSearchSection } from "./TVSearchSection";
import { TVSearchTabBadges } from "./TVSearchTabBadges"; import { TVSearchTabBadges } from "./TVSearchTabBadges";
const HORIZONTAL_PADDING = 60; const HORIZONTAL_PADDING = 60;
const TOP_PADDING = 100; const TOP_PADDING = 100;
// Height of the native search bar itself. The tvOS grid keyboard presents as
// its own overlay when the field is focused, so we only reserve the bar height
// here — not the whole keyboard. Tunable once seen on device.
const SEARCH_AREA_HEIGHT = 250;
const SECTION_GAP = 10; const SECTION_GAP = 10;
const SCALE_PADDING = 20; const SCALE_PADDING = 20;
// Loading skeleton for TV. // Loading skeleton for TV
// Mirrors TVSearchSection's scaled layout (poster width, item gap, edge
// padding, heading typography, poster radius) so the placeholder lines up with
// the real content that replaces it.
const TVLoadingSkeleton: React.FC = () => { const TVLoadingSkeleton: React.FC = () => {
const typography = useScaledTVTypography(); const typography = useScaledTVTypography();
const sizes = useScaledTVSizes(); const itemWidth = 210;
const itemWidth = sizes.posters.poster;
return ( return (
<View style={{ overflow: "visible" }}> <View style={{ overflow: "visible" }}>
{/* Section header placeholder — matches the heading typography + margins */}
<View <View
style={{ style={{
width: itemWidth, width: 200,
height: typography.heading, height: 28,
backgroundColor: "#262626", backgroundColor: "#262626",
borderRadius: 8, borderRadius: 8,
marginBottom: 20, marginBottom: 16,
marginLeft: sizes.padding.horizontal, marginLeft: SCALE_PADDING,
}} }}
/> />
<View <View
style={{ style={{
flexDirection: "row", flexDirection: "row",
gap: sizes.gaps.item, gap: 16,
paddingLeft: sizes.padding.horizontal, paddingHorizontal: SCALE_PADDING,
paddingVertical: SCALE_PADDING, paddingVertical: SCALE_PADDING,
}} }}
> >
@@ -67,14 +56,15 @@ const TVLoadingSkeleton: React.FC = () => {
backgroundColor: "#262626", backgroundColor: "#262626",
width: itemWidth, width: itemWidth,
aspectRatio: 10 / 15, aspectRatio: 10 / 15,
borderRadius: scaleSize(24), borderRadius: 12,
marginBottom: scaleSize(8), marginBottom: 8,
}} }}
/> />
<View <View
style={{ style={{
borderRadius: 6, borderRadius: 6,
overflow: "hidden", overflow: "hidden",
marginBottom: 4,
alignSelf: "flex-start", alignSelf: "flex-start",
}} }}
> >
@@ -134,6 +124,7 @@ interface TVSearchPageProps {
} }
export const TVSearchPage: React.FC<TVSearchPageProps> = ({ export const TVSearchPage: React.FC<TVSearchPageProps> = ({
search,
setSearch, setSearch,
debouncedSearch, debouncedSearch,
movies, movies,
@@ -224,129 +215,125 @@ export const TVSearchPage: React.FC<TVSearchPageProps> = ({
const currentNoResults = isLibraryMode ? noResults : jellyseerrNoResults; const currentNoResults = isLibraryMode ? noResults : jellyseerrNoResults;
return ( return (
<View style={{ flex: 1 }}> <ScrollView
{/* Sticky header: search field stays pinned while results scroll below. */} nestedScrollEnabled
showsVerticalScrollIndicator={false}
keyboardDismissMode='on-drag'
contentContainerStyle={{
paddingTop: insets.top + TOP_PADDING,
paddingBottom: insets.bottom + 60,
}}
>
{/* Search Input */}
<View <View
style={{ style={{
paddingTop: insets.top + TOP_PADDING, marginBottom: 24,
marginHorizontal: HORIZONTAL_PADDING + 200,
}} }}
> >
{/* Native tvOS search field (SwiftUI `.searchable`, our `tv-search` <Input
module). It renders the native search bar + grid keyboard and placeholder={t("search.search")}
forwards typed text into the existing query pipeline via setSearch; value={search}
our own results grid renders below. */} onChangeText={setSearch}
<View keyboardType='default'
style={{ returnKeyType='done'
marginBottom: 24, autoCapitalize='none'
marginHorizontal: HORIZONTAL_PADDING, clearButtonMode='while-editing'
height: SEARCH_AREA_HEIGHT, maxLength={500}
}} hasTVPreferredFocus={
> debouncedSearch.length === 0 &&
<TvSearchView sections.length === 0 &&
style={{ width: "100%", height: "100%" }} !showDiscover
placeholder={t("search.search")} }
onChangeText={(e) => setSearch(e.nativeEvent.text)} />
/>
</View>
</View> </View>
<ScrollView {/* Search Type Tab Badges */}
nestedScrollEnabled {showDiscover && (
showsVerticalScrollIndicator={false} <View style={{ marginHorizontal: HORIZONTAL_PADDING }}>
keyboardDismissMode='on-drag' <TVSearchTabBadges
contentContainerStyle={{ searchType={searchType}
paddingBottom: insets.bottom + 60, setSearchType={setSearchType}
}} showDiscover={showDiscover}
>
{/* Search Type Tab Badges */}
{showDiscover && (
<View style={{ marginHorizontal: HORIZONTAL_PADDING }}>
<TVSearchTabBadges
searchType={searchType}
setSearchType={setSearchType}
showDiscover={showDiscover}
/>
</View>
)}
{/* Loading State */}
{currentLoading && (
<View style={{ gap: SECTION_GAP }}>
<TVLoadingSkeleton />
<TVLoadingSkeleton />
</View>
)}
{/* Library Search Results */}
{isLibraryMode && !loading && (
<View style={{ gap: SECTION_GAP }}>
{sections.map((section, index) => (
<TVSearchSection
key={section.key}
title={section.title}
items={section.items!}
orientation={section.orientation || "vertical"}
isFirstSection={index === 0}
onItemPress={onItemPress}
onItemLongPress={onItemLongPress}
imageUrlGetter={
["artists", "albums", "songs", "playlists"].includes(
section.key,
)
? getImageUrl
: undefined
}
/>
))}
</View>
)}
{/* Jellyseerr/Discover Search Results */}
{isDiscoverMode && !jellyseerrLoading && debouncedSearch.length > 0 && (
<TVJellyseerrSearchResults
movieResults={jellyseerrMovies}
tvResults={jellyseerrTv}
personResults={jellyseerrPersons}
loading={jellyseerrLoading}
noResults={jellyseerrNoResults}
searchQuery={debouncedSearch}
onMoviePress={onJellyseerrMoviePress || (() => {})}
onTvPress={onJellyseerrTvPress || (() => {})}
onPersonPress={onJellyseerrPersonPress || (() => {})}
/> />
)} </View>
)}
{/* Discover Content (when no search query in Discover mode) */} {/* Loading State */}
{isDiscoverMode && {currentLoading && (
!jellyseerrLoading && <View style={{ gap: SECTION_GAP }}>
debouncedSearch.length === 0 && ( <TVLoadingSkeleton />
<TVDiscover sliders={discoverSliders} /> <TVLoadingSkeleton />
)} </View>
)}
{/* No Results State */} {/* Library Search Results */}
{!currentLoading && currentNoResults && debouncedSearch.length > 0 && ( {isLibraryMode && !loading && (
<View style={{ alignItems: "center", paddingTop: 40 }}> <View style={{ gap: SECTION_GAP }}>
<Text {sections.map((section, index) => (
style={{ <TVSearchSection
fontSize: typography.heading, key={section.key}
fontWeight: "bold", title={section.title}
color: "#FFFFFF", items={section.items!}
marginBottom: 8, orientation={section.orientation || "vertical"}
}} isFirstSection={index === 0}
> onItemPress={onItemPress}
{t("search.no_results_found_for")} onItemLongPress={onItemLongPress}
</Text> imageUrlGetter={
<Text ["artists", "albums", "songs", "playlists"].includes(
style={{ section.key,
fontSize: typography.body, )
color: "rgba(255,255,255,0.6)", ? getImageUrl
}} : undefined
> }
"{debouncedSearch}" />
</Text> ))}
</View> </View>
)} )}
</ScrollView>
</View> {/* Jellyseerr/Discover Search Results */}
{isDiscoverMode && !jellyseerrLoading && debouncedSearch.length > 0 && (
<TVJellyseerrSearchResults
movieResults={jellyseerrMovies}
tvResults={jellyseerrTv}
personResults={jellyseerrPersons}
loading={jellyseerrLoading}
noResults={jellyseerrNoResults}
searchQuery={debouncedSearch}
onMoviePress={onJellyseerrMoviePress || (() => {})}
onTvPress={onJellyseerrTvPress || (() => {})}
onPersonPress={onJellyseerrPersonPress || (() => {})}
/>
)}
{/* Discover Content (when no search query in Discover mode) */}
{isDiscoverMode && !jellyseerrLoading && debouncedSearch.length === 0 && (
<TVDiscover sliders={discoverSliders} />
)}
{/* No Results State */}
{!currentLoading && currentNoResults && debouncedSearch.length > 0 && (
<View style={{ alignItems: "center", paddingTop: 40 }}>
<Text
style={{
fontSize: typography.heading,
fontWeight: "bold",
color: "#FFFFFF",
marginBottom: 8,
}}
>
{t("search.no_results_found_for")}
</Text>
<Text
style={{
fontSize: typography.body,
color: "rgba(255,255,255,0.6)",
}}
>
"{debouncedSearch}"
</Text>
</View>
)}
</ScrollView>
); );
}; };

View File

@@ -20,8 +20,6 @@ interface TVSearchSectionProps extends ViewProps {
onItemPress: (item: BaseItemDto) => void; onItemPress: (item: BaseItemDto) => void;
onItemLongPress?: (item: BaseItemDto) => void; onItemLongPress?: (item: BaseItemDto) => void;
imageUrlGetter?: (item: BaseItemDto) => string | undefined; imageUrlGetter?: (item: BaseItemDto) => string | undefined;
/** Override the horizontal edge padding (defaults to the scaled TV padding). */
horizontalPadding?: number;
} }
export const TVSearchSection: React.FC<TVSearchSectionProps> = ({ export const TVSearchSection: React.FC<TVSearchSectionProps> = ({
@@ -33,14 +31,12 @@ export const TVSearchSection: React.FC<TVSearchSectionProps> = ({
onItemPress, onItemPress,
onItemLongPress, onItemLongPress,
imageUrlGetter, imageUrlGetter,
horizontalPadding,
...props ...props
}) => { }) => {
const typography = useScaledTVTypography(); const typography = useScaledTVTypography();
const posterSizes = useScaledTVPosterSizes(); const posterSizes = useScaledTVPosterSizes();
const sizes = useScaledTVSizes(); const sizes = useScaledTVSizes();
const ITEM_GAP = sizes.gaps.item; const ITEM_GAP = sizes.gaps.item;
const edgePadding = horizontalPadding ?? sizes.padding.horizontal;
const flatListRef = useRef<FlatList<BaseItemDto>>(null); const flatListRef = useRef<FlatList<BaseItemDto>>(null);
const [focusedCount, setFocusedCount] = useState(0); const [focusedCount, setFocusedCount] = useState(0);
const prevFocusedCount = useRef(0); const prevFocusedCount = useRef(0);
@@ -277,7 +273,7 @@ export const TVSearchSection: React.FC<TVSearchSectionProps> = ({
fontWeight: "700", fontWeight: "700",
color: "#FFFFFF", color: "#FFFFFF",
marginBottom: 20, marginBottom: 20,
marginLeft: edgePadding, marginLeft: sizes.padding.horizontal,
letterSpacing: 0.5, letterSpacing: 0.5,
}} }}
> >
@@ -298,10 +294,10 @@ export const TVSearchSection: React.FC<TVSearchSectionProps> = ({
getItemLayout={getItemLayout} getItemLayout={getItemLayout}
style={{ overflow: "visible" }} style={{ overflow: "visible" }}
contentInset={{ contentInset={{
left: edgePadding, left: sizes.padding.horizontal,
right: edgePadding, right: sizes.padding.horizontal,
}} }}
contentOffset={{ x: -edgePadding, y: 0 }} contentOffset={{ x: -sizes.padding.horizontal, y: 0 }}
contentContainerStyle={{ contentContainerStyle={{
paddingVertical: SCALE_PADDING, paddingVertical: SCALE_PADDING,
}} }}

View File

@@ -193,7 +193,7 @@ const TVSeasonButton: React.FC<{
> >
<Text <Text
style={{ style={{
fontSize: typography.callout, fontSize: typography.body,
color: focused ? "#000" : "#FFFFFF", color: focused ? "#000" : "#FFFFFF",
fontWeight: "bold", fontWeight: "bold",
}} }}
@@ -538,7 +538,7 @@ export const TVSeriesPage: React.FC<TVSeriesPageProps> = ({
/> />
<Text <Text
style={{ style={{
fontSize: typography.callout, fontSize: typography.body,
fontWeight: "bold", fontWeight: "bold",
color: "#000000", color: "#000000",
}} }}

View File

@@ -1,9 +1,14 @@
import { Stack } from "expo-router"; import type { ParamListBase, RouteProp } from "@react-navigation/native";
import type { ComponentProps } from "react"; import type { NativeStackNavigationOptions } from "@react-navigation/native-stack";
import { Platform } from "react-native"; import { Platform } from "react-native";
import { HeaderBackButton } from "../common/HeaderBackButton"; import { HeaderBackButton } from "../common/HeaderBackButton";
type ICommonScreenOptions = ComponentProps<typeof Stack.Screen>["options"]; type ICommonScreenOptions =
| NativeStackNavigationOptions
| ((prop: {
route: RouteProp<ParamListBase, string>;
navigation: any;
}) => NativeStackNavigationOptions);
export const commonScreenOptions: ICommonScreenOptions = { export const commonScreenOptions: ICommonScreenOptions = {
title: "", title: "",

View File

@@ -63,7 +63,6 @@ export const TVNextEpisodeCountdown: FC<TVNextEpisodeCountdownProps> = ({
const typography = useScaledTVTypography(); const typography = useScaledTVTypography();
const { t } = useTranslation(); const { t } = useTranslation();
const progress = useSharedValue(0); const progress = useSharedValue(0);
const cancelled = useSharedValue(false);
const onFinishRef = useRef(onFinish); const onFinishRef = useRef(onFinish);
const { focused, handleFocus, handleBlur, animatedStyle } = const { focused, handleFocus, handleBlur, animatedStyle } =
useTVFocusAnimation({ useTVFocusAnimation({
@@ -121,15 +120,13 @@ export const TVNextEpisodeCountdown: FC<TVNextEpisodeCountdownProps> = ({
return; return;
} }
cancelled.value = false;
// Resume from current position // Resume from current position
const remainingDuration = (1 - progress.value) * 8000; const remainingDuration = (1 - progress.value) * 8000;
progress.value = withTiming( progress.value = withTiming(
1, 1,
{ duration: remainingDuration, easing: Easing.linear }, { duration: remainingDuration, easing: Easing.linear },
(finished) => { (finished) => {
if (finished && !cancelled.value) { if (finished) {
runOnJS(onFinishRef.current)(); runOnJS(onFinishRef.current)();
} }
}, },
@@ -137,10 +134,9 @@ export const TVNextEpisodeCountdown: FC<TVNextEpisodeCountdownProps> = ({
// Cancel animation on unmount to prevent onFinish from firing after exit // Cancel animation on unmount to prevent onFinish from firing after exit
return () => { return () => {
cancelled.value = true;
cancelAnimation(progress); cancelAnimation(progress);
}; };
}, [show, isPlaying, progress, cancelled]); }, [show, isPlaying, progress]);
const progressStyle = useAnimatedStyle(() => ({ const progressStyle = useAnimatedStyle(() => ({
width: `${progress.value * 100}%`, width: `${progress.value * 100}%`,

View File

@@ -263,7 +263,7 @@ const createStyles = (typography: ReturnType<typeof useScaledTVTypography>) =>
color: "#fff", color: "#fff",
}, },
downloadingOverlay: { downloadingOverlay: {
...StyleSheet.absoluteFill, ...StyleSheet.absoluteFillObject,
backgroundColor: "rgba(0,0,0,0.5)", backgroundColor: "rgba(0,0,0,0.5)",
borderRadius: scaleSize(14), borderRadius: scaleSize(14),
justifyContent: "center", justifyContent: "center",

View File

@@ -1,34 +1,19 @@
import { Ionicons } from "@expo/vector-icons"; import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
import type { import type { FC } from "react";
BaseItemDto, import { View } from "react-native";
ChapterInfo,
} from "@jellyfin/sdk/lib/generated-client";
import { type FC, useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import { Pressable, View } from "react-native";
import { Slider } from "react-native-awesome-slider"; import { Slider } from "react-native-awesome-slider";
import { type SharedValue } from "react-native-reanimated"; import { type SharedValue } from "react-native-reanimated";
import { useSafeAreaInsets } from "react-native-safe-area-context"; import { useSafeAreaInsets } from "react-native-safe-area-context";
import { ChapterList } from "@/components/chapters/ChapterList";
import { ChapterTicks } from "@/components/chapters/ChapterTicks";
import { Text } from "@/components/common/Text"; import { Text } from "@/components/common/Text";
import { useSettings } from "@/utils/atoms/settings"; import { useSettings } from "@/utils/atoms/settings";
import { chapterMarkers, chapterNameAt } from "@/utils/chapters"; import { ChapterMarkers } from "./ChapterMarkers";
import NextEpisodeCountDownButton from "./NextEpisodeCountDownButton"; import NextEpisodeCountDownButton from "./NextEpisodeCountDownButton";
import SkipButton from "./SkipButton"; import SkipButton from "./SkipButton";
import { TimeDisplay } from "./TimeDisplay"; import { TimeDisplay } from "./TimeDisplay";
import { TrickplayBubble } from "./TrickplayBubble"; import { TrickplayBubble } from "./TrickplayBubble";
// Chapter tick height in dp — matches the slider track height for a clean,
// flush look (no top/bottom overflow).
const TICK_HEIGHT = 10;
interface BottomControlsProps { interface BottomControlsProps {
item: BaseItemDto; item: BaseItemDto;
/** Item chapters, used for the tick overlay and chapter list. */
chapters?: ChapterInfo[] | null;
/** Total media duration in milliseconds. */
durationMs: number;
showControls: boolean; showControls: boolean;
isSliding: boolean; isSliding: boolean;
showRemoteBubble: boolean; showRemoteBubble: boolean;
@@ -54,8 +39,6 @@ interface BottomControlsProps {
handleSliderChange: (value: number) => void; handleSliderChange: (value: number) => void;
handleTouchStart: () => void; handleTouchStart: () => void;
handleTouchEnd: () => void; handleTouchEnd: () => void;
/** Programmatic seek (chapter list, hotkeys) — bypasses slide gesture state. */
seekTo: (value: number) => void;
// Trickplay props // Trickplay props
trickPlayUrl: { trickPlayUrl: {
@@ -82,8 +65,6 @@ interface BottomControlsProps {
export const BottomControls: FC<BottomControlsProps> = ({ export const BottomControls: FC<BottomControlsProps> = ({
item, item,
chapters,
durationMs,
showControls, showControls,
isSliding, isSliding,
showRemoteBubble, showRemoteBubble,
@@ -107,39 +88,13 @@ export const BottomControls: FC<BottomControlsProps> = ({
handleSliderChange, handleSliderChange,
handleTouchStart, handleTouchStart,
handleTouchEnd, handleTouchEnd,
seekTo,
trickPlayUrl, trickPlayUrl,
trickplayInfo, trickplayInfo,
time, time,
chapterPositions = [], chapterPositions = [],
}) => { }) => {
const { settings } = useSettings(); const { settings } = useSettings();
const { t } = useTranslation();
const insets = useSafeAreaInsets(); const insets = useSafeAreaInsets();
const [chapterListVisible, setChapterListVisible] = useState(false);
// Only expose chapter UI when there are at least two real markers.
const chapterMarkerList = useMemo(
() => chapterMarkers(chapters, durationMs),
[chapters, durationMs],
);
const hasChapters = chapterMarkerList.length > 1;
// Current chapter name for the always-visible header label (live playback).
const currentChapterName = useMemo(
() => (hasChapters ? chapterNameAt(currentTime, chapters) : null),
[hasChapters, currentTime, chapters],
);
// Chapter name at the scrubbed position for the trickplay bubble. `time` is
// an {h,m,s} object derived from the slider's dragged value — convert back
// to ms for the lookup. Only useful while actively scrubbing.
const scrubChapterName = useMemo(() => {
if (!hasChapters) return null;
const scrubMs =
(time.hours * 3600 + time.minutes * 60 + time.seconds) * 1000;
return chapterNameAt(scrubMs, chapters);
}, [hasChapters, time.hours, time.minutes, time.seconds, chapters]);
return ( return (
<View <View
@@ -181,24 +136,8 @@ export const BottomControls: FC<BottomControlsProps> = ({
{item?.Type === "Audio" && ( {item?.Type === "Audio" && (
<Text className='text-xs opacity-50'>{item?.Album}</Text> <Text className='text-xs opacity-50'>{item?.Album}</Text>
)} )}
{currentChapterName ? (
<Text className='text-xs opacity-70 mt-1' numberOfLines={1}>
{currentChapterName}
</Text>
) : null}
</View> </View>
<View className='flex flex-row items-center space-x-2 shrink-0'> <View className='flex flex-row space-x-2 shrink-0'>
{hasChapters && (
<Pressable
onPress={() => setChapterListVisible(true)}
hitSlop={10}
className='justify-center mr-4'
accessibilityRole='button'
accessibilityLabel={t("chapters.open")}
>
<Ionicons name='bookmarks' size={24} color='white' />
</Pressable>
)}
<SkipButton <SkipButton
showButton={showSkipButton} showButton={showSkipButton}
onPress={skipIntro} onPress={skipIntro}
@@ -242,9 +181,7 @@ export const BottomControls: FC<BottomControlsProps> = ({
height: 10, height: 10,
justifyContent: "center", justifyContent: "center",
alignItems: "stretch", alignItems: "stretch",
// Allow chapter ticks taller than the 10px track to bleed out position: "relative",
// top/bottom (RN defaults to overflow: "hidden" on Android).
overflow: "visible",
}} }}
onTouchStart={handleTouchStart} onTouchStart={handleTouchStart}
onTouchEnd={handleTouchEnd} onTouchEnd={handleTouchEnd}
@@ -272,7 +209,6 @@ export const BottomControls: FC<BottomControlsProps> = ({
trickPlayUrl={trickPlayUrl} trickPlayUrl={trickPlayUrl}
trickplayInfo={trickplayInfo} trickplayInfo={trickplayInfo}
time={time} time={time}
chapterName={scrubChapterName}
/> />
) )
} }
@@ -282,7 +218,7 @@ export const BottomControls: FC<BottomControlsProps> = ({
minimumValue={min} minimumValue={min}
maximumValue={max} maximumValue={max}
/> />
<ChapterTicks markers={chapterMarkerList} height={TICK_HEIGHT} /> <ChapterMarkers chapterPositions={chapterPositions} />
</View> </View>
<TimeDisplay <TimeDisplay
currentTime={currentTime} currentTime={currentTime}
@@ -290,13 +226,6 @@ export const BottomControls: FC<BottomControlsProps> = ({
/> />
</View> </View>
</View> </View>
<ChapterList
visible={chapterListVisible}
chapters={chapters}
currentPositionMs={currentTime}
onSeek={seekTo}
onClose={() => setChapterListVisible(false)}
/>
</View> </View>
); );
}; };

View File

@@ -267,7 +267,6 @@ export const Controls: FC<Props> = ({
handleTouchEnd, handleTouchEnd,
handleSliderComplete, handleSliderComplete,
handleSliderChange, handleSliderChange,
seekTo,
} = useVideoSlider({ } = useVideoSlider({
progress, progress,
isSeeking, isSeeking,
@@ -556,8 +555,6 @@ export const Controls: FC<Props> = ({
> >
<BottomControls <BottomControls
item={item} item={item}
chapters={item.Chapters}
durationMs={maxMs}
showControls={showControls} showControls={showControls}
isSliding={isSliding} isSliding={isSliding}
showRemoteBubble={showRemoteBubble} showRemoteBubble={showRemoteBubble}
@@ -581,7 +578,6 @@ export const Controls: FC<Props> = ({
handleSliderChange={handleSliderChange} handleSliderChange={handleSliderChange}
handleTouchStart={handleTouchStart} handleTouchStart={handleTouchStart}
handleTouchEnd={handleTouchEnd} handleTouchEnd={handleTouchEnd}
seekTo={seekTo}
trickPlayUrl={trickPlayUrl} trickPlayUrl={trickPlayUrl}
trickplayInfo={trickplayInfo} trickplayInfo={trickplayInfo}
time={isSliding || showRemoteBubble ? time : remoteTime} time={isSliding || showRemoteBubble ? time : remoteTime}

View File

@@ -59,7 +59,6 @@ import { useRemoteControl } from "./hooks/useRemoteControl";
import { useVideoTime } from "./hooks/useVideoTime"; import { useVideoTime } from "./hooks/useVideoTime";
import { TechnicalInfoOverlay } from "./TechnicalInfoOverlay"; import { TechnicalInfoOverlay } from "./TechnicalInfoOverlay";
import { TrickplayBubble } from "./TrickplayBubble"; import { TrickplayBubble } from "./TrickplayBubble";
import type { Track } from "./types";
import { useControlsTimeout } from "./useControlsTimeout"; import { useControlsTimeout } from "./useControlsTimeout";
interface Props { interface Props {
@@ -233,8 +232,14 @@ export const Controls: FC<Props> = ({
const api = useAtomValue(apiAtom); const api = useAtomValue(apiAtom);
const { settings } = useSettings(); const { settings } = useSettings();
const router = useRouter(); const router = useRouter();
const { bitrateValue } = useLocalSearchParams<{ const {
bitrateValue,
subtitleIndex: paramSubtitleIndex,
audioIndex: paramAudioIndex,
} = useLocalSearchParams<{
bitrateValue: string; bitrateValue: string;
subtitleIndex: string;
audioIndex: string;
}>(); }>();
const { nextItem: internalNextItem } = usePlaybackManager({ const { nextItem: internalNextItem } = usePlaybackManager({
@@ -310,31 +315,6 @@ export const Controls: FC<Props> = ({
[onSubtitleIndexChange], [onSubtitleIndexChange],
); );
// Re-fetch subtitle streams from the server (e.g. after a server-side
// download) and map them to the modal's Track shape. setTrack drives the
// player through the same handler used for manual subtitle selection.
const refreshSubtitleTracks = useCallback(async (): Promise<Track[]> => {
try {
const streams = (await onRefreshSubtitleTracks?.()) ?? [];
// Skip streams without a real index: `?? -1` would alias them to the
// "disable subtitles" sentinel and mis-route selection.
return streams
.filter((stream) => typeof stream.Index === "number")
.map((stream) => {
const index = stream.Index as number;
return {
name:
stream.DisplayTitle ||
`${stream.Language || "Unknown"} (${stream.Codec})`,
index,
setTrack: () => onSubtitleIndexChange?.(index),
};
});
} catch {
return [];
}
}, [onRefreshSubtitleTracks, onSubtitleIndexChange]);
const { const {
trickPlayUrl, trickPlayUrl,
calculateTrickplayUrl, calculateTrickplayUrl,
@@ -511,8 +491,6 @@ export const Controls: FC<Props> = ({
const goToNextItemRef = useRef<(opts?: { isAutoPlay?: boolean }) => void>( const goToNextItemRef = useRef<(opts?: { isAutoPlay?: boolean }) => void>(
() => {}, () => {},
); );
const exitingRef = useRef(false);
const [isExiting, setIsExiting] = useState(false);
const updateSeekBubbleTime = useCallback((ms: number) => { const updateSeekBubbleTime = useCallback((ms: number) => {
const totalSeconds = Math.floor(ms / 1000); const totalSeconds = Math.floor(ms / 1000);
@@ -577,22 +555,10 @@ export const Controls: FC<Props> = ({
const handleOpenSubtitleSheet = useCallback(() => { const handleOpenSubtitleSheet = useCallback(() => {
setLastOpenedModal("subtitle"); setLastOpenedModal("subtitle");
// Filter out the "Disable" option from VideoContext tracks since the modal adds its own "None" option. // Filter out the "Disable" option from VideoContext tracks since the modal adds its own "None" option
// Wrap each setTrack so selecting a subtitle ALSO updates the player's live const tracksWithoutDisable = (videoContextSubtitleTracks ?? []).filter(
// index via onSubtitleIndexChange. The modal is a separate route, so the (track) => track.index !== -1,
// VideoContext router.setParams inside setTrack targets the modal — not the );
// player — leaving currentSubtitleIndex stale. Without this sync, the next
// episode carries the previously-shown subtitle instead of the one the user
// just picked. (The audio sheet already uses onAudioIndexChange directly.)
const tracksWithoutDisable = (videoContextSubtitleTracks ?? [])
.filter((track) => track.index !== -1)
.map((track) => ({
...track,
setTrack: () => {
track.setTrack();
onSubtitleIndexChange?.(track.index);
},
}));
showSubtitleModal({ showSubtitleModal({
item, item,
mediaSourceId: mediaSource?.Id, mediaSourceId: mediaSource?.Id,
@@ -604,12 +570,8 @@ export const Controls: FC<Props> = ({
(t) => t.index === -1, (t) => t.index === -1,
); );
disableTrack?.setTrack(); disableTrack?.setTrack();
onSubtitleIndexChange?.(-1);
}, },
onLocalSubtitleDownloaded: handleLocalSubtitleDownloaded, onLocalSubtitleDownloaded: handleLocalSubtitleDownloaded,
refreshSubtitleTracks: onRefreshSubtitleTracks
? refreshSubtitleTracks
: undefined,
}); });
controlsInteractionRef.current(); controlsInteractionRef.current();
}, [ }, [
@@ -618,10 +580,7 @@ export const Controls: FC<Props> = ({
mediaSource?.Id, mediaSource?.Id,
videoContextSubtitleTracks, videoContextSubtitleTracks,
subtitleIndex, subtitleIndex,
onSubtitleIndexChange,
handleLocalSubtitleDownloaded, handleLocalSubtitleDownloaded,
onRefreshSubtitleTracks,
refreshSubtitleTracks,
]); ]);
const handleToggleTechnicalInfo = useCallback(() => { const handleToggleTechnicalInfo = useCallback(() => {
@@ -970,16 +929,6 @@ export const Controls: FC<Props> = ({
router.back(); router.back();
}, [router]); }, [router]);
const handleWillExit = useCallback(() => {
exitingRef.current = true;
setIsExiting(true);
}, []);
const handleCancelExit = useCallback(() => {
exitingRef.current = false;
setIsExiting(false);
}, []);
const { isSliding: isRemoteSliding } = useRemoteControl({ const { isSliding: isRemoteSliding } = useRemoteControl({
showControls: showControls, showControls: showControls,
toggleControls, toggleControls,
@@ -996,8 +945,6 @@ export const Controls: FC<Props> = ({
onVerticalDpad: handleVerticalDpad, onVerticalDpad: handleVerticalDpad,
onHideControls: hideControls, onHideControls: hideControls,
onBack: handleBack, onBack: handleBack,
onWillExit: handleWillExit,
onCancelExit: handleCancelExit,
videoTitle: item?.Name ?? undefined, videoTitle: item?.Name ?? undefined,
}); });
@@ -1039,12 +986,13 @@ export const Controls: FC<Props> = ({
return; return;
} }
// Use the live selection passed down from the player (currentSubtitleIndex
// / currentAudioIndex), not the stale URL params the episode started with.
// This path runs on autoplay; the manual "Next" button uses goToNextItemProp.
const previousIndexes = { const previousIndexes = {
subtitleIndex, subtitleIndex: paramSubtitleIndex
audioIndex, ? Number.parseInt(paramSubtitleIndex, 10)
: undefined,
audioIndex: paramAudioIndex
? Number.parseInt(paramAudioIndex, 10)
: undefined,
}; };
const { const {
@@ -1071,8 +1019,8 @@ export const Controls: FC<Props> = ({
[ [
nextItem, nextItem,
settings, settings,
subtitleIndex, paramSubtitleIndex,
audioIndex, paramAudioIndex,
mediaSource, mediaSource,
bitrateValue, bitrateValue,
router, router,
@@ -1082,7 +1030,6 @@ export const Controls: FC<Props> = ({
goToNextItemRef.current = goToNextItem; goToNextItemRef.current = goToNextItem;
const handleAutoPlayFinish = useCallback(() => { const handleAutoPlayFinish = useCallback(() => {
if (exitingRef.current) return;
goToNextItem({ isAutoPlay: true }); goToNextItem({ isAutoPlay: true });
}, [goToNextItem]); }, [goToNextItem]);
@@ -1157,7 +1104,7 @@ export const Controls: FC<Props> = ({
nextItem={nextItem} nextItem={nextItem}
api={api} api={api}
show={isCountdownActive} show={isCountdownActive}
isPlaying={isPlaying && !isExiting} isPlaying={isPlaying}
onFinish={handleAutoPlayFinish} onFinish={handleAutoPlayFinish}
onPlayNext={handleNextItemButton} onPlayNext={handleNextItemButton}
controlsVisible={showControls} controlsVisible={showControls}
@@ -1461,14 +1408,14 @@ export const Controls: FC<Props> = ({
const styles = StyleSheet.create({ const styles = StyleSheet.create({
controlsContainer: { controlsContainer: {
...StyleSheet.absoluteFill, ...StyleSheet.absoluteFillObject,
}, },
darkOverlay: { darkOverlay: {
...StyleSheet.absoluteFill, ...StyleSheet.absoluteFillObject,
backgroundColor: "rgba(0, 0, 0, 0.4)", backgroundColor: "rgba(0, 0, 0, 0.4)",
}, },
focusStealingOverlay: { focusStealingOverlay: {
...StyleSheet.absoluteFill, ...StyleSheet.absoluteFillObject,
zIndex: 1, zIndex: 1,
}, },
bottomContainer: { bottomContainer: {

View File

@@ -4,9 +4,7 @@ import { View } from "react-native";
import { Text } from "@/components/common/Text"; import { Text } from "@/components/common/Text";
import { CONTROLS_CONSTANTS } from "./constants"; import { CONTROLS_CONSTANTS } from "./constants";
// Slightly larger preview (scale 1.6 vs old 1.4) to give the overlay text const BASE_IMAGE_SCALE = 1.4;
// more room and feel closer to the Jellyfin web style.
const BASE_IMAGE_SCALE = 1.6;
const BUBBLE_LEFT_OFFSET = 62; const BUBBLE_LEFT_OFFSET = 62;
const BUBBLE_WIDTH_MULTIPLIER = 1.5; const BUBBLE_WIDTH_MULTIPLIER = 1.5;
@@ -30,8 +28,12 @@ interface TrickplayBubbleProps {
}; };
/** Scale factor for the image (default 1). Does not affect timestamp text. */ /** Scale factor for the image (default 1). Does not affect timestamp text. */
imageScale?: number; imageScale?: number;
/** Chapter name at the scrubbed position, if any. */ }
chapterName?: string | null;
function formatTime(hours: number, minutes: number, seconds: number): string {
const pad = (n: number) => (n < 10 ? `0${n}` : `${n}`);
const prefix = hours > 0 ? `${hours}:` : "";
return `${prefix}${pad(minutes)}:${pad(seconds)}`;
} }
export const TrickplayBubble: FC<TrickplayBubbleProps> = ({ export const TrickplayBubble: FC<TrickplayBubbleProps> = ({
@@ -39,7 +41,6 @@ export const TrickplayBubble: FC<TrickplayBubbleProps> = ({
trickplayInfo, trickplayInfo,
time, time,
imageScale = 1, imageScale = 1,
chapterName,
}) => { }) => {
if (!trickPlayUrl || !trickplayInfo) { if (!trickPlayUrl || !trickplayInfo) {
return null; return null;
@@ -48,28 +49,19 @@ export const TrickplayBubble: FC<TrickplayBubbleProps> = ({
const { x, y, url } = trickPlayUrl; const { x, y, url } = trickPlayUrl;
const tileWidth = CONTROLS_CONSTANTS.TILE_WIDTH; const tileWidth = CONTROLS_CONSTANTS.TILE_WIDTH;
const tileHeight = tileWidth / trickplayInfo.aspectRatio!; const tileHeight = tileWidth / trickplayInfo.aspectRatio!;
const timeStr = `${time.hours > 0 ? `${time.hours}:` : ""}${
time.minutes < 10 ? `0${time.minutes}` : time.minutes
}:${time.seconds < 10 ? `0${time.seconds}` : time.seconds}`;
const finalScale = BASE_IMAGE_SCALE * imageScale; const finalScale = BASE_IMAGE_SCALE * imageScale;
return ( return (
<View <View
style={{ style={{
position: "absolute", position: "absolute",
// Sit just above the slider — high enough not to overlap the
// progress bar, low enough to feel anchored to the thumb.
left: -BUBBLE_LEFT_OFFSET * imageScale, left: -BUBBLE_LEFT_OFFSET * imageScale,
bottom: 0, bottom: 0,
paddingTop: 12, paddingTop: 30,
paddingBottom: 5, paddingBottom: 5,
width: tileWidth * BUBBLE_WIDTH_MULTIPLIER * imageScale, width: tileWidth * BUBBLE_WIDTH_MULTIPLIER * imageScale,
justifyContent: "center", justifyContent: "center",
alignItems: "center", alignItems: "center",
// Bring the bubble in front of the player title / overlays.
zIndex: 999,
elevation: 10,
}} }}
> >
<View <View
@@ -97,51 +89,10 @@ export const TrickplayBubble: FC<TrickplayBubbleProps> = ({
source={{ uri: url }} source={{ uri: url }}
contentFit='cover' contentFit='cover'
/> />
{/*
* Bottom-right overlay (Jellyfin web style) — chapter name (small,
* faded) above the timestamp (small, bold). Sits on top of the
* trickplay frame inside the same overflow:hidden container so it
* always stays within the bubble bounds.
*/}
<View
pointerEvents='none'
style={{
position: "absolute",
left: 4,
bottom: 3,
alignItems: "flex-start",
paddingHorizontal: 3,
paddingVertical: 1,
borderRadius: 3,
backgroundColor: "rgba(0,0,0,0.55)",
maxWidth: tileWidth - 8,
}}
>
{chapterName ? (
<Text
numberOfLines={1}
style={{
color: "#fff",
fontSize: 7,
opacity: 0.85,
lineHeight: 9,
}}
>
{chapterName}
</Text>
) : null}
<Text
style={{
color: "#fff",
fontSize: 8,
fontWeight: "600",
lineHeight: 10,
}}
>
{timeStr}
</Text>
</View>
</View> </View>
<Text style={{ marginTop: 30, fontSize: 16 }}>
{formatTime(time.hours, time.minutes, time.seconds)}
</Text>
</View> </View>
); );
}; };

View File

@@ -35,10 +35,6 @@ interface UseRemoteControlProps {
onLongSeekStop?: () => void; onLongSeekStop?: () => void;
/** Callback when up/down D-pad pressed (to show controls with play button focused) */ /** Callback when up/down D-pad pressed (to show controls with play button focused) */
onVerticalDpad?: () => void; onVerticalDpad?: () => void;
/** Called before the exit confirmation Alert is shown (e.g., to pause countdown) */
onWillExit?: () => void;
/** Called when the user cancels the exit confirmation Alert */
onCancelExit?: () => void;
// Legacy props - kept for backwards compatibility with mobile Controls.tsx // Legacy props - kept for backwards compatibility with mobile Controls.tsx
// These are ignored in the simplified implementation // These are ignored in the simplified implementation
progress?: SharedValue<number>; progress?: SharedValue<number>;
@@ -76,8 +72,6 @@ export function useRemoteControl({
onLongSeekRightStart, onLongSeekRightStart,
onLongSeekStop, onLongSeekStop,
onVerticalDpad, onVerticalDpad,
onWillExit,
onCancelExit,
}: UseRemoteControlProps) { }: UseRemoteControlProps) {
// Keep these for backward compatibility with the component // Keep these for backward compatibility with the component
const remoteScrubProgress = useSharedValue<number | null>(null); const remoteScrubProgress = useSharedValue<number | null>(null);
@@ -91,24 +85,13 @@ export function useRemoteControl({
const onHideControlsRef = useRef(onHideControls); const onHideControlsRef = useRef(onHideControls);
const onBackRef = useRef(onBack); const onBackRef = useRef(onBack);
const videoTitleRef = useRef(videoTitle); const videoTitleRef = useRef(videoTitle);
const onWillExitRef = useRef(onWillExit);
const onCancelExitRef = useRef(onCancelExit);
useEffect(() => { useEffect(() => {
showControlsRef.current = showControls; showControlsRef.current = showControls;
onHideControlsRef.current = onHideControls; onHideControlsRef.current = onHideControls;
onBackRef.current = onBack; onBackRef.current = onBack;
videoTitleRef.current = videoTitle; videoTitleRef.current = videoTitle;
onWillExitRef.current = onWillExit; }, [showControls, onHideControls, onBack, videoTitle]);
onCancelExitRef.current = onCancelExit;
}, [
showControls,
onHideControls,
onBack,
videoTitle,
onWillExit,
onCancelExit,
]);
// BackHandler owns player exit: Android TV sends hardware back here, and // BackHandler owns player exit: Android TV sends hardware back here, and
// react-native-tvos maps the Apple TV menu button to the same API. // react-native-tvos maps the Apple TV menu button to the same API.
@@ -119,9 +102,6 @@ export function useRemoteControl({
return true; return true;
} }
if (onBackRef.current) { if (onBackRef.current) {
// Signal Controls that exit is imminent (pauses countdown, sets guard)
onWillExitRef.current?.();
// Controls are hidden, so confirm before leaving playback. // Controls are hidden, so confirm before leaving playback.
Alert.alert( Alert.alert(
"Stop Playback", "Stop Playback",
@@ -129,11 +109,7 @@ export function useRemoteControl({
? `Stop playing "${videoTitleRef.current}"?` ? `Stop playing "${videoTitleRef.current}"?`
: "Are you sure you want to stop playback?", : "Are you sure you want to stop playback?",
[ [
{ { text: "Cancel", style: "cancel" },
text: "Cancel",
style: "cancel",
onPress: () => onCancelExitRef.current?.(),
},
{ text: "Stop", style: "destructive", onPress: onBackRef.current }, { text: "Stop", style: "destructive", onPress: onBackRef.current },
], ],
); );

View File

@@ -74,21 +74,6 @@ export function useVideoSlider({
[seek, play, progress, isSeeking], [seek, play, progress, isSeeking],
); );
// Programmatic seek (chapter list, hotkeys) that bypasses the slide gesture.
// Reads `isPlaying` directly instead of `wasPlayingRef`, which is only set
// during a real slide and would carry stale state on a tap-to-seek.
const seekTo = useCallback(
(value: number) => {
const seekValue = Math.max(0, Math.floor(value));
progress.value = seekValue;
seek(seekValue);
if (isPlaying) {
play();
}
},
[seek, play, progress, isPlaying],
);
const handleSliderChange = useCallback( const handleSliderChange = useCallback(
debounce((value: number) => { debounce((value: number) => {
// Convert ms to ticks for trickplay // Convert ms to ticks for trickplay
@@ -111,6 +96,5 @@ export function useVideoSlider({
handleTouchEnd, handleTouchEnd,
handleSliderComplete, handleSliderComplete,
handleSliderChange, handleSliderChange,
seekTo,
}; };
} }

View File

@@ -28,4 +28,4 @@ type Track = {
localPath?: string; localPath?: string;
}; };
export type { EmbeddedSubtitle, ExternalSubtitle, Track, TranscodedSubtitle }; export type { EmbeddedSubtitle, ExternalSubtitle, TranscodedSubtitle, Track };

View File

@@ -49,8 +49,8 @@ export const TVGaps = {
* Base padding values in pixels. * Base padding values in pixels.
*/ */
export const TVPadding = { export const TVPadding = {
/** Horizontal padding from screen edges (static — matches native search inset) */ /** Horizontal padding from screen edges */
horizontal: 80, horizontal: 90,
/** Padding to accommodate scale animations (1.05x) */ /** Padding to accommodate scale animations (1.05x) */
scale: 20, scale: 20,
@@ -142,9 +142,7 @@ export const useScaledTVSizes = (): ScaledTVSizes => {
large: Math.round(scaleSize(TVGaps.large) * scale), large: Math.round(scaleSize(TVGaps.large) * scale),
}, },
padding: { padding: {
// Static: matches the native tvOS search bar inset, which is a fixed horizontal: Math.round(scaleSize(TVPadding.horizontal) * scale),
// point value and does not change with the typography scale setting.
horizontal: TVPadding.horizontal,
scale: Math.round(scaleSize(TVPadding.scale) * scale), scale: Math.round(scaleSize(TVPadding.scale) * scale),
vertical: Math.round(scaleSize(TVPadding.vertical) * scale), vertical: Math.round(scaleSize(TVPadding.vertical) * scale),
heroHeight: TVPadding.heroHeight * scale, heroHeight: TVPadding.heroHeight * scale,

View File

@@ -13,17 +13,11 @@ export const excludeFields = (fieldsToExclude: ItemFields[]) => {
); );
}; };
type ExtraQueryOptions = {
gcTime?: number;
staleTime?: number;
};
export const useItemQuery = ( export const useItemQuery = (
itemId: string | undefined, itemId: string | undefined,
isOffline?: boolean, isOffline?: boolean,
fields?: ItemFields[], fields?: ItemFields[],
excludeFields?: ItemFields[], excludeFields?: ItemFields[],
queryOptions?: ExtraQueryOptions,
) => { ) => {
const [api] = useAtom(apiAtom); const [api] = useAtom(apiAtom);
const [user] = useAtom(userAtom); const [user] = useAtom(userAtom);
@@ -62,6 +56,5 @@ export const useItemQuery = (
refetchOnWindowFocus: true, refetchOnWindowFocus: true,
refetchOnReconnect: true, refetchOnReconnect: true,
networkMode: "always", networkMode: "always",
...queryOptions,
}); });
}; };

View File

@@ -80,7 +80,7 @@ export const usePlaybackManager = ({
const { data: adjacentItems } = useQuery({ const { data: adjacentItems } = useQuery({
queryKey: ["adjacentItems", item?.Id, item?.SeriesId, isOffline], queryKey: ["adjacentItems", item?.Id, item?.SeriesId, isOffline],
queryFn: async (): Promise<BaseItemDto[] | null> => { queryFn: async (): Promise<BaseItemDto[] | null> => {
if (!item?.SeriesId) { if (!item || !item.SeriesId) {
return null; return null;
} }

View File

@@ -1,50 +0,0 @@
import { useFocusEffect } from "expo-router";
import { useCallback, useRef } from "react";
import { useNetworkAwareQueryClient } from "@/hooks/useNetworkAwareQueryClient";
// Query keys that depend on the set of library items. Kept in sync with the
// LibraryChanged handler in WebSocketProvider.
const LIBRARY_QUERY_KEYS = [
["home"],
["library-items"],
["nextUp-all"],
["nextUp"],
["resumeItems"],
];
/**
* Fallback refresh for newly added/removed content.
*
* The primary path is the server's `LibraryChanged` WebSocket event (handled in
* WebSocketProvider). This hook is a safety net for cases where the socket was
* down or the change happened while the screen was unfocused: when the screen
* regains focus, it invalidates the library-dependent queries so React Query
* refetches the latest content.
*
* Skips the refresh on the very first focus (initial mount already fetches) and
* throttles to avoid refetch storms when quickly switching tabs.
*/
export function useRefreshLibraryOnFocus(throttleMs = 30_000) {
const queryClient = useNetworkAwareQueryClient();
const hasFocusedOnce = useRef(false);
const lastRefreshRef = useRef(0);
useFocusEffect(
useCallback(() => {
if (!hasFocusedOnce.current) {
hasFocusedOnce.current = true;
return;
}
const now = Date.now();
if (now - lastRefreshRef.current < throttleMs) {
return;
}
lastRefreshRef.current = now;
for (const queryKey of LIBRARY_QUERY_KEYS) {
queryClient.invalidateQueries({ queryKey });
}
}, [queryClient, throttleMs]),
);
}

View File

@@ -21,7 +21,7 @@ export const useSessions = ({
const { data, isLoading } = useQuery({ const { data, isLoading } = useQuery({
queryKey: ["sessions"], queryKey: ["sessions"],
queryFn: async () => { queryFn: async () => {
if (!api || !user?.Policy?.IsAdministrator) { if (!api || !user || !user.Policy?.IsAdministrator) {
return []; return [];
} }
const response = await getSessionApi(api).getSessions({ const response = await getSessionApi(api).getSessions({
@@ -55,7 +55,7 @@ export const useAllSessions = ({
const { data, isLoading } = useQuery({ const { data, isLoading } = useQuery({
queryKey: ["allSessions"], queryKey: ["allSessions"],
queryFn: async () => { queryFn: async () => {
if (!api || !user?.Policy?.IsAdministrator) { if (!api || !user || !user.Policy?.IsAdministrator) {
return []; return [];
} }
const response = await getSessionApi(api).getSessions({ const response = await getSessionApi(api).getSessions({

View File

@@ -177,9 +177,6 @@ export const useAddToWatchlist = () => {
} }
}, },
onSuccess: (_data, variables) => { onSuccess: (_data, variables) => {
queryClient.invalidateQueries({
queryKey: ["streamystats", "watchlists"],
});
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: ["streamystats", "watchlist", variables.watchlistId], queryKey: ["streamystats", "watchlist", variables.watchlistId],
}); });
@@ -238,9 +235,6 @@ export const useRemoveFromWatchlist = () => {
} }
}, },
onSuccess: (_data, variables) => { onSuccess: (_data, variables) => {
queryClient.invalidateQueries({
queryKey: ["streamystats", "watchlists"],
});
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: ["streamystats", "watchlist", variables.watchlistId], queryKey: ["streamystats", "watchlist", variables.watchlistId],
}); });

View File

@@ -236,43 +236,37 @@ class MPVLayerRenderer(private val context: Context) : MPVLib.EventObserver {
} }
/** /**
* Attach surface and ensure video output is active. * Attach surface and re-enable video output.
* * Based on Findroid's implementation.
* During PiP transitions, the surface is destroyed and recreated by Android.
* We keep the VO pipeline alive (not killed with vo=null) so that rendering
* resumes immediately when the new surface is attached — avoiding the black
* screen that occurs when the VO is fully re-initialized via setOptionString.
*/ */
fun attachSurface(surface: Surface) { fun attachSurface(surface: Surface) {
this.surface = surface this.surface = surface
Log.i(TAG, "[PiP] attachSurface — isRunning=$isRunning, vo=$voDriver, surface=${surface.hashCode()}")
if (isRunning) { if (isRunning) {
MPVLib.attachSurface(surface) MPVLib.attachSurface(surface)
// Re-enable video output after attaching surface (Findroid approach)
MPVLib.setOptionString("force-window", "yes") MPVLib.setOptionString("force-window", "yes")
// Read back vo to confirm it's still active MPVLib.setOptionString("vo", voDriver)
val activeVo = try { MPVLib.getPropertyString("vo") } catch (e: Exception) { null } Log.i(TAG, "Surface attached, video output re-enabled (vo=$voDriver)")
Log.i(TAG, "[PiP] attachSurface — attached, activeVo=$activeVo")
} }
} }
/** /**
* Detach surface without killing the VO pipeline. * Detach surface and disable video output.
* * Based on Findroid's implementation.
* The previous approach (vo=null / force-window=no) destroyed the entire video
* output pipeline on every surface transition. During PiP mode, the rapid
* destroy/recreate cycle caused a black screen because setOptionString("vo", ...)
* did not properly re-initialize rendering into the new PiP surface.
*
* By keeping the VO alive, frames are simply dropped while no surface is
* attached, and rendering resumes immediately when the new surface arrives.
*/ */
fun detachSurface() { fun detachSurface() {
this.surface = null this.surface = null
Log.i(TAG, "[PiP] detachSurface — isRunning=$isRunning, vo=$voDriver")
if (isRunning) { if (isRunning) {
try {
// Disable video output before detaching surface (Findroid approach)
MPVLib.setOptionString("vo", "null")
MPVLib.setOptionString("force-window", "no")
Log.i(TAG, "Video output disabled before surface detach")
} catch (e: Exception) {
Log.e(TAG, "Failed to disable video output: ${e.message}")
}
MPVLib.detachSurface() MPVLib.detachSurface()
val activeVo = try { MPVLib.getPropertyString("vo") } catch (e: Exception) { null }
Log.i(TAG, "[PiP] detachSurface — detached, activeVo=$activeVo (should still be $voDriver)")
} }
} }
@@ -283,24 +277,7 @@ class MPVLayerRenderer(private val context: Context) : MPVLib.EventObserver {
fun updateSurfaceSize(width: Int, height: Int) { fun updateSurfaceSize(width: Int, height: Int) {
if (isRunning) { if (isRunning) {
MPVLib.setPropertyString("android-surface-size", "${width}x$height") MPVLib.setPropertyString("android-surface-size", "${width}x$height")
Log.i(TAG, "[PiP] updateSurfaceSize ${width}x${height}") Log.i(TAG, "Surface size updated: ${width}x$height")
} else {
Log.w(TAG, "[PiP] updateSurfaceSize — called but renderer not running")
}
}
/**
* Force mpv to render a frame to the current surface.
* Steps forward one frame then seeks back to the original position.
* Used after PiP entry to work around mpv stopping pixel output.
*/
fun forceRedraw() {
if (!isRunning) return
val pos = cachedPosition
Log.i(TAG, "[PiP] forceRedraw — stepping frame then seeking to $pos")
MPVLib.command(arrayOf("frame-step"))
if (pos > 0) {
MPVLib.command(arrayOf("seek", pos.toString(), "absolute"))
} }
} }
@@ -707,18 +684,10 @@ class MPVLayerRenderer(private val context: Context) : MPVLib.EventObserver {
MPVLib.command(arrayOf("sub-add", subUrl, "auto")) MPVLib.command(arrayOf("sub-add", subUrl, "auto"))
} }
pendingExternalSubtitles = emptyList() pendingExternalSubtitles = emptyList()
}
// Apply the initial audio/subtitle selection now that the file's // Set subtitle after external subs are added
// tracks are enumerated. Setting sid/aid before `loadfile` does not initialSubtitleId?.let { setSubtitleTrack(it) } ?: disableSubtitles()
// reliably stick for embedded tracks (the selection is silently
// dropped), so we (re)apply here for embedded and external alike.
// This is what makes a carried-over subtitle show up on the next
// episode without a manual re-selection.
if (initialAudioId != null && initialAudioId > 0) {
setAudioTrack(initialAudioId)
} }
initialSubtitleId?.let { setSubtitleTrack(it) } ?: disableSubtitles()
if (!isReadyToSeek) { if (!isReadyToSeek) {
isReadyToSeek = true isReadyToSeek = true

View File

@@ -198,7 +198,7 @@ class MpvPlayerModule : Module() {
} }
// Defines events that the view can send to JavaScript // Defines events that the view can send to JavaScript
Events("onLoad", "onPlaybackStateChange", "onProgress", "onError", "onTracksReady", "onPictureInPictureChange") Events("onLoad", "onPlaybackStateChange", "onProgress", "onError", "onTracksReady")
} }
} }
} }

View File

@@ -2,15 +2,12 @@ package expo.modules.mpvplayer
import android.content.Context import android.content.Context
import android.graphics.Color import android.graphics.Color
import android.graphics.Rect import android.os.Build
import android.graphics.SurfaceTexture
import android.os.Handler
import android.os.Looper
import android.util.Log import android.util.Log
import android.view.Surface import android.view.Surface
import android.view.TextureView import android.view.SurfaceHolder
import android.view.View import android.view.SurfaceView
import android.view.ViewGroup import android.widget.FrameLayout
import expo.modules.kotlin.AppContext import expo.modules.kotlin.AppContext
import expo.modules.kotlin.viewevent.EventDispatcher import expo.modules.kotlin.viewevent.EventDispatcher
import expo.modules.kotlin.views.ExpoView import expo.modules.kotlin.views.ExpoView
@@ -31,10 +28,10 @@ data class VideoLoadConfig(
/** /**
* MpvPlayerView - ExpoView that hosts the MPV player. * MpvPlayerView - ExpoView that hosts the MPV player.
* Uses TextureView for reliable Picture-in-Picture support. * This mirrors the iOS MpvPlayerView implementation.
*/ */
class MpvPlayerView(context: Context, appContext: AppContext) : ExpoView(context, appContext), class MpvPlayerView(context: Context, appContext: AppContext) : ExpoView(context, appContext),
MPVLayerRenderer.Delegate, TextureView.SurfaceTextureListener { MPVLayerRenderer.Delegate, SurfaceHolder.Callback {
companion object { companion object {
private const val TAG = "MpvPlayerView" private const val TAG = "MpvPlayerView"
@@ -46,9 +43,8 @@ class MpvPlayerView(context: Context, appContext: AppContext) : ExpoView(context
val onProgress by EventDispatcher() val onProgress by EventDispatcher()
val onError by EventDispatcher() val onError by EventDispatcher()
val onTracksReady by EventDispatcher() val onTracksReady by EventDispatcher()
val onPictureInPictureChange by EventDispatcher()
private var textureView: TextureView private var surfaceView: SurfaceView
private var renderer: MPVLayerRenderer? = null private var renderer: MPVLayerRenderer? = null
private var pipController: PiPController? = null private var pipController: PiPController? = null
@@ -60,29 +56,23 @@ class MpvPlayerView(context: Context, appContext: AppContext) : ExpoView(context
private var pendingConfig: VideoLoadConfig? = null private var pendingConfig: VideoLoadConfig? = null
private var rendererStarted: Boolean = false private var rendererStarted: Boolean = false
private var pendingSurface: Surface? = null private var pendingSurface: Surface? = null
private var surfaceTexture: SurfaceTexture? = null
// PiP state tracking
private var isWaitingForPiPTransition: Boolean = false
private var isPiPSurfaceForced: Boolean = false
private val pipHandler = Handler(Looper.getMainLooper())
init { init {
setBackgroundColor(Color.BLACK) setBackgroundColor(Color.BLACK)
// Create TextureView for video rendering (composites into app window for PiP support) // Create SurfaceView for video rendering
textureView = TextureView(context).apply { surfaceView = SurfaceView(context).apply {
layoutParams = ViewGroup.LayoutParams( layoutParams = FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT FrameLayout.LayoutParams.MATCH_PARENT
) )
surfaceTextureListener = this@MpvPlayerView holder.addCallback(this@MpvPlayerView)
} }
addView(textureView) addView(surfaceView)
// Initialize PiP controller with Expo's AppContext for proper activity access // Initialize PiP controller with Expo's AppContext for proper activity access
pipController = PiPController(context, appContext) pipController = PiPController(context, appContext)
pipController?.setPlayerView(textureView) pipController?.setPlayerView(surfaceView)
pipController?.delegate = object : PiPController.Delegate { pipController?.delegate = object : PiPController.Delegate {
override fun onPlay() { override fun onPlay() {
play() play()
@@ -95,23 +85,6 @@ class MpvPlayerView(context: Context, appContext: AppContext) : ExpoView(context
override fun onSeekBy(seconds: Double) { override fun onSeekBy(seconds: Double) {
seekBy(seconds) seekBy(seconds)
} }
override fun onPictureInPictureModeChanged(isInPiP: Boolean) {
if (isInPiP) {
if (!isWaitingForPiPTransition) {
isWaitingForPiPTransition = true
pipHandler.removeCallbacksAndMessages(null)
for (delay in longArrayOf(500, 1000, 1500, 2000)) {
pipHandler.postDelayed({ forcePiPBufferSize() }, delay)
}
}
} else {
isWaitingForPiPTransition = false
pipHandler.removeCallbacksAndMessages(null)
restoreFromPiP()
}
onPictureInPictureChange(mapOf("isActive" to isInPiP))
}
} }
// Renderer is created lazily in loadVideo once we have the voDriver setting // Renderer is created lazily in loadVideo once we have the voDriver setting
@@ -129,10 +102,13 @@ class MpvPlayerView(context: Context, appContext: AppContext) : ExpoView(context
try { try {
renderer?.start(voDriver ?: "gpu-next") renderer?.start(voDriver ?: "gpu-next")
rendererStarted = true rendererStarted = true
Log.i(TAG, "Renderer started with vo=$voDriver")
// If surface was created before renderer started, attach it now
pendingSurface?.let { surface -> pendingSurface?.let { surface ->
renderer?.attachSurface(surface) renderer?.attachSurface(surface)
pendingSurface = null pendingSurface = null
Log.i(TAG, "Attached pending surface after renderer start")
} }
} catch (e: Exception) { } catch (e: Exception) {
Log.e(TAG, "Failed to start renderer: ${e.message}") Log.e(TAG, "Failed to start renderer: ${e.message}")
@@ -140,18 +116,18 @@ class MpvPlayerView(context: Context, appContext: AppContext) : ExpoView(context
} }
} }
// MARK: - TextureView.SurfaceTextureListener // MARK: - SurfaceHolder.Callback
override fun onSurfaceTextureAvailable(surfaceTexture: SurfaceTexture, width: Int, height: Int) { override fun surfaceCreated(holder: SurfaceHolder) {
this.surfaceTexture = surfaceTexture Log.i(TAG, "Surface created")
val surface = Surface(surfaceTexture)
surfaceTexture.setDefaultBufferSize(width, height)
surfaceReady = true surfaceReady = true
if (rendererStarted) { if (rendererStarted) {
renderer?.attachSurface(surface) renderer?.attachSurface(holder.surface)
} else { } else {
pendingSurface = surface // Renderer not started yet - store surface to attach after start
pendingSurface = holder.surface
Log.i(TAG, "Surface created before renderer started, storing as pending")
} }
// If we have a pending load, execute it now // If we have a pending load, execute it now
@@ -162,20 +138,16 @@ class MpvPlayerView(context: Context, appContext: AppContext) : ExpoView(context
} }
} }
override fun onSurfaceTextureSizeChanged(surfaceTexture: SurfaceTexture, width: Int, height: Int) { override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) {
surfaceTexture.setDefaultBufferSize(width, height) Log.i(TAG, "Surface changed: ${width}x${height}")
// Update MPV with the new surface size (Findroid approach)
renderer?.updateSurfaceSize(width, height) renderer?.updateSurfaceSize(width, height)
} }
override fun onSurfaceTextureDestroyed(surfaceTexture: SurfaceTexture): Boolean { override fun surfaceDestroyed(holder: SurfaceHolder) {
this.surfaceTexture = null Log.i(TAG, "Surface destroyed")
surfaceReady = false surfaceReady = false
renderer?.detachSurface() renderer?.detachSurface()
return false // mpv manages the SurfaceTexture
}
override fun onSurfaceTextureUpdated(surfaceTexture: SurfaceTexture) {
// Called every frame — no action needed, mpv drives rendering directly
} }
// MARK: - Video Loading // MARK: - Video Loading
@@ -267,60 +239,11 @@ class MpvPlayerView(context: Context, appContext: AppContext) : ExpoView(context
// MARK: - Picture in Picture // MARK: - Picture in Picture
fun startPictureInPicture() { fun startPictureInPicture() {
isWaitingForPiPTransition = true Log.i(TAG, "startPictureInPicture called")
pipController?.startPictureInPicture() pipController?.startPictureInPicture()
// Resize buffer to match PiP window after animation settles
pipHandler.removeCallbacksAndMessages(null)
for (delay in longArrayOf(500, 1000, 1500, 2000)) {
pipHandler.postDelayed({ forcePiPBufferSize() }, delay)
}
}
/**
* Resize the SurfaceTexture buffer AND TextureView layout to match the PiP
* visible rect so mpv renders at the PiP window's actual dimensions.
*/
private fun forcePiPBufferSize() {
if (!isWaitingForPiPTransition || !surfaceReady) return
val rect = Rect()
textureView.getGlobalVisibleRect(rect)
val visW = rect.width()
val visH = rect.height()
val vw = textureView.width
val vh = textureView.height
if (visW <= 0 || visH <= 0 || (vw == visW && vh == visH)) return
surfaceTexture?.setDefaultBufferSize(visW, visH)
renderer?.updateSurfaceSize(visW, visH)
// Force TextureView layout to match PiP visible area.
// layoutParams alone doesn't work during PiP because the parent
// never re-lays out its children.
textureView.measure(
View.MeasureSpec.makeMeasureSpec(visW, View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(visH, View.MeasureSpec.EXACTLY)
)
textureView.layout(0, 0, visW, visH)
isPiPSurfaceForced = true
}
private fun restoreFromPiP() {
if (!isPiPSurfaceForced) return
isPiPSurfaceForced = false
val lp = textureView.layoutParams
lp.width = ViewGroup.LayoutParams.MATCH_PARENT
lp.height = ViewGroup.LayoutParams.MATCH_PARENT
textureView.layoutParams = lp
textureView.requestLayout()
} }
fun stopPictureInPicture() { fun stopPictureInPicture() {
isWaitingForPiPTransition = false
pipHandler.removeCallbacksAndMessages(null)
pipController?.stopPictureInPicture() pipController?.stopPictureInPicture()
} }
@@ -445,6 +368,7 @@ class MpvPlayerView(context: Context, appContext: AppContext) : ExpoView(context
} }
override fun onPauseChanged(isPaused: Boolean) { override fun onPauseChanged(isPaused: Boolean) {
// Sync PiP playback rate
pipController?.setPlaybackRate(if (isPaused) 0.0 else 1.0) pipController?.setPlaybackRate(if (isPaused) 0.0 else 1.0)
onPlaybackStateChange(mapOf( onPlaybackStateChange(mapOf(
@@ -470,6 +394,7 @@ class MpvPlayerView(context: Context, appContext: AppContext) : ExpoView(context
} }
override fun onVideoDimensionsChanged(width: Int, height: Int) { override fun onVideoDimensionsChanged(width: Int, height: Int) {
// Update PiP controller with video dimensions for proper aspect ratio
pipController?.setVideoDimensions(width, height) pipController?.setVideoDimensions(width, height)
} }
@@ -480,12 +405,9 @@ class MpvPlayerView(context: Context, appContext: AppContext) : ExpoView(context
// MARK: - Cleanup // MARK: - Cleanup
fun cleanup() { fun cleanup() {
isWaitingForPiPTransition = false
pipHandler.removeCallbacksAndMessages(null)
pipController?.stopPictureInPicture() pipController?.stopPictureInPicture()
renderer?.stop() renderer?.stop()
surfaceTexture = null surfaceView.holder.removeCallback(this)
surfaceReady = false
} }
override fun onDetachedFromWindow() { override fun onDetachedFromWindow() {

View File

@@ -1,42 +1,33 @@
package expo.modules.mpvplayer package expo.modules.mpvplayer
import android.app.Activity import android.app.Activity
import android.app.Application
import android.app.PictureInPictureParams import android.app.PictureInPictureParams
import android.app.RemoteAction
import android.content.BroadcastReceiver
import android.content.Context import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.graphics.drawable.Icon
import android.graphics.Rect import android.graphics.Rect
import android.os.Build import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.util.Log import android.util.Log
import android.util.Rational import android.util.Rational
import android.view.View import android.view.View
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import expo.modules.kotlin.AppContext import expo.modules.kotlin.AppContext
/**
* Picture-in-Picture controller for Android.
* This mirrors the iOS PiPController implementation.
*/
class PiPController(private val context: Context, private val appContext: AppContext? = null) { class PiPController(private val context: Context, private val appContext: AppContext? = null) {
companion object { companion object {
private const val TAG = "PiPController" private const val TAG = "PiPController"
private const val DEFAULT_ASPECT_WIDTH = 16 private const val DEFAULT_ASPECT_WIDTH = 16
private const val DEFAULT_ASPECT_HEIGHT = 9 private const val DEFAULT_ASPECT_HEIGHT = 9
private const val ACTION_PIP_PLAY_PAUSE = "expo.modules.mpvplayer.PIP_PLAY_PAUSE"
private const val ACTION_PIP_SKIP_FORWARD = "expo.modules.mpvplayer.PIP_SKIP_FORWARD"
private const val ACTION_PIP_SKIP_BACKWARD = "expo.modules.mpvplayer.PIP_SKIP_BACKWARD"
} }
interface Delegate { interface Delegate {
fun onPlay() fun onPlay()
fun onPause() fun onPause()
fun onSeekBy(seconds: Double) fun onSeekBy(seconds: Double)
fun onPictureInPictureModeChanged(isInPiP: Boolean)
} }
var delegate: Delegate? = null var delegate: Delegate? = null
@@ -45,18 +36,16 @@ class PiPController(private val context: Context, private val appContext: AppCon
private var currentDuration: Double = 0.0 private var currentDuration: Double = 0.0
private var playbackRate: Double = 1.0 private var playbackRate: Double = 1.0
// Video dimensions for proper aspect ratio
private var videoWidth: Int = 0 private var videoWidth: Int = 0
private var videoHeight: Int = 0 private var videoHeight: Int = 0
// Reference to the player view for source rect
private var playerView: View? = null private var playerView: View? = null
// PiP state tracking /**
private var isInPiPMode: Boolean = false * Check if Picture-in-Picture is supported on this device
private var pipEntryNotified: Boolean = false */
private val pipHandler = Handler(Looper.getMainLooper())
private var lifecycleCallbacks: Application.ActivityLifecycleCallbacks? = null
private var lifecycleRegistered = false
private var pipBroadcastReceiver: BroadcastReceiver? = null
fun isPictureInPictureSupported(): Boolean { fun isPictureInPictureSupported(): Boolean {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE) context.packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)
@@ -65,6 +54,9 @@ class PiPController(private val context: Context, private val appContext: AppCon
} }
} }
/**
* Check if Picture-in-Picture is currently active
*/
fun isPictureInPictureActive(): Boolean { fun isPictureInPictureActive(): Boolean {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val activity = getActivity() val activity = getActivity()
@@ -73,68 +65,68 @@ class PiPController(private val context: Context, private val appContext: AppCon
return false return false
} }
/**
* Start Picture-in-Picture mode
*/
fun startPictureInPicture() { fun startPictureInPicture() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val activity = getActivity()
val activity = getActivity() ?: run { if (activity == null) {
Log.e(TAG, "Cannot start PiP: no activity") Log.e(TAG, "Cannot start PiP: no activity found")
return
}
if (!isPictureInPictureSupported()) {
Log.e(TAG, "PiP not supported on this device")
return
}
try {
val params = buildPiPParams(forEntering = true)
val result = activity.enterPictureInPictureMode(params)
if (!result) {
Log.e(TAG, "enterPictureInPictureMode rejected by system")
isInPiPMode = false
return return
} }
isInPiPMode = true if (!isPictureInPictureSupported()) {
pipEntryNotified = true Log.e(TAG, "PiP not supported on this device")
delegate?.onPictureInPictureModeChanged(true) return
registerLifecycleCallbacks() }
} catch (e: Exception) {
Log.e(TAG, "Failed to enter PiP: ${e.message}") try {
val params = buildPiPParams(forEntering = true)
activity.enterPictureInPictureMode(params)
Log.i(TAG, "Entered PiP mode")
} catch (e: Exception) {
Log.e(TAG, "Failed to enter PiP: ${e.message}")
}
} else {
Log.w(TAG, "PiP requires Android O or higher")
} }
} }
/**
* Stop Picture-in-Picture mode
*/
fun stopPictureInPicture() { fun stopPictureInPicture() {
isInPiPMode = false // On Android, exiting PiP is typically done by the user
pipEntryNotified = false // or by finishing the activity. We can request to move task to back.
unregisterLifecycleCallbacks()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val activity = getActivity() val activity = getActivity()
if (activity?.isInPictureInPictureMode == true) { if (activity?.isInPictureInPictureMode == true) {
// Move task to back which will exit PiP
activity.moveTaskToBack(false) activity.moveTaskToBack(false)
} }
} }
} }
fun isCurrentlyInPiP(): Boolean = isInPiPMode /**
* Update the current playback position and duration
* Note: We don't update PiP params here as we're not using progress in PiP controls
*/
fun setCurrentTime(position: Double, duration: Double) { fun setCurrentTime(position: Double, duration: Double) {
currentPosition = position currentPosition = position
currentDuration = duration currentDuration = duration
} }
/**
* Set the playback rate (0.0 for paused, 1.0 for playing)
*/
fun setPlaybackRate(rate: Double) { fun setPlaybackRate(rate: Double) {
playbackRate = rate playbackRate = rate
if (rate > 0) { // Update PiP params to reflect play/pause state
registerLifecycleCallbacks()
}
// Update PiP params so autoEnterEnabled and action icons track play/pause state
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val activity = getActivity() val activity = getActivity()
if (activity != null) { if (activity?.isInPictureInPictureMode == true) {
try { try {
activity.setPictureInPictureParams(buildPiPParams()) activity.setPictureInPictureParams(buildPiPParams())
} catch (e: Exception) { } catch (e: Exception) {
@@ -144,14 +136,23 @@ class PiPController(private val context: Context, private val appContext: AppCon
} }
} }
/**
* Set the video dimensions for proper aspect ratio calculation
*/
fun setVideoDimensions(width: Int, height: Int) { fun setVideoDimensions(width: Int, height: Int) {
if (width > 0 && height > 0) { if (width > 0 && height > 0) {
videoWidth = width videoWidth = width
videoHeight = height videoHeight = height
Log.i(TAG, "Video dimensions set: ${width}x${height}")
// Update PiP params if active
updatePiPParamsIfNeeded() updatePiPParamsIfNeeded()
} }
} }
/**
* Set the player view reference for source rect hint
*/
fun setPlayerView(view: View?) { fun setPlayerView(view: View?) {
playerView = view playerView = view
} }
@@ -169,15 +170,22 @@ class PiPController(private val context: Context, private val appContext: AppCon
} }
} }
/**
* Build Picture-in-Picture params for the current player state.
* Calculates proper aspect ratio and source rect based on video and view dimensions.
*/
@RequiresApi(Build.VERSION_CODES.O) @RequiresApi(Build.VERSION_CODES.O)
private fun buildPiPParams(forEntering: Boolean = false): PictureInPictureParams { private fun buildPiPParams(forEntering: Boolean = false): PictureInPictureParams {
val view = playerView val view = playerView
val viewWidth = view?.width ?: 0 val viewWidth = view?.width ?: 0
val viewHeight = view?.height ?: 0 val viewHeight = view?.height ?: 0
// Display aspect ratio from view (exactly like Findroid)
val displayAspectRatio = Rational(viewWidth.coerceAtLeast(1), viewHeight.coerceAtLeast(1)) val displayAspectRatio = Rational(viewWidth.coerceAtLeast(1), viewHeight.coerceAtLeast(1))
// Video aspect ratio with 2.39:1 clamping // Video aspect ratio with 2.39:1 clamping (exactly like Findroid)
// Findroid: Rational(it.width.coerceAtMost((it.height * 2.39f).toInt()),
// it.height.coerceAtMost((it.width * 2.39f).toInt()))
val aspectRatio = if (videoWidth > 0 && videoHeight > 0) { val aspectRatio = if (videoWidth > 0 && videoHeight > 0) {
Rational( Rational(
videoWidth.coerceAtMost((videoHeight * 2.39f).toInt()), videoWidth.coerceAtMost((videoHeight * 2.39f).toInt()),
@@ -187,13 +195,26 @@ class PiPController(private val context: Context, private val appContext: AppCon
Rational(DEFAULT_ASPECT_WIDTH, DEFAULT_ASPECT_HEIGHT) Rational(DEFAULT_ASPECT_WIDTH, DEFAULT_ASPECT_HEIGHT)
} }
// Source rect hint calculation (exactly like Findroid)
val sourceRectHint = if (viewWidth > 0 && viewHeight > 0 && videoWidth > 0 && videoHeight > 0) { val sourceRectHint = if (viewWidth > 0 && viewHeight > 0 && videoWidth > 0 && videoHeight > 0) {
if (displayAspectRatio < aspectRatio) { if (displayAspectRatio < aspectRatio) {
// Letterboxing - black bars top/bottom
val space = ((viewHeight - (viewWidth.toFloat() / aspectRatio.toFloat())) / 2).toInt() val space = ((viewHeight - (viewWidth.toFloat() / aspectRatio.toFloat())) / 2).toInt()
Rect(0, space, viewWidth, (viewWidth.toFloat() / aspectRatio.toFloat()).toInt() + space) Rect(
0,
space,
viewWidth,
(viewWidth.toFloat() / aspectRatio.toFloat()).toInt() + space
)
} else { } else {
// Pillarboxing - black bars left/right
val space = ((viewWidth - (viewHeight.toFloat() * aspectRatio.toFloat())) / 2).toInt() val space = ((viewWidth - (viewHeight.toFloat() * aspectRatio.toFloat())) / 2).toInt()
Rect(space, 0, (viewHeight.toFloat() * aspectRatio.toFloat()).toInt() + space, viewHeight) Rect(
space,
0,
(viewHeight.toFloat() * aspectRatio.toFloat()).toInt() + space,
viewHeight
)
} }
} else { } else {
null null
@@ -204,217 +225,39 @@ class PiPController(private val context: Context, private val appContext: AppCon
sourceRectHint?.let { builder.setSourceRectHint(it) } sourceRectHint?.let { builder.setSourceRectHint(it) }
ensurePiPReceiverRegistered() // On Android 12+, enable auto-enter (like Findroid)
builder.setActions(buildPiPActions())
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
builder.setAutoEnterEnabled(forEntering || playbackRate > 0) builder.setAutoEnterEnabled(true)
} }
return builder.build() return builder.build()
} }
private fun getActivity(): Activity? { private fun getActivity(): Activity? {
// First try Expo's AppContext (preferred in React Native)
appContext?.currentActivity?.let { return it } appContext?.currentActivity?.let { return it }
// Fallback: Try to get from context wrapper chain
var ctx = context var ctx = context
while (ctx is android.content.ContextWrapper) { while (ctx is android.content.ContextWrapper) {
if (ctx is Activity) return ctx if (ctx is Activity) {
return ctx
}
ctx = ctx.baseContext ctx = ctx.baseContext
} }
return null return null
} }
// MARK: - Lifecycle-based PiP Detection /**
* Handle PiP action (called from activity when user taps PiP controls)
private fun registerLifecycleCallbacks() { */
if (lifecycleRegistered) return fun handlePiPAction(action: String) {
when (action) {
val app = context.applicationContext as? Application ?: run { "play" -> delegate?.onPlay()
Log.w(TAG, "Cannot access Application for lifecycle callbacks, falling back to polling") "pause" -> delegate?.onPause()
startFallbackPolling() "skip_forward" -> delegate?.onSeekBy(10.0)
return "skip_backward" -> delegate?.onSeekBy(-10.0)
} }
lifecycleCallbacks = object : Application.ActivityLifecycleCallbacks {
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {}
override fun onActivityStarted(activity: Activity) {}
override fun onActivityResumed(activity: Activity) {
if (!isInPiPMode) return
if (!activity.isInPictureInPictureMode) {
isInPiPMode = false
pipEntryNotified = false
delegate?.onPictureInPictureModeChanged(false)
}
}
override fun onActivityPaused(activity: Activity) {
// Proactively hide controls when user leaves while playing,
// before the PiP window captures the UI. onActivityStopped
// will restore if PiP didn't actually enter.
if (playbackRate > 0 && !isInPiPMode) {
isInPiPMode = true
pipEntryNotified = true
delegate?.onPictureInPictureModeChanged(true)
}
}
override fun onActivityStopped(activity: Activity) {
pipHandler.postDelayed({
val inPip = activity.isInPictureInPictureMode
if (inPip && !isInPiPMode) {
isInPiPMode = true
pipEntryNotified = true
delegate?.onPictureInPictureModeChanged(true)
return@postDelayed
}
if (!isInPiPMode) return@postDelayed
if (inPip) return@postDelayed
// Not in PiP after 1s — check again to avoid false positive during transition
pipHandler.postDelayed({
if (!isInPiPMode) return@postDelayed
if (!activity.isInPictureInPictureMode) {
isInPiPMode = false
pipEntryNotified = false
delegate?.onPictureInPictureModeChanged(false)
}
}, 1500)
}, 1000)
}
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {}
override fun onActivityDestroyed(activity: Activity) {
isInPiPMode = false
}
}
app.registerActivityLifecycleCallbacks(lifecycleCallbacks)
lifecycleRegistered = true
}
private fun unregisterLifecycleCallbacks() {
if (!lifecycleRegistered) return
lifecycleCallbacks?.let {
(context.applicationContext as? Application)
?.unregisterActivityLifecycleCallbacks(it)
}
lifecycleCallbacks = null
lifecycleRegistered = false
pipHandler.removeCallbacksAndMessages(null)
unregisterPiPBroadcastReceiver()
}
private fun startFallbackPolling() {
var falseReadCount = 0
pipHandler.removeCallbacksAndMessages(null)
pipHandler.postDelayed(object : Runnable {
override fun run() {
if (!isInPiPMode) return
var ctx = context
var activity: Activity? = null
while (ctx is android.content.ContextWrapper) {
if (ctx is Activity) { activity = ctx; break }
ctx = ctx.baseContext
}
val stillInPip = activity?.isInPictureInPictureMode == true
if (!stillInPip) {
falseReadCount++
if (falseReadCount >= 3) {
isInPiPMode = false
delegate?.onPictureInPictureModeChanged(false)
return
}
pipHandler.postDelayed(this, 500)
return
}
falseReadCount = 0
pipHandler.postDelayed(this, 1000)
}
}, 3000)
}
// MARK: - PiP Remote Actions
private fun ensurePiPReceiverRegistered() {
if (pipBroadcastReceiver != null) return
pipBroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
when (intent.action) {
ACTION_PIP_PLAY_PAUSE -> {
if (playbackRate > 0) delegate?.onPause() else delegate?.onPlay()
}
ACTION_PIP_SKIP_FORWARD -> delegate?.onSeekBy(10.0)
ACTION_PIP_SKIP_BACKWARD -> delegate?.onSeekBy(-10.0)
}
}
}
val filter = IntentFilter().apply {
addAction(ACTION_PIP_PLAY_PAUSE)
addAction(ACTION_PIP_SKIP_FORWARD)
addAction(ACTION_PIP_SKIP_BACKWARD)
}
val registerFlags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
Context.RECEIVER_EXPORTED
} else {
0
}
context.applicationContext.registerReceiver(pipBroadcastReceiver, filter, registerFlags)
}
private fun unregisterPiPBroadcastReceiver() {
pipBroadcastReceiver?.let {
try {
context.applicationContext.unregisterReceiver(it)
} catch (_: Exception) {}
}
pipBroadcastReceiver = null
}
private fun buildPiPActions(): List<RemoteAction> {
val isPlaying = playbackRate > 0
return listOf(
RemoteAction(
Icon.createWithResource(context, android.R.drawable.ic_media_rew),
"Rewind", "Skip backward 10 seconds",
createPiPPendingIntent(ACTION_PIP_SKIP_BACKWARD)
),
RemoteAction(
Icon.createWithResource(
context,
if (isPlaying) android.R.drawable.ic_media_pause else android.R.drawable.ic_media_play
),
if (isPlaying) "Pause" else "Play",
if (isPlaying) "Pause playback" else "Resume playback",
createPiPPendingIntent(ACTION_PIP_PLAY_PAUSE)
),
RemoteAction(
Icon.createWithResource(context, android.R.drawable.ic_media_ff),
"Fast Forward", "Skip forward 10 seconds",
createPiPPendingIntent(ACTION_PIP_SKIP_FORWARD)
)
)
}
private fun createPiPPendingIntent(action: String): android.app.PendingIntent {
val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
android.app.PendingIntent.FLAG_IMMUTABLE
} else {
0
}
return android.app.PendingIntent.getBroadcast(
context.applicationContext, 0, Intent(action), flags
)
} }
} }

View File

@@ -485,7 +485,8 @@ final class MPVLayerRenderer {
switch event.event_id { switch event.event_id {
case MPV_EVENT_FILE_LOADED: case MPV_EVENT_FILE_LOADED:
// Add external subtitles now that the file is loaded // Add external subtitles now that the file is loaded
if !pendingExternalSubtitles.isEmpty, let handle = mpv { let hadExternalSubs = !pendingExternalSubtitles.isEmpty
if hadExternalSubs, let handle = mpv {
for (index, subUrl) in pendingExternalSubtitles.enumerated() { for (index, subUrl) in pendingExternalSubtitles.enumerated() {
print("🔧 Adding external subtitle [\(index)]: \(subUrl)") print("🔧 Adding external subtitle [\(index)]: \(subUrl)")
// Use commandSync to ensure subs are added in exact order (not async) // Use commandSync to ensure subs are added in exact order (not async)
@@ -493,20 +494,12 @@ final class MPVLayerRenderer {
commandSync(handle, ["sub-add", subUrl, "auto"]) commandSync(handle, ["sub-add", subUrl, "auto"])
} }
pendingExternalSubtitles = [] pendingExternalSubtitles = []
} // Set subtitle after external subs are added
// Apply the initial audio/subtitle selection now that the file's if let subId = initialSubtitleId {
// tracks are enumerated. Setting sid/aid before `loadfile` does not setSubtitleTrack(subId)
// reliably stick for embedded tracks (the selection is silently } else {
// dropped), so we (re)apply here for embedded and external alike. disableSubtitles()
// This is what makes a carried-over subtitle show up on the next }
// episode without a manual re-selection.
if let audioId = initialAudioId, audioId > 0 {
setAudioTrack(audioId)
}
if let subId = initialSubtitleId {
setSubtitleTrack(subId)
} else {
disableSubtitles()
} }
if !isReadyToSeek { if !isReadyToSeek {
isReadyToSeek = true isReadyToSeek = true

View File

@@ -1,19 +1,32 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'MpvPlayer' s.name = 'MpvPlayer'
s.version = '1.0.0' s.version = '1.0.0'
s.summary = 'MPV-based video player for Streamyfin (Expo module)' s.summary = 'MPVKit for Expo'
s.author = 'Streamyfin' s.description = 'MPVKit for Expo'
s.homepage = 'https://github.com/streamyfin/streamyfin' s.author = 'mpvkit'
s.platforms = { :ios => '15.1', :tvos => '15.1' } s.homepage = 'https://github.com/mpvkit/MPVKit'
s.source = { git: '' } s.platforms = {
:ios => '15.1',
:tvos => '15.1'
}
s.source = { git: 'https://github.com/mpvkit/MPVKit.git' }
s.static_framework = true s.static_framework = true
s.dependency 'ExpoModulesCore' s.dependency 'ExpoModulesCore'
s.dependency 'MPVKit' s.dependency 'MPVKit-GPL'
# Swift/Objective-C compatibility
s.pod_target_xcconfig = { s.pod_target_xcconfig = {
'DEFINES_MODULE' => 'YES', 'DEFINES_MODULE' => 'YES',
'SWIFT_COMPILATION_MODE' => 'wholemodule' 'VALID_ARCHS' => 'arm64',
'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386',
'DEBUG_INFORMATION_FORMAT' => 'dwarf',
'STRIP_INSTALLED_PRODUCT' => 'YES',
'DEPLOYMENT_POSTPROCESSING' => 'YES',
}
s.user_target_xcconfig = {
'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386'
} }
s.source_files = "*.{h,m,mm,swift,hpp,cpp}" s.source_files = "*.{h,m,mm,swift,hpp,cpp}"

View File

@@ -150,16 +150,6 @@ final class PiPController: NSObject {
CMTimebaseSetRate(tb, rate: Float64(rate)) CMTimebaseSetRate(tb, rate: Float64(rate))
} }
} }
deinit {
if let tb = timebase {
CMTimebaseSetRate(tb, rate: 0)
}
sampleBufferDisplayLayer?.controlTimebase = nil
timebase = nil
pipController?.delegate = nil
pipController = nil
}
} }
// MARK: - AVPictureInPictureControllerDelegate // MARK: - AVPictureInPictureControllerDelegate

View File

@@ -25,10 +25,6 @@ export type OnErrorEventPayload = {
export type OnTracksReadyEventPayload = Record<string, never>; export type OnTracksReadyEventPayload = Record<string, never>;
export type OnPictureInPictureChangePayload = {
isActive: boolean;
};
export type NowPlayingMetadata = { export type NowPlayingMetadata = {
title?: string; title?: string;
artist?: string; artist?: string;
@@ -81,9 +77,6 @@ export type MpvPlayerViewProps = {
onProgress?: (event: { nativeEvent: OnProgressEventPayload }) => void; onProgress?: (event: { nativeEvent: OnProgressEventPayload }) => void;
onError?: (event: { nativeEvent: OnErrorEventPayload }) => void; onError?: (event: { nativeEvent: OnErrorEventPayload }) => void;
onTracksReady?: (event: { nativeEvent: OnTracksReadyEventPayload }) => void; onTracksReady?: (event: { nativeEvent: OnTracksReadyEventPayload }) => void;
onPictureInPictureChange?: (event: {
nativeEvent: OnPictureInPictureChangePayload;
}) => void;
}; };
export interface MpvPlayerViewRef { export interface MpvPlayerViewRef {

View File

@@ -7,8 +7,6 @@ import { MpvPlayerViewProps, MpvPlayerViewRef } from "./MpvPlayer.types";
const NativeView: React.ComponentType<MpvPlayerViewProps & { ref?: any }> = const NativeView: React.ComponentType<MpvPlayerViewProps & { ref?: any }> =
requireNativeView("MpvPlayer"); requireNativeView("MpvPlayer");
const PIP_LOG = "[PiP] MpvPlayerView.tsx:";
export default React.forwardRef<MpvPlayerViewRef, MpvPlayerViewProps>( export default React.forwardRef<MpvPlayerViewRef, MpvPlayerViewProps>(
function MpvPlayerView(props, ref) { function MpvPlayerView(props, ref) {
const nativeRef = useRef<any>(null); const nativeRef = useRef<any>(null);
@@ -42,24 +40,16 @@ export default React.forwardRef<MpvPlayerViewRef, MpvPlayerViewProps>(
return await nativeRef.current?.getDuration(); return await nativeRef.current?.getDuration();
}, },
startPictureInPicture: async () => { startPictureInPicture: async () => {
console.log(PIP_LOG, "startPictureInPicture → native");
await nativeRef.current?.startPictureInPicture(); await nativeRef.current?.startPictureInPicture();
console.log(PIP_LOG, "startPictureInPicture ← native returned");
}, },
stopPictureInPicture: async () => { stopPictureInPicture: async () => {
console.log(PIP_LOG, "stopPictureInPicture → native");
await nativeRef.current?.stopPictureInPicture(); await nativeRef.current?.stopPictureInPicture();
console.log(PIP_LOG, "stopPictureInPicture ← native returned");
}, },
isPictureInPictureSupported: async () => { isPictureInPictureSupported: async () => {
const result = await nativeRef.current?.isPictureInPictureSupported(); return await nativeRef.current?.isPictureInPictureSupported();
console.log(PIP_LOG, "isPictureInPictureSupported =", result);
return result;
}, },
isPictureInPictureActive: async () => { isPictureInPictureActive: async () => {
const result = await nativeRef.current?.isPictureInPictureActive(); return await nativeRef.current?.isPictureInPictureActive();
console.log(PIP_LOG, "isPictureInPictureActive =", result);
return result;
}, },
getSubtitleTracks: async () => { getSubtitleTracks: async () => {
return await nativeRef.current?.getSubtitleTracks(); return await nativeRef.current?.getSubtitleTracks();

View File

@@ -1,6 +0,0 @@
{
"platforms": ["apple"],
"apple": {
"modules": ["TvSearchModule"]
}
}

View File

@@ -1,2 +0,0 @@
export { default as TvSearchView } from "./src/TvSearchView";
export * from "./src/TvSearchView.types";

View File

@@ -1,22 +0,0 @@
Pod::Spec.new do |s|
s.name = 'TvSearch'
s.version = '1.0.0'
s.summary = 'Native tvOS search field with text change events'
s.description = 'Hosts SwiftUI .searchable inside a UIHostingController so React Native can render its own results grid while using the native tvOS search bar and grid keyboard.'
s.author = ''
s.homepage = 'https://docs.expo.dev/modules/'
s.platforms = {
:tvos => '15.1'
}
s.source = { git: '' }
s.static_framework = true
s.dependency 'ExpoModulesCore'
s.pod_target_xcconfig = {
'DEFINES_MODULE' => 'YES',
'SWIFT_COMPILATION_MODE' => 'wholemodule'
}
s.source_files = "**/*.{h,m,mm,swift}"
end

View File

@@ -1,15 +0,0 @@
import ExpoModulesCore
public class TvSearchModule: Module {
public func definition() -> ModuleDefinition {
Name("TvSearchModule")
View(TvSearchView.self) {
Events("onChangeText")
Prop("placeholder") { (view: TvSearchView, value: String?) in
view.setPlaceholder(value ?? "")
}
}
}
}

View File

@@ -1,206 +0,0 @@
import ExpoModulesCore
import SwiftUI
// React Native tvOS notification names for controlling gesture handler behavior.
// These match the constants in RCTTVRemoteHandler.h and are what make keyboard
// input actually reach the native search field on tvOS.
private let RCTTVDisableGestureHandlersCancelTouchesNotification = Notification.Name(
"RCTTVDisableGestureHandlersCancelTouchesNotification")
private let RCTTVEnableGestureHandlersCancelTouchesNotification = Notification.Name(
"RCTTVEnableGestureHandlersCancelTouchesNotification")
#if os(tvOS)
/// Holds the search state. ObservableObject so we can update placeholder/text
/// without recreating the SwiftUI hierarchy.
class TvSearchViewModel: ObservableObject {
@Published var searchText: String = ""
@Published var placeholder: String = "Search..."
@Published var accentColor: Color = .white
var onSearch: ((String) -> Void)?
}
/// SwiftUI content hosting `.searchable`. This mirrors expo-tvos-search's
/// structure `.searchable` attached inside a `NavigationView` (REQUIRED:
/// `.searchable` only renders a search bar in a navigation context) but with
/// the results grid REMOVED. The body is just transparent filler so the search
/// field + native grid keyboard render; results are drawn by React Native
/// below this native view instead.
struct TvSearchContentView: View {
@ObservedObject var viewModel: TvSearchViewModel
var body: some View {
NavigationView {
// Transparent filler gives `.searchable` something to attach to and
// lets the native search bar/keyboard own the space.
Color.clear
.frame(maxWidth: .infinity, maxHeight: .infinity)
.searchable(text: $viewModel.searchText, prompt: viewModel.placeholder)
.onChange(of: viewModel.searchText) { newValue in
viewModel.onSearch?(newValue)
}
}
.tint(viewModel.accentColor)
}
}
class TvSearchView: ExpoView {
private var hostingController: UIHostingController<TvSearchContentView>?
private let viewModel = TvSearchViewModel()
private var gestureHandlersDisabled = false
private var disabledGestureRecognizers: [UIGestureRecognizer] = []
let onChangeText = EventDispatcher()
required init(appContext: AppContext? = nil) {
super.init(appContext: appContext)
setupView()
}
deinit {
NotificationCenter.default.removeObserver(self)
hostingController?.willMove(toParent: nil)
hostingController?.removeFromParent()
#if !targetEnvironment(simulator)
enableParentGestureRecognizers()
#endif
if gestureHandlersDisabled {
NotificationCenter.default.post(
name: RCTTVEnableGestureHandlersCancelTouchesNotification, object: nil)
}
}
func setPlaceholder(_ value: String) {
viewModel.placeholder = value
}
private func setupView() {
viewModel.onSearch = { [weak self] query in
self?.onChangeText(["text": query])
}
let controller = UIHostingController(rootView: TvSearchContentView(viewModel: viewModel))
controller.view.backgroundColor = .clear
hostingController = controller
addSubview(controller.view)
controller.view.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
controller.view.topAnchor.constraint(equalTo: topAnchor),
controller.view.bottomAnchor.constraint(equalTo: bottomAnchor),
controller.view.leadingAnchor.constraint(equalTo: leadingAnchor),
controller.view.trailingAnchor.constraint(equalTo: trailingAnchor),
])
if let parentVC = parentViewController() {
parentVC.addChild(controller)
controller.didMove(toParent: parentVC)
}
// Detect when the search keyboard becomes active so we can release RN's
// remote gesture handling (otherwise keystrokes never reach the field).
NotificationCenter.default.addObserver(
self, selector: #selector(handleTextFieldDidBeginEditing),
name: UITextField.textDidBeginEditingNotification, object: nil)
NotificationCenter.default.addObserver(
self, selector: #selector(handleTextFieldDidEndEditing),
name: UITextField.textDidEndEditingNotification, object: nil)
}
// MARK: - View controller containment
/// SwiftUI needs proper appearance lifecycle events for `.searchable` to
/// register with tvOS's focus system, so we manage child VC containment as
/// the view enters/leaves the window.
override func didMoveToWindow() {
super.didMoveToWindow()
guard let controller = hostingController else { return }
if window != nil {
if controller.parent == nil, let parentVC = parentViewController() {
parentVC.addChild(controller)
controller.didMove(toParent: parentVC)
}
} else {
controller.willMove(toParent: nil)
controller.removeFromParent()
}
}
private func parentViewController() -> UIViewController? {
var responder: UIResponder? = self
while let next = responder?.next {
if let vc = next as? UIViewController { return vc }
responder = next
}
return nil
}
// MARK: - Keyboard / gesture handling
@objc private func handleTextFieldDidBeginEditing(_ notification: Notification) {
guard let textField = notification.object as? UITextField,
let hostingView = hostingController?.view,
textField.isDescendant(of: hostingView)
else { return }
guard !gestureHandlersDisabled else { return }
gestureHandlersDisabled = true
NotificationCenter.default.post(
name: RCTTVDisableGestureHandlersCancelTouchesNotification, object: nil)
#if !targetEnvironment(simulator)
disableParentGestureRecognizers()
#endif
}
@objc private func handleTextFieldDidEndEditing(_ notification: Notification) {
guard let textField = notification.object as? UITextField,
let hostingView = hostingController?.view,
textField.isDescendant(of: hostingView)
else { return }
guard gestureHandlersDisabled else { return }
gestureHandlersDisabled = false
#if !targetEnvironment(simulator)
enableParentGestureRecognizers()
#endif
NotificationCenter.default.post(
name: RCTTVEnableGestureHandlersCancelTouchesNotification, object: nil)
}
private func disableParentGestureRecognizers() {
disabledGestureRecognizers.removeAll()
var currentView: UIView? = superview
while let view = currentView {
for recognizer in view.gestureRecognizers ?? [] {
let isTapOrPress =
recognizer is UITapGestureRecognizer || recognizer is UILongPressGestureRecognizer
if isTapOrPress && recognizer.isEnabled {
recognizer.isEnabled = false
disabledGestureRecognizers.append(recognizer)
}
}
currentView = view.superview
}
}
private func enableParentGestureRecognizers() {
for recognizer in disabledGestureRecognizers {
recognizer.isEnabled = true
}
disabledGestureRecognizers.removeAll()
}
}
#else
// Fallback for non-tvOS platforms (iOS).
class TvSearchView: ExpoView {
let onChangeText = EventDispatcher()
func setPlaceholder(_ value: String) {}
}
#endif

View File

@@ -1,10 +0,0 @@
{
"name": "tv-search",
"version": "0.1.0",
"description": "Native tvOS search field (SwiftUI .searchable) emitting typed text to React Native",
"main": "index.ts",
"platforms": [
"apple"
],
"devDependencies": {}
}

View File

@@ -1,22 +0,0 @@
import { requireNativeView } from "expo";
import * as React from "react";
import type { View } from "react-native";
import type { TvSearchViewProps } from "./TvSearchView.types";
const NativeView: React.ComponentType<
TvSearchViewProps & React.RefAttributes<View>
> = requireNativeView("TvSearchModule");
/**
* Forwards its ref to the underlying native view so it can be used as a
* `TVFocusGuideView` `destinations` target for routing focus into the native
* search bar.
*/
const TvSearchView = React.forwardRef<View, TvSearchViewProps>((props, ref) => {
return <NativeView ref={ref} {...props} />;
});
TvSearchView.displayName = "TvSearchView";
export default TvSearchView;

View File

@@ -1,12 +0,0 @@
import type { ViewProps } from "react-native";
export interface TvSearchTextChangeEvent {
nativeEvent: { text: string };
}
export interface TvSearchViewProps extends ViewProps {
/** Placeholder shown in the native search bar. */
placeholder?: string;
/** Fired as the user types in the native search bar. */
onChangeText?: (event: TvSearchTextChangeEvent) => void;
}

View File

@@ -28,59 +28,61 @@
"dependencies": { "dependencies": {
"@bottom-tabs/react-navigation": "1.2.0", "@bottom-tabs/react-navigation": "1.2.0",
"@douglowder/expo-av-route-picker-view": "^0.0.5", "@douglowder/expo-av-route-picker-view": "^0.0.5",
"@expo/metro-runtime": "~56.0.13", "@expo/metro-runtime": "~55.0.11",
"@expo/react-native-action-sheet": "^4.1.1", "@expo/react-native-action-sheet": "^4.1.1",
"@expo/ui": "~56.0.14", "@expo/ui": "~55.0.17",
"@expo/vector-icons": "^15.0.3", "@expo/vector-icons": "^15.0.3",
"@gorhom/bottom-sheet": "5.2.8", "@gorhom/bottom-sheet": "5.2.8",
"@jellyfin/sdk": "^0.13.0", "@jellyfin/sdk": "^0.13.0",
"@react-native-community/netinfo": "^12.0.0", "@react-native-community/netinfo": "^12.0.0",
"@react-navigation/material-top-tabs": "7.4.9",
"@react-navigation/native": "^7.2.5", "@react-navigation/native": "^7.2.5",
"@react-navigation/native-stack": "~7.14.5",
"@shopify/flash-list": "2.0.2", "@shopify/flash-list": "2.0.2",
"@tanstack/query-sync-storage-persister": "^5.100.14", "@tanstack/query-sync-storage-persister": "^5.90.18",
"@tanstack/react-pacer": "^0.19.1", "@tanstack/react-pacer": "^0.19.1",
"@tanstack/react-query": "5.100.14", "@tanstack/react-query": "5.90.20",
"@tanstack/react-query-persist-client": "^5.100.14", "@tanstack/react-query-persist-client": "^5.90.18",
"axios": "^1.7.9", "axios": "^1.7.9",
"expo": "~56.0.6", "expo": "~55.0.26",
"expo-application": "~56.0.3", "expo-application": "~55.0.15",
"expo-asset": "~56.0.15", "expo-asset": "~55.0.17",
"expo-audio": "~56.0.11", "expo-audio": "~55.0.0",
"expo-background-task": "~56.0.15", "expo-background-task": "~55.0.18",
"expo-blur": "~56.0.3", "expo-blur": "~55.0.14",
"expo-brightness": "~56.0.5", "expo-brightness": "~55.0.13",
"expo-build-properties": "~56.0.15", "expo-build-properties": "~55.0.14",
"expo-camera": "~56.0.7", "expo-camera": "~55.0.19",
"expo-constants": "~56.0.16", "expo-constants": "~55.0.16",
"expo-crypto": "~56.0.4", "expo-crypto": "~55.0.15",
"expo-dev-client": "~56.0.16", "expo-dev-client": "~55.0.35",
"expo-device": "~56.0.4", "expo-device": "~55.0.17",
"expo-font": "~56.0.5", "expo-font": "~55.0.8",
"expo-haptics": "~56.0.3", "expo-haptics": "~55.0.14",
"expo-image": "~56.0.9", "expo-image": "~55.0.11",
"expo-linear-gradient": "~56.0.4", "expo-linear-gradient": "~55.0.14",
"expo-linking": "~56.0.12", "expo-linking": "~55.0.15",
"expo-localization": "~56.0.6", "expo-localization": "~55.0.15",
"expo-location": "~56.0.14", "expo-location": "~55.1.10",
"expo-notifications": "~56.0.14", "expo-notifications": "~55.0.23",
"expo-router": "~56.2.7", "expo-router": "~55.0.16",
"expo-screen-orientation": "~56.0.5", "expo-screen-orientation": "~55.0.16",
"expo-secure-store": "~56.0.4", "expo-secure-store": "~55.0.14",
"expo-sharing": "~56.0.14", "expo-sharing": "~55.0.20",
"expo-splash-screen": "~56.0.10", "expo-splash-screen": "~55.0.21",
"expo-status-bar": "~56.0.4", "expo-status-bar": "~55.0.6",
"expo-system-ui": "~56.0.5", "expo-system-ui": "~55.0.18",
"expo-task-manager": "~56.0.15", "expo-task-manager": "~55.0.16",
"expo-web-browser": "~56.0.5", "expo-web-browser": "~55.0.16",
"i18next": "^26.3.0", "i18next": "^25.0.0",
"jotai": "2.20.0", "jotai": "2.16.2",
"lodash": "4.18.1", "lodash": "4.17.23",
"nativewind": "^2.0.11", "nativewind": "^2.0.11",
"patch-package": "^8.0.0", "patch-package": "^8.0.0",
"react": "19.2.3", "react": "19.2.0",
"react-dom": "19.2.3", "react-dom": "19.2.0",
"react-i18next": "17.0.8", "react-i18next": "16.5.3",
"react-native": "npm:react-native-tvos@0.85.3-0", "react-native": "npm:react-native-tvos@0.83.6-0",
"react-native-awesome-slider": "^2.9.0", "react-native-awesome-slider": "^2.9.0",
"react-native-bottom-tabs": "1.2.0", "react-native-bottom-tabs": "1.2.0",
"react-native-circular-progress": "^1.4.1", "react-native-circular-progress": "^1.4.1",
@@ -89,7 +91,7 @@
"react-native-device-info": "^15.0.0", "react-native-device-info": "^15.0.0",
"react-native-draggable-flatlist": "^4.0.3", "react-native-draggable-flatlist": "^4.0.3",
"react-native-edge-to-edge": "^1.7.0", "react-native-edge-to-edge": "^1.7.0",
"react-native-gesture-handler": "~3.0.0", "react-native-gesture-handler": "~2.30.0",
"react-native-glass-effect-view": "^1.0.0", "react-native-glass-effect-view": "^1.0.0",
"react-native-google-cast": "^4.9.1", "react-native-google-cast": "^4.9.1",
"react-native-image-colors": "^2.4.0", "react-native-image-colors": "^2.4.0",
@@ -97,13 +99,13 @@
"react-native-ios-utilities": "5.2.0", "react-native-ios-utilities": "5.2.0",
"react-native-mmkv": "4.1.1", "react-native-mmkv": "4.1.1",
"react-native-nitro-modules": "0.33.1", "react-native-nitro-modules": "0.33.1",
"react-native-pager-view": "8.0.1", "react-native-pager-view": "8.0.0",
"react-native-qrcode-svg": "^6.3.21", "react-native-qrcode-svg": "^6.3.21",
"react-native-reanimated": "4.3.1", "react-native-reanimated": "4.2.1",
"react-native-reanimated-carousel": "4.0.3", "react-native-reanimated-carousel": "4.0.3",
"react-native-safe-area-context": "~5.7.0", "react-native-safe-area-context": "~5.6.0",
"react-native-screens": "4.25.2", "react-native-screens": "~4.18.0",
"react-native-svg": "15.15.4", "react-native-svg": "15.15.3",
"react-native-text-ticker": "^1.15.0", "react-native-text-ticker": "^1.15.0",
"react-native-track-player": "github:lovegaoshi/react-native-track-player#APM", "react-native-track-player": "github:lovegaoshi/react-native-track-player#APM",
"react-native-udp": "^4.1.7", "react-native-udp": "^4.1.7",
@@ -111,19 +113,19 @@
"react-native-uuid": "^2.0.3", "react-native-uuid": "^2.0.3",
"react-native-volume-manager": "^2.0.8", "react-native-volume-manager": "^2.0.8",
"react-native-web": "^0.21.0", "react-native-web": "^0.21.0",
"react-native-worklets": "0.8.3", "react-native-worklets": "0.7.4",
"sonner-native": "0.21.2", "sonner-native": "0.21.2",
"tailwindcss": "3.3.2", "tailwindcss": "3.3.2",
"use-debounce": "^10.0.4", "use-debounce": "^10.0.4",
"zod": "4.4.3" "zod": "4.1.13"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "7.29.7", "@babel/core": "7.28.6",
"@biomejs/biome": "2.4.16", "@biomejs/biome": "2.3.11",
"@react-native-community/cli": "20.1.3", "@react-native-community/cli": "20.1.3",
"@react-native-tvos/config-tv": "0.1.6", "@react-native-tvos/config-tv": "0.1.6",
"@types/jest": "29.5.14", "@types/jest": "29.5.14",
"@types/lodash": "4.17.24", "@types/lodash": "4.17.23",
"@types/react": "~19.2.10", "@types/react": "~19.2.10",
"@types/react-test-renderer": "19.1.0", "@types/react-test-renderer": "19.1.0",
"cross-env": "10.1.0", "cross-env": "10.1.0",
@@ -146,7 +148,6 @@
}, },
"install": { "install": {
"exclude": [ "exclude": [
"react-native",
"react-native-screens" "react-native-screens"
] ]
} }
@@ -164,8 +165,9 @@
"unrs-resolver" "unrs-resolver"
], ],
"patchedDependencies": { "patchedDependencies": {
"react-native-screens@4.18.0": "bun-patches/react-native-screens@4.18.0.patch",
"react-native-udp@4.1.7": "bun-patches/react-native-udp@4.1.7.patch", "react-native-udp@4.1.7": "bun-patches/react-native-udp@4.1.7.patch",
"react-native-bottom-tabs@1.2.0": "bun-patches/react-native-bottom-tabs@1.2.0.patch", "@react-native/codegen@0.83.6": "bun-patches/@react-native%2Fcodegen@0.83.6.patch",
"react-native-ios-utilities@5.2.0": "bun-patches/react-native-ios-utilities@5.2.0.patch" "react-native-bottom-tabs@1.2.0": "bun-patches/react-native-bottom-tabs@1.2.0.patch"
} }
} }

View File

@@ -25,17 +25,6 @@ function buildPatch() {
" cfg.build_settings['HEADER_SEARCH_PATHS'] ||= '$(inherited)'", " cfg.build_settings['HEADER_SEARCH_PATHS'] ||= '$(inherited)'",
" cfg.build_settings['HEADER_SEARCH_PATHS'] << \" #{extra_hdrs.join(' ')}\"", " cfg.build_settings['HEADER_SEARCH_PATHS'] << \" #{extra_hdrs.join(' ')}\"",
" cfg.build_settings['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES'", " cfg.build_settings['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES'",
" # iOS 26 / Xcode 26: SwiftUI was split into SwiftUI + SwiftUICore. The SwiftUI",
" # pods (ExpoUI, glass-effect, glass-poster, …) emit a `-framework SwiftUICore`",
" # autolink directive that, under use_frameworks :static, flows into the app",
" # executable's link. The app isn't an allowed client of the private",
" # SwiftUICore.tbd → `cannot link directly with 'SwiftUICore'`. Dropping that one",
" # autolink at the Swift frontend lets the symbols resolve via SwiftUI's",
" # re-export instead. Phone-only — tvOS links fine and must stay untouched.",
" if ENV['EXPO_TV'] != '1'",
" cfg.build_settings['OTHER_SWIFT_FLAGS'] ||= '$(inherited)'",
" cfg.build_settings['OTHER_SWIFT_FLAGS'] << ' -Xfrontend -disable-autolink-framework -Xfrontend SwiftUICore'",
" end",
" end", " end",
" end", " end",
"", "",

View File

@@ -15,7 +15,7 @@ function getBundleIdentifier(config) {
} }
function getAppGroupIdentifier(config) { function getAppGroupIdentifier(config) {
return `group.${getBundleIdentifier(config)}.tvtopshelf`; return `group.${getBundleIdentifier(config)}`;
} }
function getKeychainAccessGroupIdentifier(config) { function getKeychainAccessGroupIdentifier(config) {
@@ -83,7 +83,7 @@ const withTVOSTopShelf = (config) => {
const keychainAccessGroupIdentifier = const keychainAccessGroupIdentifier =
getKeychainAccessGroupIdentifier(config); getKeychainAccessGroupIdentifier(config);
const bundleIdentifier = getBundleIdentifier(config); const bundleIdentifier = getBundleIdentifier(config);
const extensionBundleIdentifier = `${bundleIdentifier}.tvtopshelf`; const extensionBundleIdentifier = `${bundleIdentifier}.TopShelf`;
const isTVBuild = process.env.EXPO_TV === "1"; const isTVBuild = process.env.EXPO_TV === "1";
if (isTVBuild) { if (isTVBuild) {

View File

@@ -12,22 +12,9 @@ import {
} from "react"; } from "react";
import { AppState, type AppStateStatus } from "react-native"; import { AppState, type AppStateStatus } from "react-native";
import useRouter from "@/hooks/useAppRouter"; import useRouter from "@/hooks/useAppRouter";
import { useNetworkAwareQueryClient } from "@/hooks/useNetworkAwareQueryClient";
import { apiAtom, getOrSetDeviceId } from "@/providers/JellyfinProvider"; import { apiAtom, getOrSetDeviceId } from "@/providers/JellyfinProvider";
import { useNetworkStatus } from "@/providers/NetworkStatusProvider"; import { useNetworkStatus } from "@/providers/NetworkStatusProvider";
// Query keys that depend on the set of library items and should be refreshed
// when the server reports that the library changed (items added/removed/updated).
const LIBRARY_CHANGE_QUERY_KEYS = [
["home"],
["library-items"],
["nextUp-all"],
["nextUp"],
["resumeItems"],
["seasons"],
["episodes"],
] as const;
interface WebSocketMessage { interface WebSocketMessage {
MessageType: string; MessageType: string;
Data: any; Data: any;
@@ -55,14 +42,10 @@ export const WebSocketProvider = ({ children }: WebSocketProviderProps) => {
const [isConnected, setIsConnected] = useState(false); const [isConnected, setIsConnected] = useState(false);
const [lastMessage, setLastMessage] = useState<WebSocketMessage | null>(null); const [lastMessage, setLastMessage] = useState<WebSocketMessage | null>(null);
const router = useRouter(); const router = useRouter();
const queryClient = useNetworkAwareQueryClient();
const deviceId = useMemo(() => { const deviceId = useMemo(() => {
return getOrSetDeviceId(); return getOrSetDeviceId();
}, []); }, []);
const reconnectAttemptsRef = useRef(0); const reconnectAttemptsRef = useRef(0);
const libraryChangeDebounceRef = useRef<ReturnType<typeof setTimeout> | null>(
null,
);
const connectWebSocket = useCallback(() => { const connectWebSocket = useCallback(() => {
if (!deviceId || !api?.accessToken || !isNetworkConnected) { if (!deviceId || !api?.accessToken || !isNetworkConnected) {
@@ -128,57 +111,18 @@ export const WebSocketProvider = ({ children }: WebSocketProviderProps) => {
}; };
}, [api, deviceId, isNetworkConnected]); }, [api, deviceId, isNetworkConnected]);
const handleLibraryChanged = useCallback(
(data: any) => {
// Jellyfin sends LibraryChanged when a scan adds/updates/removes items.
// Only refresh when something actually changed in the item set.
const hasChanges =
(data?.ItemsAdded?.length ?? 0) > 0 ||
(data?.ItemsRemoved?.length ?? 0) > 0 ||
(data?.ItemsUpdated?.length ?? 0) > 0 ||
(data?.FoldersAddedTo?.length ?? 0) > 0 ||
(data?.FoldersRemovedFrom?.length ?? 0) > 0;
if (!hasChanges) {
return;
}
// A single scan can emit several LibraryChanged messages in quick
// succession, so debounce the invalidation to refetch only once.
if (libraryChangeDebounceRef.current) {
clearTimeout(libraryChangeDebounceRef.current);
}
libraryChangeDebounceRef.current = setTimeout(() => {
for (const queryKey of LIBRARY_CHANGE_QUERY_KEYS) {
queryClient.invalidateQueries({ queryKey: [...queryKey] });
}
}, 1000);
},
[queryClient],
);
useEffect(() => { useEffect(() => {
if (!lastMessage) { if (!lastMessage) {
return; return;
} }
if (lastMessage.MessageType === "Play") { if (lastMessage.MessageType === "Play") {
handlePlayCommand(lastMessage.Data); handlePlayCommand(lastMessage.Data);
} else if (lastMessage.MessageType === "LibraryChanged") {
handleLibraryChanged(lastMessage.Data);
} }
}, [lastMessage, router, handleLibraryChanged]); }, [lastMessage, router]);
useEffect(() => {
return () => {
if (libraryChangeDebounceRef.current) {
clearTimeout(libraryChangeDebounceRef.current);
}
};
}, []);
const handlePlayCommand = useCallback( const handlePlayCommand = useCallback(
(data: any) => { (data: any) => {
if (!data?.ItemIds?.length) { if (!data || !data.ItemIds || !data.ItemIds.length) {
return; return;
} }
@@ -206,7 +150,7 @@ export const WebSocketProvider = ({ children }: WebSocketProviderProps) => {
}, [connectWebSocket]); }, [connectWebSocket]);
useEffect(() => { useEffect(() => {
if (!deviceId || !api?.accessToken || !isNetworkConnected) { if (!deviceId || !api || !api?.accessToken || !isNetworkConnected) {
return; return;
} }

View File

@@ -525,23 +525,10 @@ function displayBuildError(
console.error(line); console.error(line);
} }
console.error("--- End Build Errors ---\n"); console.error("--- End Build Errors ---\n");
} } else if (stdout.trim()) {
// Linker failures ("Undefined symbols for architecture …", the SwiftUICore
// autolink rejection, "ld: …") don't carry an "error:" token, so the pattern
// filter above drops the symbol name and "referenced from" context that
// actually pinpoints the culprit. Surface that block explicitly.
const stdoutLines = stdout.split("\n");
const undefIdx = stdoutLines.findIndex((line: string) =>
line.includes("Undefined symbols"),
);
if (undefIdx >= 0) {
console.error("\n--- Linker error detail ---");
console.error(stdoutLines.slice(undefIdx, undefIdx + 40).join("\n"));
console.error("--- End linker error detail ---\n");
} else if (errorLines.length === 0 && stdout.trim()) {
// No specific error patterns found, show last N lines of stdout // No specific error patterns found, show last N lines of stdout
const lastLines = stdoutLines.slice(-ERROR_OUTPUT_TAIL_LINES).join("\n"); const lines = stdout.split("\n");
const lastLines = lines.slice(-ERROR_OUTPUT_TAIL_LINES).join("\n");
console.error( console.error(
`\n--- Last ${ERROR_OUTPUT_TAIL_LINES} lines of build output ---`, `\n--- Last ${ERROR_OUTPUT_TAIL_LINES} lines of build output ---`,
); );

View File

@@ -720,12 +720,6 @@
"stopPlayingConfirm": "Are you sure you want to stop playback?", "stopPlayingConfirm": "Are you sure you want to stop playback?",
"downloaded": "Downloaded" "downloaded": "Downloaded"
}, },
"chapters": {
"title": "Chapters",
"chapter_number": "Chapter {{number}}",
"open": "Open chapters",
"close": "Close chapters"
},
"item_card": { "item_card": {
"next_up": "Next Up", "next_up": "Next Up",
"no_items_to_display": "No Items to Display", "no_items_to_display": "No Items to Display",

Some files were not shown because too many files have changed in this diff Show More