diff --git a/app.json b/app.json index 81babb2..22f35a1 100644 --- a/app.json +++ b/app.json @@ -38,6 +38,7 @@ "android": { "package": "com.oriontv", "usesCleartextTraffic": true, + "hardwareAcceleration": true, "networkSecurityConfig": "@xml/network_security_config", "icon": "./assets/images/icon.png", "permissions": [ diff --git a/app/live.tsx b/app/live.tsx index f7a51fc..06193e1 100644 --- a/app/live.tsx +++ b/app/live.tsx @@ -106,7 +106,7 @@ export default function LiveScreen() { item} + keyExtractor={(item, index) => `group-${item}-${index}`} renderItem={({ item }) => ( item.id} + keyExtractor={(item, index) => `${item.id}-${item.group}-${index}`} renderItem={({ item }) => ( )} - setShowNextEpisodeOverlay(false)} /> + {/* setShowNextEpisodeOverlay(false)} /> */} diff --git a/components/LivePlayer.tsx b/components/LivePlayer.tsx index 11fb390..b167cb5 100644 --- a/components/LivePlayer.tsx +++ b/components/LivePlayer.tsx @@ -66,7 +66,7 @@ export default function LivePlayer({ streamUrl, channelTitle, onPlaybackStatusUp if (!streamUrl) { return ( - Select a channel to play. + 按向下键选择频道 ); } @@ -74,7 +74,7 @@ export default function LivePlayer({ streamUrl, channelTitle, onPlaybackStatusUp if (isTimeout) { return ( - Failed to load stream. It might be offline or unavailable. + 加载失败,请重试 ); } @@ -98,7 +98,7 @@ export default function LivePlayer({ streamUrl, channelTitle, onPlaybackStatusUp {isLoading && ( - Loading... + 加载中... )} {channelTitle && !isLoading && !isTimeout && ( diff --git a/package.json b/package.json index a57ded4..b7346c7 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "OrionTV", "private": true, "main": "expo-router/entry", - "version": "1.2.5", + "version": "1.2.6", "scripts": { "start": "EXPO_USE_METRO_WORKSPACE_ROOT=1 expo start", "start-tv": "EXPO_TV=1 EXPO_USE_METRO_WORKSPACE_ROOT=1 expo start", diff --git a/services/m3u.ts b/services/m3u.ts index 8b20ffc..57dc202 100644 --- a/services/m3u.ts +++ b/services/m3u.ts @@ -15,23 +15,38 @@ export const parseM3U = (m3uText: string): Channel[] => { for (const line of lines) { const trimmedLine = line.trim(); - currentChannelInfo = { id: '', name: '', url: '', logo: '', group: '' }; if (trimmedLine.startsWith('#EXTINF:')) { - const commaIndex = trimmedLine.indexOf(','); + currentChannelInfo = {}; // Start a new channel + const commaIndex = trimmedLine.lastIndexOf(','); if (commaIndex !== -1) { currentChannelInfo.name = trimmedLine.substring(commaIndex + 1).trim(); const attributesPart = trimmedLine.substring(8, commaIndex); const logoMatch = attributesPart.match(/tvg-logo="([^"]*)"/i); - if (logoMatch && logoMatch[1]) currentChannelInfo.logo = logoMatch[1]; + if (logoMatch && logoMatch[1]) { + currentChannelInfo.logo = logoMatch[1]; + } const groupMatch = attributesPart.match(/group-title="([^"]*)"/i); - if (groupMatch && groupMatch[1]) currentChannelInfo.group = groupMatch[1]; + if (groupMatch && groupMatch[1]) { + currentChannelInfo.group = groupMatch[1]; + } } else { currentChannelInfo.name = trimmedLine.substring(8).trim(); } } else if (currentChannelInfo && trimmedLine && !trimmedLine.startsWith('#') && trimmedLine.includes('://')) { currentChannelInfo.url = trimmedLine; currentChannelInfo.id = currentChannelInfo.url; // Use URL as ID - parsedChannels.push(currentChannelInfo as Channel); + + // Ensure all required fields are present, providing defaults if necessary + const finalChannel: Channel = { + id: currentChannelInfo.id, + url: currentChannelInfo.url, + name: currentChannelInfo.name || 'Unknown', + logo: currentChannelInfo.logo || '', + group: currentChannelInfo.group || 'Default', + }; + + parsedChannels.push(finalChannel); + currentChannelInfo = null; // Reset for the next channel } } return parsedChannels; @@ -56,14 +71,14 @@ export const getPlayableUrl = (originalUrl: string | null): string | null => { return null; } // In React Native, we use the proxy for all http streams to avoid potential issues. - if (originalUrl.toLowerCase().startsWith('http://')) { - // Use the baseURL from the existing api instance. - if (!api.baseURL) { - console.warn("API base URL is not set. Cannot create proxy URL.") - return originalUrl; // Fallback to original URL - } - return `${api.baseURL}/proxy?url=${encodeURIComponent(originalUrl)}`; - } + // if (originalUrl.toLowerCase().startsWith('http://')) { + // // Use the baseURL from the existing api instance. + // if (!api.baseURL) { + // console.warn("API base URL is not set. Cannot create proxy URL.") + // return originalUrl; // Fallback to original URL + // } + // return `${api.baseURL}/proxy?url=${encodeURIComponent(originalUrl)}`; + // } // HTTPS streams can be played directly. return originalUrl; };