mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-01-11 20:10:25 +00:00
Custom TTL for Stream cache
This commit is contained in:
parent
f0271cd395
commit
ce7f92b540
7 changed files with 321 additions and 146 deletions
|
|
@ -461,7 +461,7 @@
|
|||
);
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_DEBUG";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.nuvio.app;
|
||||
PRODUCT_NAME = Nuvio;
|
||||
PRODUCT_NAME = "Nuvio";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Nuvio/Nuvio-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
|
|
@ -492,8 +492,8 @@
|
|||
"-lc++",
|
||||
);
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_RELEASE";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.nuviohub.app;
|
||||
PRODUCT_NAME = Nuvio;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.nuvio.app";
|
||||
PRODUCT_NAME = "Nuvio";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Nuvio/Nuvio-Bridging-Header.h";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
|
|
|
|||
|
|
@ -1,99 +1,101 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||
<true/>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Nuvio</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.2.6</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>nuvio</string>
|
||||
<string>com.nuvio.app</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>exp+nuvio</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>21</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>12.0</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>LSSupportsOpeningDocumentsInPlace</key>
|
||||
<true/>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>NSBonjourServices</key>
|
||||
<array>
|
||||
<string>_http._tcp</string>
|
||||
</array>
|
||||
<key>NSLocalNetworkUsageDescription</key>
|
||||
<string>Allow $(PRODUCT_NAME) to access your local network</string>
|
||||
<key>RCTNewArchEnabled</key>
|
||||
<true/>
|
||||
<key>RCTRootViewBackgroundColor</key>
|
||||
<integer>4278322180</integer>
|
||||
<key>UIBackgroundModes</key>
|
||||
<array>
|
||||
<string>audio</string>
|
||||
</array>
|
||||
<key>UIFileSharingEnabled</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>SplashScreen</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
</array>
|
||||
<key>UIRequiresFullScreen</key>
|
||||
<false/>
|
||||
<key>UIStatusBarStyle</key>
|
||||
<string>UIStatusBarStyleDefault</string>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UIUserInterfaceStyle</key>
|
||||
<string>Dark</string>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
<dict>
|
||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||
<true/>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Nuvio</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.2.6</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>nuvio</string>
|
||||
<string>com.nuvio.app</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>exp+nuvio</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>21</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>12.0</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>LSSupportsOpeningDocumentsInPlace</key>
|
||||
<true/>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>NSBonjourServices</key>
|
||||
<array>
|
||||
<string>_http._tcp</string>
|
||||
</array>
|
||||
<key>NSLocalNetworkUsageDescription</key>
|
||||
<string>Allow $(PRODUCT_NAME) to access your local network</string>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
<string>This app does not require microphone access.</string>
|
||||
<key>RCTNewArchEnabled</key>
|
||||
<true/>
|
||||
<key>RCTRootViewBackgroundColor</key>
|
||||
<integer>4278322180</integer>
|
||||
<key>UIBackgroundModes</key>
|
||||
<array>
|
||||
<string>audio</string>
|
||||
</array>
|
||||
<key>UIFileSharingEnabled</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>SplashScreen</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
</array>
|
||||
<key>UIRequiresFullScreen</key>
|
||||
<false/>
|
||||
<key>UIStatusBarStyle</key>
|
||||
<string>UIStatusBarStyleDefault</string>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UIUserInterfaceStyle</key>
|
||||
<string>Dark</string>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
@ -1,5 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict/>
|
||||
</plist>
|
||||
<dict>
|
||||
<key>aps-environment</key>
|
||||
<string>development</string>
|
||||
<key>com.apple.developer.associated-domains</key>
|
||||
<array/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
@ -85,6 +85,7 @@ export interface AppSettings {
|
|||
// Continue Watching behavior
|
||||
useCachedStreams: boolean; // Enable/disable direct player navigation from Continue Watching cache
|
||||
openMetadataScreenWhenCacheDisabled: boolean; // When cache disabled, open MetadataScreen instead of StreamsScreen
|
||||
streamCacheTTL: number; // Stream cache duration in milliseconds (default: 1 hour)
|
||||
}
|
||||
|
||||
export const DEFAULT_SETTINGS: AppSettings = {
|
||||
|
|
@ -143,6 +144,7 @@ export const DEFAULT_SETTINGS: AppSettings = {
|
|||
// Continue Watching behavior
|
||||
useCachedStreams: false, // Enable by default
|
||||
openMetadataScreenWhenCacheDisabled: true, // Default to StreamsScreen when cache disabled
|
||||
streamCacheTTL: 60 * 60 * 1000, // Default: 1 hour in milliseconds
|
||||
};
|
||||
|
||||
const SETTINGS_STORAGE_KEY = 'app_settings';
|
||||
|
|
|
|||
|
|
@ -18,11 +18,29 @@ import { useTheme } from '../contexts/ThemeContext';
|
|||
import { useSettings } from '../hooks/useSettings';
|
||||
import { RootStackParamList } from '../navigation/AppNavigator';
|
||||
|
||||
// TTL options in milliseconds - organized in rows
|
||||
const TTL_OPTIONS = [
|
||||
[
|
||||
{ label: '15 min', value: 15 * 60 * 1000 },
|
||||
{ label: '30 min', value: 30 * 60 * 1000 },
|
||||
{ label: '1 hour', value: 60 * 60 * 1000 },
|
||||
],
|
||||
[
|
||||
{ label: '2 hours', value: 2 * 60 * 60 * 1000 },
|
||||
{ label: '6 hours', value: 6 * 60 * 60 * 1000 },
|
||||
{ label: '12 hours', value: 12 * 60 * 60 * 1000 },
|
||||
],
|
||||
[
|
||||
{ label: '24 hours', value: 24 * 60 * 60 * 1000 },
|
||||
],
|
||||
];
|
||||
|
||||
const ContinueWatchingSettingsScreen: React.FC = () => {
|
||||
const navigation = useNavigation<NavigationProp<RootStackParamList>>();
|
||||
const { settings, updateSetting } = useSettings();
|
||||
const { currentTheme } = useTheme();
|
||||
const colors = currentTheme.colors;
|
||||
const styles = createStyles(colors);
|
||||
const [showSavedIndicator, setShowSavedIndicator] = useState(false);
|
||||
const fadeAnim = React.useRef(new Animated.Value(0)).current;
|
||||
|
||||
|
|
@ -96,7 +114,6 @@ const ContinueWatchingSettingsScreen: React.FC = () => {
|
|||
styles.settingItem,
|
||||
{
|
||||
borderBottomColor: isLast ? 'transparent' : colors.border,
|
||||
backgroundColor: colors.elevation1
|
||||
}
|
||||
]}>
|
||||
<View style={styles.settingContent}>
|
||||
|
|
@ -111,31 +128,52 @@ const ContinueWatchingSettingsScreen: React.FC = () => {
|
|||
</View>
|
||||
);
|
||||
|
||||
const SectionHeader = ({ title }: { title: string }) => (
|
||||
<View style={[styles.sectionHeader, { backgroundColor: colors.darkBackground }]}>
|
||||
<Text style={[styles.sectionTitle, { color: colors.highEmphasis }]}>
|
||||
{title}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
|
||||
const TTLPickerItem = ({ option }: { option: { label: string; value: number } }) => {
|
||||
const isSelected = settings.streamCacheTTL === option.value;
|
||||
return (
|
||||
<TouchableOpacity
|
||||
style={[
|
||||
styles.ttlOption,
|
||||
{
|
||||
backgroundColor: isSelected ? colors.primary : colors.elevation1,
|
||||
borderColor: isSelected ? colors.primary : colors.border,
|
||||
}
|
||||
]}
|
||||
onPress={() => handleUpdateSetting('streamCacheTTL', option.value)}
|
||||
activeOpacity={0.7}
|
||||
>
|
||||
<Text style={[
|
||||
styles.ttlOptionText,
|
||||
{ color: isSelected ? colors.white : colors.highEmphasis }
|
||||
]}>
|
||||
{option.label}
|
||||
</Text>
|
||||
{isSelected && (
|
||||
<MaterialIcons name="check" size={20} color={colors.white} />
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<SafeAreaView style={[styles.container, { backgroundColor: colors.darkBackground }]}>
|
||||
<StatusBar barStyle="light-content" />
|
||||
|
||||
{/* Header */}
|
||||
<View style={[styles.header, { backgroundColor: colors.darkBackground }]}>
|
||||
<TouchableOpacity
|
||||
<View style={styles.header}>
|
||||
<TouchableOpacity
|
||||
style={styles.backButton}
|
||||
onPress={handleBack}
|
||||
>
|
||||
<MaterialIcons name="chevron-left" size={28} color={colors.primary} />
|
||||
<Text style={[styles.backText, { color: colors.primary }]}>Settings</Text>
|
||||
<MaterialIcons name="chevron-left" size={28} color={colors.white} />
|
||||
<Text style={styles.backText}>Settings</Text>
|
||||
</TouchableOpacity>
|
||||
<Text style={[styles.headerTitle, { color: colors.highEmphasis }]}>
|
||||
Continue Watching
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<Text style={styles.headerTitle}>
|
||||
Continue Watching
|
||||
</Text>
|
||||
|
||||
{/* Content */}
|
||||
<ScrollView
|
||||
|
|
@ -143,9 +181,9 @@ const ContinueWatchingSettingsScreen: React.FC = () => {
|
|||
showsVerticalScrollIndicator={false}
|
||||
contentContainerStyle={styles.contentContainer}
|
||||
>
|
||||
<SectionHeader title="PLAYBACK BEHAVIOR" />
|
||||
|
||||
<View style={[styles.settingsCard, { backgroundColor: colors.elevation1 }]}>
|
||||
<View style={styles.section}>
|
||||
<Text style={styles.sectionTitle}>PLAYBACK BEHAVIOR</Text>
|
||||
<View style={styles.settingsCard}>
|
||||
<SettingItem
|
||||
title="Use Cached Streams"
|
||||
description="When enabled, clicking Continue Watching items will open the player directly using previously played streams. When disabled, opens a content screen instead."
|
||||
|
|
@ -162,9 +200,52 @@ const ContinueWatchingSettingsScreen: React.FC = () => {
|
|||
isLast={true}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View style={[styles.infoCard, { backgroundColor: colors.elevation1 }]}>
|
||||
{settings.useCachedStreams && (
|
||||
<View style={styles.section}>
|
||||
<Text style={styles.sectionTitle}>CACHE SETTINGS</Text>
|
||||
<View style={styles.settingsCard}>
|
||||
<View style={[styles.settingItem, { borderBottomWidth: 0, flexDirection: 'column', alignItems: 'flex-start' }]}>
|
||||
<Text style={[styles.settingTitle, { color: colors.highEmphasis, marginBottom: 8 }]}>
|
||||
Stream Cache Duration
|
||||
</Text>
|
||||
<Text style={[styles.settingDescription, { color: colors.mediumEmphasis, marginBottom: 16 }]}>
|
||||
How long to keep cached stream links before they expire
|
||||
</Text>
|
||||
<View style={styles.ttlOptionsContainer}>
|
||||
{TTL_OPTIONS.map((row, rowIndex) => (
|
||||
<View key={rowIndex} style={styles.ttlRow}>
|
||||
{row.map((option) => (
|
||||
<TTLPickerItem key={option.value} option={option} />
|
||||
))}
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{settings.useCachedStreams && (
|
||||
<View style={styles.section}>
|
||||
<View style={[styles.warningCard, { borderColor: colors.warning }]}>
|
||||
<View style={styles.warningHeader}>
|
||||
<MaterialIcons name="warning" size={20} color={colors.warning} />
|
||||
<Text style={[styles.warningTitle, { color: colors.warning }]}>
|
||||
Important Note
|
||||
</Text>
|
||||
</View>
|
||||
<Text style={[styles.warningText, { color: colors.mediumEmphasis }]}>
|
||||
Not all stream links may remain active for the full cache duration. Longer cache times may result in expired links. If a cached link fails, the app will fall back to fetching fresh streams.
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
|
||||
<View style={styles.section}>
|
||||
<View style={styles.infoCard}>
|
||||
<View style={styles.infoHeader}>
|
||||
<MaterialIcons name="info" size={20} color={colors.primary} />
|
||||
<Text style={[styles.infoTitle, { color: colors.highEmphasis }]}>
|
||||
|
|
@ -172,12 +253,24 @@ const ContinueWatchingSettingsScreen: React.FC = () => {
|
|||
</Text>
|
||||
</View>
|
||||
<Text style={[styles.infoText, { color: colors.mediumEmphasis }]}>
|
||||
• Streams are cached for 1 hour after playing{'\n'}
|
||||
• Cached streams are validated before use{'\n'}
|
||||
• If cache is invalid or expired, falls back to content screen{'\n'}
|
||||
• "Use Cached Streams" controls direct player vs screen navigation{'\n'}
|
||||
• "Open Metadata Screen" appears only when cached streams are disabled
|
||||
{settings.useCachedStreams ? (
|
||||
<>
|
||||
• Streams are cached for your selected duration after playing{'\n'}
|
||||
• Cached streams are validated before use{'\n'}
|
||||
• If cache is invalid or expired, falls back to content screen{'\n'}
|
||||
• "Use Cached Streams" controls direct player vs screen navigation{'\n'}
|
||||
• "Open Metadata Screen" appears only when cached streams are disabled
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
• When cached streams are disabled, clicking Continue Watching items opens content screens{'\n'}
|
||||
• "Open Metadata Screen" option controls which screen to open{'\n'}
|
||||
• Metadata screen shows content details and allows manual stream selection{'\n'}
|
||||
• Streams screen shows available streams for immediate playback
|
||||
</>
|
||||
)}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
|
||||
|
|
@ -198,31 +291,35 @@ const ContinueWatchingSettingsScreen: React.FC = () => {
|
|||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
// Create a styles creator function that accepts the theme colors
|
||||
const createStyles = (colors: any) => StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
},
|
||||
header: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
paddingHorizontal: 16,
|
||||
paddingVertical: 12,
|
||||
paddingTop: Platform.OS === 'ios' ? 0 : 12,
|
||||
paddingTop: Platform.OS === 'android' ? (StatusBar.currentHeight || 0) + 8 : 8,
|
||||
},
|
||||
backButton: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
marginRight: 16,
|
||||
padding: 8,
|
||||
},
|
||||
backText: {
|
||||
fontSize: 16,
|
||||
fontWeight: '600',
|
||||
marginLeft: 4,
|
||||
fontSize: 17,
|
||||
fontWeight: '400',
|
||||
color: colors.primary,
|
||||
},
|
||||
headerTitle: {
|
||||
fontSize: 20,
|
||||
fontSize: 34,
|
||||
fontWeight: '700',
|
||||
flex: 1,
|
||||
color: colors.white,
|
||||
paddingHorizontal: 16,
|
||||
paddingBottom: 16,
|
||||
paddingTop: 8,
|
||||
},
|
||||
content: {
|
||||
flex: 1,
|
||||
|
|
@ -230,26 +327,33 @@ const styles = StyleSheet.create({
|
|||
contentContainer: {
|
||||
paddingBottom: 100,
|
||||
},
|
||||
sectionHeader: {
|
||||
paddingHorizontal: 16,
|
||||
paddingVertical: 12,
|
||||
paddingTop: 24,
|
||||
section: {
|
||||
marginBottom: 24,
|
||||
},
|
||||
sectionTitle: {
|
||||
fontSize: 13,
|
||||
fontWeight: '700',
|
||||
fontWeight: '600',
|
||||
color: colors.mediumGray,
|
||||
marginHorizontal: 16,
|
||||
marginBottom: 8,
|
||||
letterSpacing: 0.5,
|
||||
textTransform: 'uppercase',
|
||||
},
|
||||
settingsCard: {
|
||||
marginHorizontal: 16,
|
||||
backgroundColor: colors.elevation2,
|
||||
borderRadius: 12,
|
||||
padding: 16,
|
||||
shadowColor: '#000',
|
||||
shadowOffset: { width: 0, height: 2 },
|
||||
shadowOpacity: 0.1,
|
||||
shadowRadius: 4,
|
||||
elevation: 2,
|
||||
overflow: 'hidden',
|
||||
},
|
||||
settingItem: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
paddingHorizontal: 16,
|
||||
paddingVertical: 16,
|
||||
borderBottomWidth: 1,
|
||||
},
|
||||
|
|
@ -269,8 +373,14 @@ const styles = StyleSheet.create({
|
|||
infoCard: {
|
||||
marginHorizontal: 16,
|
||||
marginTop: 16,
|
||||
padding: 16,
|
||||
backgroundColor: colors.elevation2,
|
||||
borderRadius: 12,
|
||||
padding: 16,
|
||||
shadowColor: '#000',
|
||||
shadowOffset: { width: 0, height: 2 },
|
||||
shadowOpacity: 0.1,
|
||||
shadowRadius: 4,
|
||||
elevation: 2,
|
||||
},
|
||||
infoHeader: {
|
||||
flexDirection: 'row',
|
||||
|
|
@ -304,6 +414,58 @@ const styles = StyleSheet.create({
|
|||
fontWeight: '600',
|
||||
marginLeft: 8,
|
||||
},
|
||||
ttlOptionsContainer: {
|
||||
width: '100%',
|
||||
gap: 8,
|
||||
},
|
||||
ttlRow: {
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'space-between',
|
||||
width: '100%',
|
||||
gap: 8,
|
||||
},
|
||||
ttlOption: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
paddingHorizontal: 12,
|
||||
paddingVertical: 10,
|
||||
borderRadius: 8,
|
||||
borderWidth: 1,
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
gap: 6,
|
||||
},
|
||||
ttlOptionText: {
|
||||
fontSize: 14,
|
||||
fontWeight: '600',
|
||||
},
|
||||
warningCard: {
|
||||
marginHorizontal: 16,
|
||||
marginTop: 16,
|
||||
backgroundColor: colors.elevation2,
|
||||
borderRadius: 12,
|
||||
padding: 16,
|
||||
borderWidth: 1,
|
||||
shadowColor: '#000',
|
||||
shadowOffset: { width: 0, height: 2 },
|
||||
shadowOpacity: 0.1,
|
||||
shadowRadius: 4,
|
||||
elevation: 2,
|
||||
},
|
||||
warningHeader: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
marginBottom: 12,
|
||||
},
|
||||
warningTitle: {
|
||||
fontSize: 16,
|
||||
fontWeight: '600',
|
||||
marginLeft: 8,
|
||||
},
|
||||
warningText: {
|
||||
fontSize: 14,
|
||||
lineHeight: 20,
|
||||
},
|
||||
});
|
||||
|
||||
export default ContinueWatchingSettingsScreen;
|
||||
|
|
|
|||
|
|
@ -1159,7 +1159,8 @@ export const StreamsScreen = () => {
|
|||
season,
|
||||
episode,
|
||||
episodeTitle,
|
||||
imdbId || undefined
|
||||
imdbId || undefined,
|
||||
settings.streamCacheTTL
|
||||
);
|
||||
} catch (error) {
|
||||
logger.warn('[StreamsScreen] Failed to save stream to cache:', error);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export interface StreamCacheEntry {
|
|||
expiresAt: number; // Timestamp when cache expires
|
||||
}
|
||||
|
||||
const CACHE_DURATION = 60 * 60 * 1000; // 1 hour in milliseconds
|
||||
const DEFAULT_CACHE_DURATION = 60 * 60 * 1000; // 1 hour in milliseconds (fallback)
|
||||
const CACHE_KEY_PREFIX = 'stream_cache_';
|
||||
|
||||
class StreamCacheService {
|
||||
|
|
@ -34,7 +34,8 @@ class StreamCacheService {
|
|||
season?: number,
|
||||
episode?: number,
|
||||
episodeTitle?: string,
|
||||
imdbId?: string
|
||||
imdbId?: string,
|
||||
cacheDuration?: number
|
||||
): Promise<void> {
|
||||
try {
|
||||
const cacheKey = this.getCacheKey(id, type, episodeId);
|
||||
|
|
@ -52,16 +53,18 @@ class StreamCacheService {
|
|||
url: stream.url
|
||||
};
|
||||
|
||||
const ttl = cacheDuration || DEFAULT_CACHE_DURATION;
|
||||
const cacheEntry: StreamCacheEntry = {
|
||||
cachedStream,
|
||||
expiresAt: now + CACHE_DURATION
|
||||
expiresAt: now + ttl
|
||||
};
|
||||
|
||||
await AsyncStorage.setItem(cacheKey, JSON.stringify(cacheEntry));
|
||||
logger.log(`💾 [StreamCache] Saved stream cache for ${type}:${id}${episodeId ? `:${episodeId}` : ''}`);
|
||||
logger.log(`💾 [StreamCache] Cache key: ${cacheKey}`);
|
||||
logger.log(`💾 [StreamCache] Stream URL: ${stream.url}`);
|
||||
logger.log(`💾 [StreamCache] Expires at: ${new Date(now + CACHE_DURATION).toISOString()}`);
|
||||
logger.log(`💾 [StreamCache] TTL: ${ttl / 1000 / 60} minutes`);
|
||||
logger.log(`💾 [StreamCache] Expires at: ${new Date(now + ttl).toISOString()}`);
|
||||
} catch (error) {
|
||||
logger.warn('[StreamCache] Failed to save stream to cache:', error);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue