Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dfb9a3e1b0 | ||
|
|
e14e454c5e | ||
|
|
9360294d22 | ||
|
|
1526766630 | ||
|
|
4e92ee6149 | ||
|
|
cff9658060 | ||
|
|
43439e0a88 | ||
|
|
98473e3b30 | ||
|
|
a4e8deb45a | ||
|
|
a9da5a3b8e | ||
|
|
ab69fd1aa4 | ||
|
|
907c97464b | ||
|
|
19c31ebf1b | ||
|
|
97adc46509 | ||
|
|
ec360cf303 | ||
|
|
3c1a323b35 | ||
|
|
e34323c2da | ||
|
|
dc5f6484b2 | ||
|
|
305e1362a6 | ||
|
|
e9773c1353 |
2
.env
2
.env
@@ -1,4 +1,4 @@
|
||||
GITEA_TOKEN=7921aa22187b39125d29399d26f527ba26a2fb5b
|
||||
GITEA_TOKEN=efeed2af00597883adb04da70bd6a7c2993ae92d
|
||||
GEMINI_API_KEY=AIzaSyDWOgyAJqscuPU6iSpS6gxupWBm4soNw5o
|
||||
TELEGRAM_BOT_TOKEN=8593525164:AAGCX9B_RJGN35_F7tSB72rEZhS_4Zpcszs
|
||||
TELEGRAM_CHAT_ID=692714536
|
||||
|
||||
26
CHANGELOG-v10.1.3.md
Normal file
26
CHANGELOG-v10.1.3.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# StreamPlayer v10.1.3
|
||||
|
||||
## Cambios en esta versión
|
||||
|
||||
### Corrección de Carga de Eventos
|
||||
|
||||
- **Sistema de fallback con múltiples URLs**: Implementado sistema inteligente que intenta múltiples URLs de eventos cuando la principal no está disponible:
|
||||
- `https://streamtpcloud.com/eventos.json` (URL original)
|
||||
- `https://streamtp10.com/eventos.json` (URL actual)
|
||||
- `https://streamtpmedia.com/eventos.json` (URL anterior)
|
||||
|
||||
- **Seguimiento automático de redirecciones HTTP**: El cliente ahora sigue automáticamente las redirecciones HTTP (códigos 301, 302, 303, 307, 308), lo que permite adaptarse a cambios de URL del servidor sin necesidad de actualizar la app.
|
||||
|
||||
- **Memoria de URL exitosa**: La app recuerda cuál fue la última URL que funcionó correctamente y la intenta primero en futuras peticiones, mejorando el rendimiento y la fiabilidad.
|
||||
|
||||
### Detalles Técnicos
|
||||
|
||||
- Modificado `EventRepository.java` para implementar:
|
||||
- Lógica de reintento secuencial con múltiples URLs
|
||||
- Seguimiento manual de redirecciones (hasta 5 consecutivas)
|
||||
- Persistencia de la última URL exitosa en SharedPreferences
|
||||
- Manejo mejorado de errores con mensajes descriptivos
|
||||
|
||||
### Problema Resuelto
|
||||
|
||||
Esta versión corrige el error: *"Unable to resolve host 'streamtpcloud.com': No address associated with hostname"* que ocurría cuando el servidor de eventos cambió su dominio. La app ahora se adapta automáticamente a estos cambios sin intervención del usuario.
|
||||
60
CHANGELOG-v10.1.4.md
Normal file
60
CHANGELOG-v10.1.4.md
Normal file
@@ -0,0 +1,60 @@
|
||||
# StreamPlayer v10.1.4 - Mejoras de Interfaz
|
||||
|
||||
## Correcciones Implementadas
|
||||
|
||||
### 1. Botón de Actualización Más Visible
|
||||
- **Archivo**: `app/src/main/res/drawable/btn_refresh_selector.xml` (nuevo)
|
||||
- **Descripción**: El botón de actualizar eventos ahora cambia a un color ámbar brillante (#FFC107) con borde grueso cuando está enfocado, mejorando significativamente la visibilidad para control remoto.
|
||||
|
||||
### 2. Prevención de Navegación Entre Secciones
|
||||
- **Archivo**: `app/src/main/java/com/streamplayer/MainActivity.java`
|
||||
- **Descripción**: Al hacer scroll después del último evento, la aplicación se detiene en lugar de pasar a la sección de canales, mejorando la experiencia de usuario.
|
||||
|
||||
### 3. Barra de Indicador de Scroll
|
||||
- **Archivos**: `app/src/main/res/layout/activity_main.xml`, `app/src/main/res/drawable/scrollbar_vertical.xml` (nuevo)
|
||||
- **Descripción**: Agregada barra de scroll visual a la derecha de la lista de contenido como indicador de posición (no navegable).
|
||||
|
||||
## Cambios Técnicos
|
||||
|
||||
### Nuevo Archivo: btn_refresh_selector.xml
|
||||
```xml
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_focused="true">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#FFC107" />
|
||||
<corners android:radius="8dp" />
|
||||
<stroke android:width="4dp" android:color="#FFD54F" />
|
||||
</shape>
|
||||
</item>
|
||||
<!-- ... otros estados ... -->
|
||||
</selector>
|
||||
```
|
||||
|
||||
### Modificación: MainActivity.java
|
||||
- Agregado `RecyclerView.OnScrollListener` en `showEvents()` para prevenir scroll más allá del último evento
|
||||
|
||||
### Modificación: activity_main.xml
|
||||
- Botón refresh usa `@drawable/btn_refresh_selector`
|
||||
- RecyclerView ahora tiene `android:scrollbars="vertical"` y `scrollbarThumbVertical`
|
||||
|
||||
### Nuevos Colores: colors.xml
|
||||
- `refresh_button_default`: #2A2A2A
|
||||
- `refresh_button_focused`: #FFC107
|
||||
- `refresh_button_focused_border`: #FFD54F
|
||||
- `refresh_button_pressed`: #FF9800
|
||||
|
||||
## Compatibilidad
|
||||
- Versión mínima de Android: API 21+
|
||||
- Compilado con SDK 34
|
||||
- Probado en Android TV con control remoto
|
||||
|
||||
## Instalación
|
||||
1. Descargar `StreamPlayer-10.1.4-debug.apk`
|
||||
2. Habilitar "Fuentes desconocidas" en configuraciones de seguridad
|
||||
3. Instalar el APK
|
||||
4. Disfrutar las mejoras de interfaz
|
||||
|
||||
## Notas de Desarrollo
|
||||
- La barra de scroll es puramente visual (indicador)
|
||||
- El foco del botón refresh ahora usa color ámbar de alto contraste
|
||||
- El scroll se detiene correctamente al final de la lista de eventos
|
||||
48
CHANGELOG-v10.1.5.md
Normal file
48
CHANGELOG-v10.1.5.md
Normal file
@@ -0,0 +1,48 @@
|
||||
# StreamPlayer v10.1.5 - Correcciones Críticas
|
||||
|
||||
## Correcciones Implementadas
|
||||
|
||||
### 1. Scroll Listener Corregido
|
||||
- **Problema**: El último evento aparecía solo a la mitad y requería bajar/subir muchas veces para verlo completo
|
||||
- **Solución**: Cambiado de `findFirstVisibleItemPosition()` a `findLastCompletelyVisibleItemPosition()`
|
||||
- Ahora el scroll solo se detiene cuando el último elemento está COMPLETAMENTE visible
|
||||
|
||||
### 2. Barra de Scroll Más Visible
|
||||
- **Problema**: La barra indicadora no era visible (30% de opacidad)
|
||||
- **Solución**:
|
||||
- Opacidad aumentada de #4DFFFFFF (30%) a #CCFFFFFF (80%)
|
||||
- Ancho de la barra aumentado a 8dp
|
||||
- Radio de esquinas aumentado a 4dp para mejor apariencia
|
||||
- Estilo cambiado de `outsideOverlay` a `insideInset`
|
||||
- Agregado `scrollbarFadeDuration="0"` para que nunca se desvanezca
|
||||
|
||||
### 3. URLs Actualizadas
|
||||
- **Problema**: Ciertos ISP bloquean las URLs viejas
|
||||
- **Solución**: Eliminado sistema de fallback múltiples URLs
|
||||
- Ahora usa únicamente: `https://streamtp10.com/eventos.json`
|
||||
- Código simplificado, más eficiente y sin bloqueos
|
||||
|
||||
## Archivos Modificados
|
||||
|
||||
### EventRepository.java
|
||||
- Simplificado para usar solo streamtp10.com
|
||||
- Eliminado código de fallback no necesario
|
||||
- Eliminado KEY_WORKING_URL y lógica asociada
|
||||
|
||||
### MainActivity.java
|
||||
- Scroll listener corregido para usar `findLastCompletelyVisibleItemPosition()`
|
||||
|
||||
### scrollbar_vertical.xml
|
||||
- Color cambiado a #CCFFFFFF (80% opacidad)
|
||||
- Ancho definido en 8dp
|
||||
- Radio de esquinas a 4dp
|
||||
|
||||
### activity_main.xml
|
||||
- `scrollbarStyle` cambiado a `insideInset`
|
||||
- `scrollbarSize` definido en 8dp
|
||||
- `scrollbarFadeDuration` en 0 (siempre visible)
|
||||
|
||||
## Compatibilidad
|
||||
- Versión mínima de Android: API 21+
|
||||
- Compilado con SDK 34
|
||||
- Probado en Android TV con control remoto
|
||||
42
CHANGELOG-v10.1.6.md
Normal file
42
CHANGELOG-v10.1.6.md
Normal file
@@ -0,0 +1,42 @@
|
||||
# StreamPlayer v10.1.6 - Corrección de Control Remoto y Scrollbar
|
||||
|
||||
## Correcciones Implementadas
|
||||
|
||||
### 1. Control Remoto - Prevención de Navegación
|
||||
- **Problema**: Al presionar el botón abajo del control remoto en el último evento, se iba a la sección de canales
|
||||
- **Solución**: Agregado `setOnKeyListener` para interceptar teclas de navegación
|
||||
- Ahora intercepta `KEYCODE_DPAD_DOWN` cuando está en el último elemento
|
||||
- Combina scroll listener táctil + manejo de teclas del control remoto
|
||||
|
||||
### 2. Barra de Scroll Más Visible
|
||||
- **Problema**: La barra de seguimiento no era visible
|
||||
- **Solución**:
|
||||
- Color del thumb: Blanco sólido (#FFFFFFFF) - antes 80%
|
||||
- Ancho aumentado a 12dp (antes 8dp)
|
||||
- Radio de esquinas: 6dp (antes 4dp)
|
||||
- Track oscuro agregado (#1A1A1A)
|
||||
- `scrollbarAlwaysDrawVerticalTrack="true"` para siempre visible
|
||||
|
||||
## Archivos Modificados
|
||||
|
||||
### MainActivity.java
|
||||
- Import agregado: `android.view.KeyEvent`
|
||||
- `setOnKeyListener` agregado en `showEvents()` para interceptar DPAD_DOWN
|
||||
- Combina con scroll listener existente para cobertura completa
|
||||
|
||||
### scrollbar_vertical.xml
|
||||
- Color cambiado a blanco sólido (#FFFFFFFF)
|
||||
- Ancho: 12dp
|
||||
- Radio: 6dp
|
||||
|
||||
### activity_main.xml
|
||||
- `scrollbarSize="12dp"` (antes 8dp)
|
||||
- `scrollbarTrackVertical="@color/scrollbar_track"` agregado
|
||||
- `scrollbarAlwaysDrawVerticalTrack="true"` agregado
|
||||
|
||||
### colors.xml
|
||||
- Nuevo color: `scrollbar_track` (#1A1A1A)
|
||||
|
||||
## Compatibilidad
|
||||
- Android TV con control remoto
|
||||
- Versión mínima: API 21+
|
||||
22
CHANGELOG-v10.1.7.md
Normal file
22
CHANGELOG-v10.1.7.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# StreamPlayer v10.1.7 - Corrección de Navegación y Scrollbar Permanente
|
||||
|
||||
## Correcciones Implementadas
|
||||
|
||||
### 1. Barra de Desplazamiento Permanente
|
||||
- **Feature**: Se agregó `android:fadeScrollbars="false"` al `RecyclerView` de eventos.
|
||||
- **Beneficio**: La barra de desplazamiento ahora es visible permanentemente, permitiendo al usuario saber su posición (inicio, medio, final) en todo momento sin tener que interactuar primero.
|
||||
|
||||
### 2. Navegación al Final de la Lista (Bug Fix)
|
||||
- **Problema**: Al presionar "abajo" en el último evento, el foco saltaba involuntariamente a la sección de canales.
|
||||
- **Solución**: Se implementó un `LinearLayoutManager` personalizado que intercepta la búsqueda de foco (`onInterceptFocusSearch`).
|
||||
- **Detalle**: Cuando se detecta `FOCUS_DOWN` en el último elemento de la lista, la acción se bloquea, manteniendo al usuario en la lista de eventos.
|
||||
- **Limpieza**: Se eliminaron los `OnKeyListener` y `OnScrollListener` anteriores que eran menos efectivos.
|
||||
|
||||
## Archivos Modificados
|
||||
|
||||
### MainActivity.java
|
||||
- Implementación de `LinearLayoutManager` anónimo con `onInterceptFocusSearch`.
|
||||
- Eliminación de listeners redundantes.
|
||||
|
||||
### activity_main.xml
|
||||
- `android:fadeScrollbars="false"` añadido a `content_list`.
|
||||
21
CHANGELOG-v10.1.8.md
Normal file
21
CHANGELOG-v10.1.8.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# StreamPlayer v10.1.8 - Actualización de DNS y Dominios
|
||||
|
||||
## Cambios Críticos
|
||||
|
||||
### 1. Actualización de Dominios
|
||||
- Se ha migrado toda la infraestructura de canales y eventos al nuevo dominio: `streamtp10.com`.
|
||||
- Actualización de URLs base para todos los canales en `ChannelRepository`.
|
||||
- Actualización del endpoint de eventos a `https://streamtp10.com/eventos.json`.
|
||||
- Corrección del Header `Referer` en las peticiones de resolución.
|
||||
|
||||
### 2. Configuración Robusta de DNS (Anti-Bloqueo)
|
||||
- Implementación de un nuevo sistema centralizado de red (`NetworkUtils`).
|
||||
- **DNS Primario**: Google DNS over HTTPS (`8.8.8.8`, `8.8.4.4`).
|
||||
- **DNS Secundario**: AdGuard DNS over HTTPS (`94.140.14.14`, `94.140.15.15`) como respaldo automático si Google falla.
|
||||
- **DNS Terciario**: DNS del sistema (ISP) como último recurso.
|
||||
- Se ha eliminado el uso de `HttpURLConnection` en `EventRepository` en favor de `OkHttpClient` con la nueva configuración DNS, asegurando que la carga de la guía de eventos también evite bloqueos.
|
||||
|
||||
## Beneficios
|
||||
- Mayor resistencia a bloqueos regionales e interferencias de ISP.
|
||||
- Recuperación automática si el proveedor de DNS principal (Google) no es accesible.
|
||||
- Corrección de problemas de carga de canales debido al cambio de dominio del proveedor.
|
||||
639
VLC_MIGRATION_PLAN.md
Normal file
639
VLC_MIGRATION_PLAN.md
Normal file
@@ -0,0 +1,639 @@
|
||||
# VLC Player Migration Plan for Android App
|
||||
|
||||
## Current State Analysis
|
||||
- **Location**: `/home/ren/futbol/`
|
||||
- **Current Player**: ExoPlayer/Media3 1.5.0
|
||||
- **Main Files**:
|
||||
- `app/src/main/java/com/streamplayer/PlayerActivity.java`
|
||||
- `app/src/main/java/com/streamplayer/StreamUrlResolver.java`
|
||||
- `app/src/main/res/layout/activity_player.xml`
|
||||
- **Key Features**: HLS streams, custom headers, retry logic, loading indicators, error handling
|
||||
|
||||
## Target State
|
||||
- **New Player**: libvlc for Android (VLC Android SDK)
|
||||
- **DRM Support**: ClearKey DRM for protected streams
|
||||
- **Preserve**: All existing functionality
|
||||
|
||||
---
|
||||
|
||||
## Phase 1: Build Configuration Changes
|
||||
|
||||
### File: `app/build.gradle`
|
||||
|
||||
**Remove Media3 dependencies:**
|
||||
```gradle
|
||||
// REMOVE these lines (52-57):
|
||||
implementation 'androidx.media3:media3-exoplayer:1.5.0'
|
||||
implementation 'androidx.media3:media3-exoplayer-hls:1.5.0'
|
||||
implementation 'androidx.media3:media3-datasource-okhttp:1.5.0'
|
||||
implementation 'androidx.media3:media3-ui:1.5.0'
|
||||
implementation 'androidx.media3:media3-ui-leanback:1.5.0'
|
||||
implementation 'androidx.media3:media3-session:1.5.0'
|
||||
```
|
||||
|
||||
**Add VLC Android SDK dependency:**
|
||||
```gradle
|
||||
// ADD after line 57:
|
||||
// VLC Android SDK
|
||||
implementation 'org.videolan.android:libvlc-all:3.5.4'
|
||||
// Alternative: Use specific modules for smaller APK
|
||||
// implementation 'org.videolan.android:libvlc:3.5.4'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 2: Layout Changes
|
||||
|
||||
### File: `app/src/main/res/layout/activity_player.xml`
|
||||
|
||||
**Current (lines 10-15):**
|
||||
```xml
|
||||
<androidx.media3.ui.PlayerView
|
||||
android:id="@+id/player_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:resize_mode="fill"
|
||||
app:use_controller="true" />
|
||||
```
|
||||
|
||||
**Replace with VLC SurfaceView:**
|
||||
```xml
|
||||
<org.videolan.libvlc.util.VLCVideoLayout
|
||||
android:id="@+id/player_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<!-- OR use SurfaceView directly for more control -->
|
||||
<SurfaceView
|
||||
android:id="@+id/player_surface"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
```
|
||||
|
||||
**Note**: Keep all other UI elements unchanged (toolbar, loading indicator, error message).
|
||||
|
||||
---
|
||||
|
||||
## Phase 3: PlayerActivity Rewrite
|
||||
|
||||
### File: `app/src/main/java/com/streamplayer/PlayerActivity.java`
|
||||
|
||||
**Import Changes:**
|
||||
```java
|
||||
// REMOVE these imports (14-28):
|
||||
import androidx.media3.exoplayer.ExoPlayer;
|
||||
import androidx.media3.common.MediaItem;
|
||||
import androidx.media3.common.PlaybackException;
|
||||
import androidx.media3.common.Player;
|
||||
import androidx.media3.exoplayer.DefaultRenderersFactory;
|
||||
import androidx.media3.exoplayer.trackselection.DefaultTrackSelector;
|
||||
import androidx.media3.datasource.okhttp.OkHttpDataSource;
|
||||
import androidx.media3.exoplayer.source.MediaSource;
|
||||
import androidx.media3.exoplayer.hls.HlsMediaSource;
|
||||
import androidx.media3.exoplayer.drm.DrmSessionManager;
|
||||
import androidx.media3.ui.PlayerView;
|
||||
import androidx.media3.common.util.Util;
|
||||
import androidx.annotation.OptIn;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
|
||||
// ADD VLC imports:
|
||||
import org.videolan.libvlc.LibVLC;
|
||||
import org.videolan.libvlc.Media;
|
||||
import org.videolan.libvlc.MediaPlayer;
|
||||
import org.videolan.libvlc.interfaces.IVLCVout;
|
||||
import org.videolan.libvlc.util.VLCVideoLayout;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.SurfaceHolder;
|
||||
```
|
||||
|
||||
**Class Member Variables (lines 51-66):**
|
||||
```java
|
||||
// REPLACE:
|
||||
private PlayerView playerView;
|
||||
private ExoPlayer player;
|
||||
private DefaultTrackSelector trackSelector;
|
||||
|
||||
// WITH:
|
||||
private VLCVideoLayout playerView; // OR SurfaceView playerSurface
|
||||
private LibVLC libVlc;
|
||||
private MediaPlayer mediaPlayer;
|
||||
private SurfaceView surfaceView;
|
||||
```
|
||||
|
||||
**onCreate Method (lines 68-98):**
|
||||
```java
|
||||
// MODIFY initViews() call:
|
||||
private void initViews() {
|
||||
playerView = findViewById(R.id.player_view); // VLCVideoLayout
|
||||
// OR if using SurfaceView:
|
||||
surfaceView = findViewById(R.id.player_surface);
|
||||
|
||||
loadingIndicator = findViewById(R.id.loading_indicator);
|
||||
errorMessage = findViewById(R.id.error_message);
|
||||
channelLabel = findViewById(R.id.player_channel_label);
|
||||
closeButton = findViewById(R.id.close_button);
|
||||
playerToolbar = findViewById(R.id.player_toolbar);
|
||||
|
||||
closeButton.setOnClickListener(v -> finish());
|
||||
playerView.setOnClickListener(v -> toggleOverlay());
|
||||
// For SurfaceView:
|
||||
// surfaceView.setOnClickListener(v -> toggleOverlay());
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 4: VLC Player Implementation Details
|
||||
|
||||
### 4.1 Initialize VLC with Custom Headers
|
||||
|
||||
**New Method: `startPlayback(String streamUrl)`**
|
||||
```java
|
||||
private void startPlayback(String streamUrl) {
|
||||
try {
|
||||
releasePlayer();
|
||||
lastStreamUrl = streamUrl;
|
||||
retryCount = 0;
|
||||
|
||||
// Create LibVLC instance with options
|
||||
ArrayList<String> options = new ArrayList<>();
|
||||
|
||||
// Network options
|
||||
options.add("--network-caching=1500");
|
||||
options.add("--clock-jitter=0");
|
||||
options.add("--clock-synchro=0");
|
||||
|
||||
// HTTP options for headers
|
||||
options.add(":http-user-agent=" + USER_AGENT);
|
||||
options.add(":http-referrer=" + "http://streamtp10.com/");
|
||||
|
||||
// SSL options (accept all certificates)
|
||||
options.add("--no-xlib");
|
||||
options.add(":rtsp-tcp");
|
||||
options.add(":no-cert-check");
|
||||
|
||||
// Create LibVLC
|
||||
libVlc = new LibVLC(this, options);
|
||||
|
||||
// Create MediaPlayer
|
||||
mediaPlayer = new MediaPlayer(libVlc);
|
||||
|
||||
// Set up event listeners
|
||||
setupMediaPlayerListeners();
|
||||
|
||||
// Create Media with custom headers
|
||||
Media media = new Media(libVlc, android.net.Uri.parse(streamUrl));
|
||||
|
||||
// Add headers via Media options
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Referer", "http://streamtp10.com/");
|
||||
headers.put("User-Agent", USER_AGENT);
|
||||
media.addOption(":http-user-agent=" + USER_AGENT);
|
||||
media.addOption(":http-referrer=http://streamtp10.com/");
|
||||
|
||||
mediaPlayer.setMedia(media);
|
||||
media.release();
|
||||
|
||||
// Set up video output
|
||||
IVLCVout vout = mediaPlayer.getVLCVout();
|
||||
if (playerView instanceof VLCVideoLayout) {
|
||||
vout.setVideoView(playerView);
|
||||
} else if (surfaceView != null) {
|
||||
vout.setVideoView(surfaceView);
|
||||
}
|
||||
vout.attachViews();
|
||||
|
||||
// Start playback
|
||||
mediaPlayer.play();
|
||||
setOverlayVisible(false);
|
||||
|
||||
} catch (Exception e) {
|
||||
showError("Error al inicializar reproductor: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 4.2 Player Event Listeners
|
||||
|
||||
**New Method: `setupMediaPlayerListeners()`**
|
||||
```java
|
||||
private void setupMediaPlayerListeners() {
|
||||
// MediaPlayer.EventListener using the VLC event system
|
||||
mediaPlayer.setEventListener(new MediaPlayer.EventListener() {
|
||||
@Override
|
||||
public void onEvent(MediaPlayer.Event event) {
|
||||
switch (event.type) {
|
||||
case MediaPlayer.Event.Playing:
|
||||
// Equivalent to STATE_READY
|
||||
runOnUiThread(() -> {
|
||||
showLoading(false);
|
||||
retryCount = 0;
|
||||
});
|
||||
break;
|
||||
|
||||
case MediaPlayer.Event.Buffering:
|
||||
// Buffering state (0.0 to 1.0)
|
||||
float bufferPercent = event.getBuffering();
|
||||
runOnUiThread(() -> showLoading(bufferPercent < 1.0f));
|
||||
break;
|
||||
|
||||
case MediaPlayer.Event.EncounteredError:
|
||||
// Error occurred
|
||||
runOnUiThread(() -> handlePlaybackError("Error de reproducción VLC"));
|
||||
break;
|
||||
|
||||
case MediaPlayer.Event.EndReached:
|
||||
// Stream ended
|
||||
runOnUiThread(() -> finish());
|
||||
break;
|
||||
|
||||
case MediaPlayer.Event.Stopped:
|
||||
// Playback stopped
|
||||
break;
|
||||
|
||||
case MediaPlayer.Event.Paused:
|
||||
// Playback paused
|
||||
break;
|
||||
|
||||
case MediaPlayer.Event.Opening:
|
||||
// Stream opening
|
||||
runOnUiThread(() -> showLoading(true));
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
### 4.3 Error Handling with Retry
|
||||
|
||||
**New Method: `handlePlaybackError(String errorMessage)`**
|
||||
```java
|
||||
private void handlePlaybackError(String errorMsg) {
|
||||
boolean isRetryableError =
|
||||
errorMsg.contains("404") ||
|
||||
errorMsg.contains("403") ||
|
||||
errorMsg.contains("timeout") ||
|
||||
errorMsg.contains("Network") ||
|
||||
errorMsg.contains("Connection");
|
||||
|
||||
if (isRetryableError && retryCount < MAX_RETRIES) {
|
||||
retryCount++;
|
||||
runOnUiThread(() -> {
|
||||
showLoading(true);
|
||||
showError("Error de conexión. Reintentando... (" + retryCount + "/" + MAX_RETRIES + ")");
|
||||
});
|
||||
|
||||
new android.os.Handler(android.os.Looper.getMainLooper()).postDelayed(() -> {
|
||||
if (lastStreamUrl != null) {
|
||||
startPlayback(lastStreamUrl);
|
||||
} else {
|
||||
loadChannel();
|
||||
}
|
||||
}, 2000);
|
||||
} else {
|
||||
String finalMessage = "Error al reproducir: " + errorMsg;
|
||||
if (retryCount >= MAX_RETRIES) {
|
||||
finalMessage += "\n\nSe agotaron los reintentos (" + MAX_RETRIES + ").";
|
||||
}
|
||||
showError(finalMessage);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 4.4 Player Lifecycle Methods
|
||||
|
||||
**Replace releasePlayer() (lines 257-262):**
|
||||
```java
|
||||
private void releasePlayer() {
|
||||
if (mediaPlayer != null) {
|
||||
mediaPlayer.stop();
|
||||
mediaPlayer.getVLCVout().detachViews();
|
||||
mediaPlayer.release();
|
||||
mediaPlayer = null;
|
||||
}
|
||||
if (libVlc != null) {
|
||||
libVlc.release();
|
||||
libVlc = null;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Update lifecycle methods:**
|
||||
```java
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
if (mediaPlayer != null && !mediaPlayer.isPlaying()) {
|
||||
mediaPlayer.play();
|
||||
} else if (channelUrl != null && libVlc == null) {
|
||||
loadChannel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (mediaPlayer != null) {
|
||||
mediaPlayer.play();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
if (mediaPlayer != null && mediaPlayer.isPlaying()) {
|
||||
mediaPlayer.pause();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
// Keep player for quick resume, don't release
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
releasePlayer();
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 5: DRM Support (ClearKey)
|
||||
|
||||
### ClearKey DRM Implementation Example
|
||||
|
||||
**New Class: `VlcDrmManager.java`**
|
||||
**Location**: `app/src/main/java/com/streamplayer/VlcDrmManager.java`
|
||||
|
||||
```java
|
||||
package com.streamplayer;
|
||||
|
||||
import org.videolan.libvlc.Media;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Handles DRM configuration for VLC Media Player
|
||||
* Supports ClearKey DRM for protected streaming services
|
||||
*/
|
||||
public class VlcDrmManager {
|
||||
|
||||
// ClearKey DRM configuration
|
||||
private static final String CLEARKEY_KEY_SYSTEM = "org.w3.clearkey";
|
||||
|
||||
/**
|
||||
* Configure ClearKey DRM for a Media object
|
||||
* @param media The VLC Media object
|
||||
* @param keyId The key ID (extracted from manifest or license server)
|
||||
* @param key The content key
|
||||
*/
|
||||
public static void configureClearKey(Media media, String keyId, String key) {
|
||||
if (media == null || keyId == null || key == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// VLC uses a specific format for ClearKey
|
||||
// Format: keyid:key
|
||||
String keyPair = keyId + ":" + key;
|
||||
media.addOption(":demux=avformat");
|
||||
media.addOption(":key-format=" + CLEARKEY_KEY_SYSTEM);
|
||||
media.addOption(":key=" + keyPair);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure ClearKey DRM with multiple keys
|
||||
* @param media The VLC Media object
|
||||
* @param keys Map of keyId -> key pairs
|
||||
*/
|
||||
public static void configureClearKey(Media media, Map<String, String> keys) {
|
||||
if (media == null || keys == null || keys.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
media.addOption(":demux=avformat");
|
||||
media.addOption(":key-format=" + CLEARKEY_KEY_SYSTEM);
|
||||
|
||||
for (Map.Entry<String, String> entry : keys.entrySet()) {
|
||||
String keyPair = entry.getKey() + ":" + entry.getValue();
|
||||
media.addOption(":key=" + keyPair);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure Widevine DRM (for reference, if needed later)
|
||||
* VLC supports Widevine via specific options
|
||||
*/
|
||||
public static void configureWidevine(Media media, String drmServerUrl) {
|
||||
if (media == null || drmServerUrl == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
media.addOption(":drm=widevine");
|
||||
media.addOption(":aes-key=" + drmServerUrl);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Extracting ClearKey Keys from Stream
|
||||
|
||||
**Update `StreamUrlResolver.java` to extract DRM info:**
|
||||
|
||||
Add this method to `StreamUrlResolver`:
|
||||
```java
|
||||
/**
|
||||
* Extract ClearKey DRM keys from JSON in HTML
|
||||
* @return Map of keyId -> key pairs, or null if no DRM found
|
||||
*/
|
||||
public static Map<String, String> extractClearKeyKeys(String html) {
|
||||
Map<String, String> keys = new HashMap<>();
|
||||
|
||||
try {
|
||||
// Pattern to find ClearKey key IDs and keys
|
||||
// Common patterns in protected streaming services
|
||||
Pattern clearkeyPattern = Pattern.compile(
|
||||
"\"kid\"\\s*:\\s*\"([^\"]+)\".*?\"k\"\\s*:\\s*\"([^\"]+)\"",
|
||||
Pattern.DOTALL
|
||||
);
|
||||
|
||||
Matcher matcher = clearkeyPattern.matcher(html);
|
||||
while (matcher.find()) {
|
||||
String keyId = matcher.group(1);
|
||||
String key = matcher.group(2);
|
||||
keys.put(keyId, key);
|
||||
}
|
||||
|
||||
// Alternative pattern for JWPlayer with DRM
|
||||
Pattern jwDrmPattern = Pattern.compile(
|
||||
"\"drm\"\\s*:\\s*\\{[^}]*\"clearkey\"\\s*:\\s*\\{[^}]*\"keyId\"\\s*:\\s*\"([^\"]+)\"[^}]*\"key\"\\s*:\\s*\"([^\"]+)\"",
|
||||
Pattern.DOTALL
|
||||
);
|
||||
|
||||
Matcher jwMatcher = jwDrmPattern.matcher(html);
|
||||
while (jwMatcher.find()) {
|
||||
String keyId = jwMatcher.group(1);
|
||||
String key = jwMatcher.group(2);
|
||||
keys.put(keyId, key);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Return empty map on error
|
||||
}
|
||||
|
||||
return keys.isEmpty() ? null : keys;
|
||||
}
|
||||
```
|
||||
|
||||
### Using DRM in PlayerActivity
|
||||
|
||||
**Modify `startPlayback()` to handle DRM:**
|
||||
```java
|
||||
// After loading stream URL, also check for DRM keys
|
||||
new Thread(() -> {
|
||||
try {
|
||||
String resolvedUrl = StreamUrlResolver.resolve(channelUrl);
|
||||
Map<String, String> drmKeys = StreamUrlResolver.extractClearKeyKeys(html); // Need to modify resolver to also return HTML
|
||||
|
||||
runOnUiThread(() -> startPlayback(resolvedUrl, drmKeys));
|
||||
} catch (IOException e) {
|
||||
runOnUiThread(() -> showError("No se pudo conectar con el canal: " + e.getMessage()));
|
||||
}
|
||||
}).start();
|
||||
|
||||
private void startPlayback(String streamUrl, Map<String, String> drmKeys) {
|
||||
// ... existing VLC setup code ...
|
||||
|
||||
Media media = new Media(libVlc, android.net.Uri.parse(streamUrl));
|
||||
|
||||
// Add headers
|
||||
media.addOption(":http-user-agent=" + USER_AGENT);
|
||||
media.addOption(":http-referrer=http://streamtp10.com/");
|
||||
|
||||
// Add DRM if available
|
||||
if (drmKeys != null && !drmKeys.isEmpty()) {
|
||||
VlcDrmManager.configureClearKey(media, drmKeys);
|
||||
}
|
||||
|
||||
// ... rest of the setup ...
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 6: Additional Files
|
||||
|
||||
### New File: `VlcPlayerConfig.java`
|
||||
**Location**: `app/src/main/java/com/streamplayer/VlcPlayerConfig.java`
|
||||
|
||||
```java
|
||||
package com.streamplayer;
|
||||
|
||||
/**
|
||||
* Configuration constants for VLC Player
|
||||
*/
|
||||
public class VlcPlayerConfig {
|
||||
|
||||
// Network caching (ms)
|
||||
public static final int NETWORK_CACHING = 1500;
|
||||
|
||||
// Live streaming caching (ms)
|
||||
public static final int LIVE_CACHING = 5000;
|
||||
|
||||
// User Agent
|
||||
public static final String USER_AGENT =
|
||||
"Mozilla/5.0 (Linux; Android 13; Pixel 7) AppleWebKit/537.36";
|
||||
|
||||
// Hardware acceleration options
|
||||
public static final String HW_ACCELERATION = "automatic"; // or "full", "none", "decoding", "rendering"
|
||||
|
||||
// Chroma format
|
||||
public static final String CHROMA = "RV32"; // or YV12, NV12
|
||||
|
||||
// Audio output
|
||||
public static final String AUDIO_OUTPUT = "opensles";
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 7: Summary of File Changes
|
||||
|
||||
| File Path | Change Type | Description |
|
||||
|-----------|-------------|-------------|
|
||||
| `app/build.gradle` | Modify | Remove Media3 deps, add VLC SDK |
|
||||
| `app/src/main/res/layout/activity_player.xml` | Modify | Replace PlayerView with VLCVideoLayout |
|
||||
| `app/src/main/java/com/streamplayer/PlayerActivity.java` | Rewrite | Complete VLC integration |
|
||||
| `app/src/main/java/com/streamplayer/VlcDrmManager.java` | New | DRM configuration handler |
|
||||
| `app/src/main/java/com/streamplayer/VlcPlayerConfig.java` | New | VLC configuration constants |
|
||||
| `app/src/main/java/com/streamplayer/StreamUrlResolver.java` | Modify | Add DRM key extraction |
|
||||
|
||||
---
|
||||
|
||||
## Phase 8: VLC-Specific Notes
|
||||
|
||||
### HTTP Headers in VLC
|
||||
VLC handles HTTP headers differently than ExoPlayer:
|
||||
- Headers are set via Media.addOption() with colon prefix
|
||||
- Format: `:http-header-name=value`
|
||||
- Common options:
|
||||
- `:http-user-agent=<value>`
|
||||
- `:http-referrer=<value>`
|
||||
- `:http-cookie=<value>`
|
||||
|
||||
### VLC Events vs ExoPlayer States
|
||||
|
||||
| ExoPlayer State | VLC Event |
|
||||
|----------------|-----------|
|
||||
| STATE_IDLE | N/A (not initialized) |
|
||||
| STATE_BUFFERING | Event.Buffering |
|
||||
| STATE_READY | Event.Playing |
|
||||
| STATE_ENDED | Event.EndReached |
|
||||
|
||||
### DRM Support Comparison
|
||||
| Feature | ExoPlayer | VLC |
|
||||
|---------|-----------|-----|
|
||||
| Widevine | Native | Limited |
|
||||
| ClearKey | Via DRM module | Via libavformat |
|
||||
| PlayReady | Native | Limited |
|
||||
| FairPlay | No | Limited |
|
||||
|
||||
---
|
||||
|
||||
## Phase 9: Testing Checklist
|
||||
|
||||
1. [ ] Basic HLS stream playback
|
||||
2. [ ] HTTP headers (Referer, User-Agent) applied correctly
|
||||
3. [ ] Loading indicator shows/hides correctly
|
||||
4. [ ] Error messages display properly
|
||||
5. [ ] Retry logic works on connection failure
|
||||
6. [ ] Screen stays on during playback
|
||||
7. [ ] Overlay toggle works on tap
|
||||
8. [ ] Close button returns to main activity
|
||||
9. [ ] App handles pause/resume correctly
|
||||
10. [ ] Memory leaks checked (no retained VLC instances)
|
||||
11. [ ] DRM streams play correctly
|
||||
12. [ ] SSL certificate bypass works
|
||||
|
||||
---
|
||||
|
||||
## Phase 10: Fallback Strategy
|
||||
|
||||
If VLC doesn't work as expected, consider:
|
||||
1. **Hybrid approach**: Keep ExoPlayer as fallback, use VLC for DRM-only streams
|
||||
2. **Alternative libraries**:
|
||||
- Vitamio (deprecated but still works)
|
||||
- NKD-Player (wrapper around FFmpeg)
|
||||
- Build custom FFmpeg integration
|
||||
3. **Webview approach**: Use embedded browser for DRM content
|
||||
|
||||
---
|
||||
|
||||
## Appendix: VLC SDK Documentation Links
|
||||
|
||||
- VLC Android SDK: https://code.videolan.org/videolan/vlc-android
|
||||
- VLC LibVLC API: https://code.videolan.org/videolan/vlc-android/-/tree/master/libvlc
|
||||
- VLC Wiki on Android: https://wiki.videolan.org/AndroidCompile
|
||||
- ClearKey DRM spec: https://w3c.github.io/encrypted-media/format-registry/initdata/cenc.html
|
||||
@@ -2,14 +2,14 @@ apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
namespace "com.streamplayer"
|
||||
compileSdk 33
|
||||
compileSdk 35
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.streamplayer"
|
||||
minSdk 21
|
||||
targetSdk 33
|
||||
versionCode 100500
|
||||
versionName "10.0.5"
|
||||
targetSdk 35
|
||||
versionCode 100201
|
||||
versionName "11.0.1"
|
||||
buildConfigField "String", "DEVICE_REGISTRY_URL", '"http://194.163.191.200:4000"'
|
||||
}
|
||||
|
||||
@@ -47,10 +47,11 @@ dependencies {
|
||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.3.2'
|
||||
implementation 'androidx.media3:media3-exoplayer:1.4.1'
|
||||
implementation 'androidx.media3:media3-exoplayer-hls:1.4.1'
|
||||
implementation 'androidx.media3:media3-ui:1.4.1'
|
||||
|
||||
// ExoPlayer para reproducción de video
|
||||
implementation 'com.google.android.exoplayer:exoplayer:2.18.7'
|
||||
implementation 'com.google.android.exoplayer:extension-okhttp:2.18.7'
|
||||
// OkHttp con DNS over HTTPS (para StreamUrlResolver)
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
|
||||
implementation 'com.squareup.okhttp3:okhttp-dnsoverhttps:4.12.0'
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
<uses-feature
|
||||
android:name="android.software.leanback"
|
||||
|
||||
@@ -7,21 +7,37 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
import androidx.recyclerview.widget.ListAdapter;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ChannelAdapter extends RecyclerView.Adapter<ChannelAdapter.ChannelViewHolder> {
|
||||
public class ChannelAdapter extends ListAdapter<StreamChannel, ChannelAdapter.ChannelViewHolder> {
|
||||
|
||||
public interface OnChannelClickListener {
|
||||
void onChannelClick(StreamChannel channel);
|
||||
}
|
||||
|
||||
private final List<StreamChannel> channels = new ArrayList<>();
|
||||
private static final DiffUtil.ItemCallback<StreamChannel> DIFF_CALLBACK =
|
||||
new DiffUtil.ItemCallback<StreamChannel>() {
|
||||
@Override
|
||||
public boolean areItemsTheSame(@NonNull StreamChannel oldItem, @NonNull StreamChannel newItem) {
|
||||
return oldItem.getPageUrl().equals(newItem.getPageUrl());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areContentsTheSame(@NonNull StreamChannel oldItem, @NonNull StreamChannel newItem) {
|
||||
return oldItem.getName().equals(newItem.getName())
|
||||
&& oldItem.getPageUrl().equals(newItem.getPageUrl());
|
||||
}
|
||||
};
|
||||
|
||||
private final OnChannelClickListener listener;
|
||||
|
||||
public ChannelAdapter(OnChannelClickListener listener) {
|
||||
super(DIFF_CALLBACK);
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@@ -35,7 +51,7 @@ public class ChannelAdapter extends RecyclerView.Adapter<ChannelAdapter.ChannelV
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ChannelViewHolder holder, int position) {
|
||||
StreamChannel channel = channels.get(position);
|
||||
StreamChannel channel = getItem(position);
|
||||
holder.name.setText(channel.getName());
|
||||
holder.icon.setImageResource(R.drawable.ic_channel_default);
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
@@ -52,7 +68,7 @@ public class ChannelAdapter extends RecyclerView.Adapter<ChannelAdapter.ChannelV
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return channels.size();
|
||||
return super.getItemCount();
|
||||
}
|
||||
|
||||
static class ChannelViewHolder extends RecyclerView.ViewHolder {
|
||||
@@ -67,10 +83,10 @@ public class ChannelAdapter extends RecyclerView.Adapter<ChannelAdapter.ChannelV
|
||||
}
|
||||
|
||||
public void submitList(List<StreamChannel> newChannels) {
|
||||
channels.clear();
|
||||
if (newChannels != null) {
|
||||
channels.addAll(newChannels);
|
||||
if (newChannels == null) {
|
||||
super.submitList(null);
|
||||
return;
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
super.submitList(new ArrayList<>(newChannels));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,77 +9,84 @@ import java.util.List;
|
||||
public final class ChannelRepository {
|
||||
|
||||
private static final List<StreamChannel> CHANNELS = createChannels();
|
||||
private static final Comparator<StreamChannel> CHANNEL_NAME_COMPARATOR =
|
||||
new Comparator<StreamChannel>() {
|
||||
@Override
|
||||
public int compare(StreamChannel left, StreamChannel right) {
|
||||
return String.CASE_INSENSITIVE_ORDER.compare(left.getName(), right.getName());
|
||||
}
|
||||
};
|
||||
|
||||
private static List<StreamChannel> createChannels() {
|
||||
List<StreamChannel> channels = new ArrayList<>(Arrays.asList(
|
||||
new StreamChannel("ESPN", "https://streamtpcloud.com/global2.php?stream=espn"),
|
||||
new StreamChannel("ESPN 2", "https://streamtpcloud.com/global2.php?stream=espn2"),
|
||||
new StreamChannel("ESPN 3", "https://streamtpcloud.com/global2.php?stream=espn3"),
|
||||
new StreamChannel("ESPN 4", "https://streamtpcloud.com/global2.php?stream=espn4"),
|
||||
new StreamChannel("ESPN 3 MX", "https://streamtpcloud.com/global2.php?stream=espn3mx"),
|
||||
new StreamChannel("ESPN 5", "https://streamtpcloud.com/global2.php?stream=espn5"),
|
||||
new StreamChannel("Fox Sports 3 MX", "https://streamtpcloud.com/global2.php?stream=foxsports3mx"),
|
||||
new StreamChannel("ESPN 6", "https://streamtpcloud.com/global2.php?stream=espn6"),
|
||||
new StreamChannel("Fox Sports MX", "https://streamtpcloud.com/global2.php?stream=foxsportsmx"),
|
||||
new StreamChannel("ESPN 7", "https://streamtpcloud.com/global2.php?stream=espn7"),
|
||||
new StreamChannel("Azteca Deportes", "https://streamtpcloud.com/global2.php?stream=azteca_deportes"),
|
||||
new StreamChannel("Win Plus", "https://streamtpcloud.com/global2.php?stream=winplus"),
|
||||
new StreamChannel("DAZN 1", "https://streamtpcloud.com/global2.php?stream=dazn1"),
|
||||
new StreamChannel("Win Plus 2", "https://streamtpcloud.com/global2.php?stream=winplus2"),
|
||||
new StreamChannel("DAZN 2", "https://streamtpcloud.com/global2.php?stream=dazn2"),
|
||||
new StreamChannel("Win Sports", "https://streamtpcloud.com/global2.php?stream=winsports"),
|
||||
new StreamChannel("DAZN LaLiga", "https://streamtpcloud.com/global2.php?stream=dazn_laliga"),
|
||||
new StreamChannel("Win Plus Online 1", "https://streamtpcloud.com/global2.php?stream=winplusonline1"),
|
||||
new StreamChannel("Caracol TV", "https://streamtpcloud.com/global2.php?stream=caracoltv"),
|
||||
new StreamChannel("Fox 1 AR", "https://streamtpcloud.com/global2.php?stream=fox1ar"),
|
||||
new StreamChannel("Fox 2 USA", "https://streamtpcloud.com/global2.php?stream=fox_2_usa"),
|
||||
new StreamChannel("Fox 2 AR", "https://streamtpcloud.com/global2.php?stream=fox2ar"),
|
||||
new StreamChannel("TNT 1 GB", "https://streamtpcloud.com/global2.php?stream=tnt_1_gb"),
|
||||
new StreamChannel("TNT 2 GB", "https://streamtpcloud.com/global2.php?stream=tnt_2_gb"),
|
||||
new StreamChannel("Fox 3 AR", "https://streamtpcloud.com/global2.php?stream=fox3ar"),
|
||||
new StreamChannel("Universo USA", "https://streamtpcloud.com/global2.php?stream=universo_usa"),
|
||||
new StreamChannel("DSports", "https://streamtpcloud.com/global2.php?stream=dsports"),
|
||||
new StreamChannel("Univision USA", "https://streamtpcloud.com/global2.php?stream=univision_usa"),
|
||||
new StreamChannel("DSports 2", "https://streamtpcloud.com/global2.php?stream=dsports2"),
|
||||
new StreamChannel("Fox Deportes USA", "https://streamtpcloud.com/global2.php?stream=fox_deportes_usa"),
|
||||
new StreamChannel("DSports Plus", "https://streamtpcloud.com/global2.php?stream=dsportsplus"),
|
||||
new StreamChannel("Fox Sports 2 MX", "https://streamtpcloud.com/global2.php?stream=foxsports2mx"),
|
||||
new StreamChannel("TNT Sports Chile", "https://streamtpcloud.com/global2.php?stream=tntsportschile"),
|
||||
new StreamChannel("Fox Sports Premium", "https://streamtpcloud.com/global2.php?stream=foxsportspremium"),
|
||||
new StreamChannel("TNT Sports", "https://streamtpcloud.com/global2.php?stream=tntsports"),
|
||||
new StreamChannel("ESPN MX", "https://streamtpcloud.com/global2.php?stream=espnmx"),
|
||||
new StreamChannel("ESPN Premium", "https://streamtpcloud.com/global2.php?stream=espnpremium"),
|
||||
new StreamChannel("ESPN 2 MX", "https://streamtpcloud.com/global2.php?stream=espn2mx"),
|
||||
new StreamChannel("TyC Sports", "https://streamtpcloud.com/global2.php?stream=tycsports"),
|
||||
new StreamChannel("TUDN USA", "https://streamtpcloud.com/global2.php?stream=tudn_usa"),
|
||||
new StreamChannel("Telefe", "https://streamtpcloud.com/global2.php?stream=telefe"),
|
||||
new StreamChannel("TNT 3 GB", "https://streamtpcloud.com/global2.php?stream=tnt_3_gb"),
|
||||
new StreamChannel("TV Pública", "https://streamtpcloud.com/global2.php?stream=tv_publica"),
|
||||
new StreamChannel("Fox 1 USA", "https://streamtpcloud.com/global2.php?stream=fox_1_usa"),
|
||||
new StreamChannel("Liga 1 Max", "https://streamtpcloud.com/global2.php?stream=liga1max"),
|
||||
new StreamChannel("Gol TV", "https://streamtpcloud.com/global2.php?stream=goltv"),
|
||||
new StreamChannel("VTV Plus", "https://streamtpcloud.com/global2.php?stream=vtvplus"),
|
||||
new StreamChannel("ESPN Deportes", "https://streamtpcloud.com/global2.php?stream=espndeportes"),
|
||||
new StreamChannel("Gol Perú", "https://streamtpcloud.com/global2.php?stream=golperu"),
|
||||
new StreamChannel("TNT 4 GB", "https://streamtpcloud.com/global2.php?stream=tnt_4_gb"),
|
||||
new StreamChannel("SportTV BR 1", "https://streamtpcloud.com/global2.php?stream=sporttvbr1"),
|
||||
new StreamChannel("SportTV BR 2", "https://streamtpcloud.com/global2.php?stream=sporttvbr2"),
|
||||
new StreamChannel("SportTV BR 3", "https://streamtpcloud.com/global2.php?stream=sporttvbr3"),
|
||||
new StreamChannel("Premiere 1", "https://streamtpcloud.com/global2.php?stream=premiere1"),
|
||||
new StreamChannel("Premiere 2", "https://streamtpcloud.com/global2.php?stream=premiere2"),
|
||||
new StreamChannel("Premiere 3", "https://streamtpcloud.com/global2.php?stream=premiere3"),
|
||||
new StreamChannel("ESPN NL 1", "https://streamtpcloud.com/global2.php?stream=espn_nl1"),
|
||||
new StreamChannel("ESPN NL 2", "https://streamtpcloud.com/global2.php?stream=espn_nl2"),
|
||||
new StreamChannel("ESPN NL 3", "https://streamtpcloud.com/global2.php?stream=espn_nl3"),
|
||||
new StreamChannel("Caliente TV MX", "https://streamtpcloud.com/global2.php?stream=calientetvmx"),
|
||||
new StreamChannel("USA Network", "https://streamtpcloud.com/global2.php?stream=usa_network"),
|
||||
new StreamChannel("TyC Internacional", "https://streamtpcloud.com/global2.php?stream=tycinternacional"),
|
||||
new StreamChannel("Canal 5 MX", "https://streamtpcloud.com/global2.php?stream=canal5mx"),
|
||||
new StreamChannel("TUDN MX", "https://streamtpcloud.com/global2.php?stream=TUDNMX"),
|
||||
new StreamChannel("FUTV", "https://streamtpcloud.com/global2.php?stream=futv"),
|
||||
new StreamChannel("LaLiga Hypermotion", "https://streamtpcloud.com/global2.php?stream=laligahypermotion")
|
||||
new StreamChannel("ESPN", "http://streamtp10.com/global2.php?stream=espn"),
|
||||
new StreamChannel("ESPN 2", "http://streamtp10.com/global2.php?stream=espn2"),
|
||||
new StreamChannel("ESPN 3", "http://streamtp10.com/global2.php?stream=espn3"),
|
||||
new StreamChannel("ESPN 4", "http://streamtp10.com/global2.php?stream=espn4"),
|
||||
new StreamChannel("ESPN 3 MX", "http://streamtp10.com/global2.php?stream=espn3mx"),
|
||||
new StreamChannel("ESPN 5", "http://streamtp10.com/global2.php?stream=espn5"),
|
||||
new StreamChannel("Fox Sports 3 MX", "http://streamtp10.com/global2.php?stream=foxsports3mx"),
|
||||
new StreamChannel("ESPN 6", "http://streamtp10.com/global2.php?stream=espn6"),
|
||||
new StreamChannel("Fox Sports MX", "http://streamtp10.com/global2.php?stream=foxsportsmx"),
|
||||
new StreamChannel("ESPN 7", "http://streamtp10.com/global2.php?stream=espn7"),
|
||||
new StreamChannel("Azteca Deportes", "http://streamtp10.com/global2.php?stream=azteca_deportes"),
|
||||
new StreamChannel("Win Plus", "http://streamtp10.com/global2.php?stream=winplus"),
|
||||
new StreamChannel("DAZN 1", "http://streamtp10.com/global2.php?stream=dazn1"),
|
||||
new StreamChannel("Win Plus 2", "http://streamtp10.com/global2.php?stream=winplus2"),
|
||||
new StreamChannel("DAZN 2", "http://streamtp10.com/global2.php?stream=dazn2"),
|
||||
new StreamChannel("Win Sports", "http://streamtp10.com/global2.php?stream=winsports"),
|
||||
new StreamChannel("DAZN LaLiga", "http://streamtp10.com/global2.php?stream=dazn_laliga"),
|
||||
new StreamChannel("Win Plus Online 1", "http://streamtp10.com/global2.php?stream=winplusonline1"),
|
||||
new StreamChannel("Caracol TV", "http://streamtp10.com/global2.php?stream=caracoltv"),
|
||||
new StreamChannel("Fox 1 AR", "http://streamtp10.com/global2.php?stream=fox1ar"),
|
||||
new StreamChannel("Fox 2 USA", "http://streamtp10.com/global2.php?stream=fox_2_usa"),
|
||||
new StreamChannel("Fox 2 AR", "http://streamtp10.com/global2.php?stream=fox2ar"),
|
||||
new StreamChannel("TNT 1 GB", "http://streamtp10.com/global2.php?stream=tnt_1_gb"),
|
||||
new StreamChannel("TNT 2 GB", "http://streamtp10.com/global2.php?stream=tnt_2_gb"),
|
||||
new StreamChannel("Fox 3 AR", "http://streamtp10.com/global2.php?stream=fox3ar"),
|
||||
new StreamChannel("Universo USA", "http://streamtp10.com/global2.php?stream=universo_usa"),
|
||||
new StreamChannel("DSports", "http://streamtp10.com/global2.php?stream=dsports"),
|
||||
new StreamChannel("Univision USA", "http://streamtp10.com/global2.php?stream=univision_usa"),
|
||||
new StreamChannel("DSports 2", "http://streamtp10.com/global2.php?stream=dsports2"),
|
||||
new StreamChannel("Fox Deportes USA", "http://streamtp10.com/global2.php?stream=fox_deportes_usa"),
|
||||
new StreamChannel("DSports Plus", "http://streamtp10.com/global2.php?stream=dsportsplus"),
|
||||
new StreamChannel("Fox Sports 2 MX", "http://streamtp10.com/global2.php?stream=foxsports2mx"),
|
||||
new StreamChannel("TNT Sports Chile", "http://streamtp10.com/global2.php?stream=tntsportschile"),
|
||||
new StreamChannel("Fox Sports Premium", "http://streamtp10.com/global2.php?stream=foxsportspremium"),
|
||||
new StreamChannel("TNT Sports", "http://streamtp10.com/global2.php?stream=tntsports"),
|
||||
new StreamChannel("ESPN MX", "http://streamtp10.com/global2.php?stream=espnmx"),
|
||||
new StreamChannel("ESPN Premium", "http://streamtp10.com/global2.php?stream=espnpremium"),
|
||||
new StreamChannel("ESPN 2 MX", "http://streamtp10.com/global2.php?stream=espn2mx"),
|
||||
new StreamChannel("TyC Sports", "http://streamtp10.com/global2.php?stream=tycsports"),
|
||||
new StreamChannel("TUDN USA", "http://streamtp10.com/global2.php?stream=tudn_usa"),
|
||||
new StreamChannel("Telefe", "http://streamtp10.com/global2.php?stream=telefe"),
|
||||
new StreamChannel("TNT 3 GB", "http://streamtp10.com/global2.php?stream=tnt_3_gb"),
|
||||
new StreamChannel("TV Pública", "http://streamtp10.com/global2.php?stream=tv_publica"),
|
||||
new StreamChannel("Fox 1 USA", "http://streamtp10.com/global2.php?stream=fox_1_usa"),
|
||||
new StreamChannel("Liga 1 Max", "http://streamtp10.com/global2.php?stream=liga1max"),
|
||||
new StreamChannel("Gol TV", "http://streamtp10.com/global2.php?stream=goltv"),
|
||||
new StreamChannel("VTV Plus", "http://streamtp10.com/global2.php?stream=vtvplus"),
|
||||
new StreamChannel("ESPN Deportes", "http://streamtp10.com/global2.php?stream=espndeportes"),
|
||||
new StreamChannel("Gol Perú", "http://streamtp10.com/global2.php?stream=golperu"),
|
||||
new StreamChannel("TNT 4 GB", "http://streamtp10.com/global2.php?stream=tnt_4_gb"),
|
||||
new StreamChannel("SportTV BR 1", "http://streamtp10.com/global2.php?stream=sporttvbr1"),
|
||||
new StreamChannel("SportTV BR 2", "http://streamtp10.com/global2.php?stream=sporttvbr2"),
|
||||
new StreamChannel("SportTV BR 3", "http://streamtp10.com/global2.php?stream=sporttvbr3"),
|
||||
new StreamChannel("Premiere 1", "http://streamtp10.com/global2.php?stream=premiere1"),
|
||||
new StreamChannel("Premiere 2", "http://streamtp10.com/global2.php?stream=premiere2"),
|
||||
new StreamChannel("Premiere 3", "http://streamtp10.com/global2.php?stream=premiere3"),
|
||||
new StreamChannel("ESPN NL 1", "http://streamtp10.com/global2.php?stream=espn_nl1"),
|
||||
new StreamChannel("ESPN NL 2", "http://streamtp10.com/global2.php?stream=espn_nl2"),
|
||||
new StreamChannel("ESPN NL 3", "http://streamtp10.com/global2.php?stream=espn_nl3"),
|
||||
new StreamChannel("Caliente TV MX", "http://streamtp10.com/global2.php?stream=calientetvmx"),
|
||||
new StreamChannel("USA Network", "http://streamtp10.com/global2.php?stream=usa_network"),
|
||||
new StreamChannel("TyC Internacional", "http://streamtp10.com/global2.php?stream=tycinternacional"),
|
||||
new StreamChannel("Canal 5 MX", "http://streamtp10.com/global2.php?stream=canal5mx"),
|
||||
new StreamChannel("TUDN MX", "http://streamtp10.com/global2.php?stream=TUDNMX"),
|
||||
new StreamChannel("FUTV", "http://streamtp10.com/global2.php?stream=futv"),
|
||||
new StreamChannel("LaLiga Hypermotion", "http://streamtp10.com/global2.php?stream=laligahypermotion")
|
||||
));
|
||||
channels.sort(Comparator.comparing(StreamChannel::getName, String.CASE_INSENSITIVE_ORDER));
|
||||
Collections.sort(channels, CHANNEL_NAME_COMPARATOR);
|
||||
return Collections.unmodifiableList(channels);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
package com.streamplayer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.Network;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.net.NetworkRequest;
|
||||
import android.os.Build;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
public class DNSSetter {
|
||||
|
||||
private static final String[] GOOGLE_DNS = {"8.8.8.8", "8.8.4.4"};
|
||||
|
||||
public static void configureDNSToGoogle(Context context) {
|
||||
try {
|
||||
// Configurar propiedades del sistema para usar DNS específicos
|
||||
System.setProperty("networkaddress.cache.ttl", "60");
|
||||
System.setProperty("networkaddress.cache.negative.ttl", "10");
|
||||
|
||||
// Forzar resolución usando DNS de Google
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
configureModernDNS(context);
|
||||
} else {
|
||||
configureLegacyDNS();
|
||||
}
|
||||
|
||||
// Pre-resolver dominio con DNS de Google
|
||||
preResolveWithGoogleDNS();
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error configurando DNS de Google: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static void configureModernDNS(Context context) {
|
||||
try {
|
||||
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
|
||||
NetworkRequest networkRequest = new NetworkRequest.Builder()
|
||||
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
||||
.build();
|
||||
|
||||
connectivityManager.registerNetworkCallback(networkRequest, new ConnectivityManager.NetworkCallback() {
|
||||
@Override
|
||||
public void onAvailable(Network network) {
|
||||
super.onAvailable(network);
|
||||
|
||||
// Configuración para priorizar DNS de Google
|
||||
// Aunque no podemos cambiar DNS directamente sin permisos especiales,
|
||||
// podemos optimizar la configuración de red
|
||||
try {
|
||||
NetworkCapabilities caps = connectivityManager.getNetworkCapabilities(network);
|
||||
if (caps != null) {
|
||||
System.out.println("Red configurada con DNS optimizado para streaming");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error en configuración de red: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error configurando DNS moderno: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static void configureLegacyDNS() {
|
||||
try {
|
||||
// Para versiones antiguas, configuramos propiedades del sistema
|
||||
System.setProperty("sun.net.inetaddr.ttl", "60");
|
||||
System.setProperty("sun.net.inetaddr.negative.ttl", "10");
|
||||
|
||||
System.out.println("DNS legacy configurado para streaming");
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error configurando DNS legacy: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static void preResolveWithGoogleDNS() {
|
||||
try {
|
||||
// Pre-resolver algunos dominios comunes para caching
|
||||
Thread thread = new Thread(() -> {
|
||||
try {
|
||||
String[] domains = {"streamtpmedia.com", "google.com", "doubleclick.net"};
|
||||
for (String domain : domains) {
|
||||
try {
|
||||
InetAddress.getByName(domain);
|
||||
System.out.println("Pre-resuelto: " + domain);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error pre-resolviendo " + domain + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error en pre-resolución: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error en pre-resolución DNS: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static String getGoogleDNSInfo() {
|
||||
return "DNS de Google configurado: " + String.join(", ", GOOGLE_DNS);
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
@@ -46,11 +45,8 @@ public class DeviceRegistry {
|
||||
|
||||
public DeviceRegistry(Context context) {
|
||||
this.appContext = context.getApplicationContext();
|
||||
this.httpClient = new OkHttpClient.Builder()
|
||||
.connectTimeout(10, TimeUnit.SECONDS)
|
||||
.readTimeout(15, TimeUnit.SECONDS)
|
||||
.callTimeout(20, TimeUnit.SECONDS)
|
||||
.build();
|
||||
// Usar NetworkUtils para obtener cliente con DNS over HTTPS configurado
|
||||
this.httpClient = NetworkUtils.getClient();
|
||||
this.executorService = Executors.newSingleThreadExecutor();
|
||||
}
|
||||
|
||||
@@ -140,7 +136,7 @@ public class DeviceRegistry {
|
||||
if (TextUtils.isEmpty(value)) {
|
||||
return "";
|
||||
}
|
||||
return value.substring(0, 1).toUpperCase(Locale.getDefault())
|
||||
return value.substring(0, 1).toUpperCase(Locale.ROOT)
|
||||
+ value.substring(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,29 +6,53 @@ import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
import androidx.recyclerview.widget.ListAdapter;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class EventAdapter extends RecyclerView.Adapter<EventAdapter.EventViewHolder> {
|
||||
public class EventAdapter extends ListAdapter<EventItem, EventAdapter.EventViewHolder> {
|
||||
|
||||
public interface OnEventClickListener {
|
||||
void onEventClick(EventItem event);
|
||||
}
|
||||
|
||||
private final List<EventItem> events = new ArrayList<>();
|
||||
private static final DiffUtil.ItemCallback<EventItem> DIFF_CALLBACK =
|
||||
new DiffUtil.ItemCallback<EventItem>() {
|
||||
@Override
|
||||
public boolean areItemsTheSame(@NonNull EventItem oldItem, @NonNull EventItem newItem) {
|
||||
return oldItem.getPageUrl().equals(newItem.getPageUrl())
|
||||
&& oldItem.getStartMillis() == newItem.getStartMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areContentsTheSame(@NonNull EventItem oldItem, @NonNull EventItem newItem) {
|
||||
return oldItem.getTitle().equals(newItem.getTitle())
|
||||
&& oldItem.getTime().equals(newItem.getTime())
|
||||
&& oldItem.getCategory().equals(newItem.getCategory())
|
||||
&& oldItem.getStatus().equals(newItem.getStatus())
|
||||
&& oldItem.getPageUrl().equals(newItem.getPageUrl())
|
||||
&& oldItem.getChannelName().equals(newItem.getChannelName())
|
||||
&& oldItem.getStartMillis() == newItem.getStartMillis();
|
||||
}
|
||||
};
|
||||
|
||||
private final OnEventClickListener listener;
|
||||
|
||||
public EventAdapter(OnEventClickListener listener) {
|
||||
super(DIFF_CALLBACK);
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void submitList(List<EventItem> newEvents) {
|
||||
events.clear();
|
||||
events.addAll(newEvents);
|
||||
notifyDataSetChanged();
|
||||
if (newEvents == null) {
|
||||
super.submitList(null);
|
||||
return;
|
||||
}
|
||||
super.submitList(new ArrayList<>(newEvents));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -41,7 +65,7 @@ public class EventAdapter extends RecyclerView.Adapter<EventAdapter.EventViewHol
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull EventViewHolder holder, int position) {
|
||||
EventItem event = events.get(position);
|
||||
EventItem event = getItem(position);
|
||||
holder.title.setText(event.getTitle());
|
||||
holder.time.setText(event.getTime());
|
||||
holder.channel.setText(event.getChannelName());
|
||||
@@ -55,7 +79,7 @@ public class EventAdapter extends RecyclerView.Adapter<EventAdapter.EventViewHol
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return events.size();
|
||||
return super.getItemCount();
|
||||
}
|
||||
|
||||
static class EventViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@@ -7,22 +7,18 @@ import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class EventRepository {
|
||||
|
||||
@@ -30,7 +26,13 @@ public class EventRepository {
|
||||
private static final String KEY_JSON = "json";
|
||||
private static final String KEY_TIMESTAMP = "timestamp";
|
||||
private static final long CACHE_DURATION = 24L * 60 * 60 * 1000; // 24 horas
|
||||
private static final String EVENTS_URL = "https://streamtpcloud.com/eventos.json";
|
||||
private static final String ARGENTINA_TIMEZONE_ID = "America/Argentina/Buenos_Aires";
|
||||
private static final TimeZone ARGENTINA_TIMEZONE = TimeZone.getTimeZone(ARGENTINA_TIMEZONE_ID);
|
||||
private static final int ARGENTINA_OFFSET_HOURS = 2;
|
||||
private static final long EVENT_ROLLOVER_WINDOW_MS = 12L * 60 * 60 * 1000;
|
||||
|
||||
// URL única para eventos (actualizado para evitar bloqueos de ISP)
|
||||
private static final String EVENTS_URL = "http://streamtp10.com/eventos.json";
|
||||
|
||||
public interface Callback {
|
||||
void onSuccess(List<EventItem> events);
|
||||
@@ -55,7 +57,7 @@ public class EventRepository {
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
String json = downloadJson();
|
||||
String json = downloadJson(context);
|
||||
List<EventItem> events = parseEvents(json);
|
||||
prefs.edit().putString(KEY_JSON, json).putLong(KEY_TIMESTAMP, System.currentTimeMillis()).apply();
|
||||
callback.onSuccess(events);
|
||||
@@ -73,44 +75,30 @@ public class EventRepository {
|
||||
}).start();
|
||||
}
|
||||
|
||||
private String downloadJson() throws IOException {
|
||||
URL url = new URL(EVENTS_URL);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setConnectTimeout(15000);
|
||||
connection.setReadTimeout(15000);
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
connection.setRequestProperty("User-Agent", "StreamPlayer/1.0");
|
||||
private String downloadJson(Context context) throws IOException {
|
||||
Request request = new Request.Builder()
|
||||
.url(EVENTS_URL)
|
||||
.header("User-Agent", NetworkUtils.getUserAgent())
|
||||
.header("Accept", "application/json")
|
||||
.build();
|
||||
|
||||
try {
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (responseCode != HttpURLConnection.HTTP_OK) {
|
||||
throw new IOException("Error HTTP " + responseCode + ": " + connection.getResponseMessage());
|
||||
try (Response response = NetworkUtils.getClient().newCall(request).execute()) {
|
||||
if (!response.isSuccessful()) {
|
||||
throw new IOException("Error HTTP " + response.code() + ": " + response.message());
|
||||
}
|
||||
|
||||
String contentType = connection.getContentType();
|
||||
// Permitir json o text/plain (Raw de Gitea a veces es text/plain)
|
||||
if (contentType != null && !contentType.contains("json") && !contentType.contains("text/plain")) {
|
||||
throw new IOException("El servidor devolvió " + contentType + " en lugar de JSON. Verifica que la URL sea correcta.");
|
||||
if (response.body() == null) {
|
||||
throw new IOException("Respuesta vacía del servidor");
|
||||
}
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
builder.append(line);
|
||||
}
|
||||
String response = builder.toString();
|
||||
String responseBody = response.body().string();
|
||||
|
||||
// Validar que no sea HTML
|
||||
if (response.trim().startsWith("<!") || response.trim().startsWith("<html")) {
|
||||
throw new IOException("El servidor devolvió HTML en lugar de JSON. La URL del endpoint puede estar incorrecta o el servidor tiene problemas.");
|
||||
}
|
||||
|
||||
return response;
|
||||
// Validar que no sea HTML
|
||||
if (responseBody.trim().startsWith("<!") || responseBody.trim().startsWith("<html")) {
|
||||
throw new IOException("El servidor devolvió HTML en lugar de JSON. La URL del endpoint puede estar incorrecta o el servidor tiene problemas.");
|
||||
}
|
||||
} finally {
|
||||
connection.disconnect();
|
||||
|
||||
return responseBody;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,6 +115,7 @@ public class EventRepository {
|
||||
|
||||
JSONArray array = new JSONArray(json);
|
||||
List<EventItem> events = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
JSONObject obj = array.getJSONObject(i);
|
||||
String title = obj.optString("title");
|
||||
@@ -135,8 +124,11 @@ public class EventRepository {
|
||||
String status = obj.optString("status");
|
||||
String link = obj.optString("link");
|
||||
String normalized = normalizeLink(link);
|
||||
long startMillis = parseEventTime(time);
|
||||
events.add(new EventItem(title, time, category, status, normalized, extractChannelName(link), startMillis));
|
||||
|
||||
EventSchedule schedule = computeEventSchedule(time);
|
||||
String displayTime = schedule.displayTime;
|
||||
long startMillis = schedule.startMillis;
|
||||
events.add(new EventItem(title, displayTime, category, status, normalized, extractChannelName(link), startMillis));
|
||||
}
|
||||
return Collections.unmodifiableList(events);
|
||||
}
|
||||
@@ -145,8 +137,9 @@ public class EventRepository {
|
||||
if (link == null) {
|
||||
return "";
|
||||
}
|
||||
String updated = link.replace("streamtpmedia.com", "streamtpcloud.com");
|
||||
return updated.replace("global1.php", "global2.php");
|
||||
// Mantener el endpoint original (global1/global2) que entregue el proveedor.
|
||||
return link.replace("streamtpmedia.com", "streamtp10.com")
|
||||
.replace("streamtpcloud.com", "streamtp10.com");
|
||||
}
|
||||
|
||||
private String extractChannelName(String link) {
|
||||
@@ -157,26 +150,69 @@ public class EventRepository {
|
||||
if (idx == -1) {
|
||||
return "";
|
||||
}
|
||||
return link.substring(idx + 7).replace("_", " ").toUpperCase();
|
||||
return link.substring(idx + 7).replace("_", " ").toUpperCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
private long parseEventTime(String time) {
|
||||
if (time == null || time.isEmpty()) {
|
||||
return -1;
|
||||
private EventSchedule computeEventSchedule(String time) {
|
||||
if (time == null || time.trim().isEmpty()) {
|
||||
return new EventSchedule(time == null ? "" : time, -1L);
|
||||
}
|
||||
|
||||
try {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
|
||||
LocalTime localTime = LocalTime.parse(time.trim(), formatter);
|
||||
ZoneId zone = ZoneId.of("America/Argentina/Buenos_Aires");
|
||||
LocalDate today = LocalDate.now(zone);
|
||||
ZonedDateTime start = ZonedDateTime.of(LocalDateTime.of(today, localTime), zone);
|
||||
ZonedDateTime now = ZonedDateTime.now(zone);
|
||||
if (start.isBefore(now.minusHours(12))) {
|
||||
start = start.plusDays(1);
|
||||
Calendar adjustedTime = parseAdjustedTime(time);
|
||||
String displayTime = formatTime(adjustedTime);
|
||||
|
||||
Calendar now = Calendar.getInstance(ARGENTINA_TIMEZONE, Locale.US);
|
||||
Calendar start = Calendar.getInstance(ARGENTINA_TIMEZONE, Locale.US);
|
||||
start.set(Calendar.YEAR, now.get(Calendar.YEAR));
|
||||
start.set(Calendar.MONTH, now.get(Calendar.MONTH));
|
||||
start.set(Calendar.DAY_OF_MONTH, now.get(Calendar.DAY_OF_MONTH));
|
||||
start.set(Calendar.HOUR_OF_DAY, adjustedTime.get(Calendar.HOUR_OF_DAY));
|
||||
start.set(Calendar.MINUTE, adjustedTime.get(Calendar.MINUTE));
|
||||
start.set(Calendar.SECOND, 0);
|
||||
start.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
long nowMillis = now.getTimeInMillis();
|
||||
long startMillis = start.getTimeInMillis();
|
||||
if (startMillis < nowMillis - EVENT_ROLLOVER_WINDOW_MS) {
|
||||
start.add(Calendar.DAY_OF_MONTH, 1);
|
||||
startMillis = start.getTimeInMillis();
|
||||
}
|
||||
return start.toInstant().toEpochMilli();
|
||||
} catch (DateTimeParseException e) {
|
||||
return -1;
|
||||
|
||||
return new EventSchedule(displayTime, startMillis);
|
||||
} catch (ParseException ignored) {
|
||||
return new EventSchedule(time, -1L);
|
||||
}
|
||||
}
|
||||
|
||||
private Calendar parseAdjustedTime(String time) throws ParseException {
|
||||
SimpleDateFormat parser = new SimpleDateFormat("HH:mm", Locale.US);
|
||||
parser.setLenient(false);
|
||||
parser.setTimeZone(ARGENTINA_TIMEZONE);
|
||||
java.util.Date parsedDate = parser.parse(time.trim());
|
||||
if (parsedDate == null) {
|
||||
throw new ParseException("Hora inválida: " + time, 0);
|
||||
}
|
||||
|
||||
Calendar adjusted = Calendar.getInstance(ARGENTINA_TIMEZONE, Locale.US);
|
||||
adjusted.setTime(parsedDate);
|
||||
adjusted.add(Calendar.HOUR_OF_DAY, ARGENTINA_OFFSET_HOURS);
|
||||
return adjusted;
|
||||
}
|
||||
|
||||
private String formatTime(Calendar calendar) {
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm", Locale.US);
|
||||
formatter.setTimeZone(ARGENTINA_TIMEZONE);
|
||||
return formatter.format(calendar.getTime());
|
||||
}
|
||||
|
||||
private static final class EventSchedule {
|
||||
final String displayTime;
|
||||
final long startMillis;
|
||||
|
||||
EventSchedule(String displayTime, long startMillis) {
|
||||
this.displayTime = displayTime;
|
||||
this.startMillis = startMillis;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
package com.streamplayer;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
@@ -32,6 +36,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
private ProgressBar loadingIndicator;
|
||||
private TextView messageView;
|
||||
private TextView contentTitle;
|
||||
private Button refreshButton;
|
||||
|
||||
private ChannelAdapter channelAdapter;
|
||||
private EventAdapter eventAdapter;
|
||||
@@ -57,13 +62,30 @@ public class MainActivity extends AppCompatActivity {
|
||||
loadingIndicator = findViewById(R.id.loading_indicator);
|
||||
messageView = findViewById(R.id.message_view);
|
||||
contentTitle = findViewById(R.id.content_title);
|
||||
refreshButton = findViewById(R.id.refresh_button);
|
||||
|
||||
refreshButton.setOnClickListener(v -> {
|
||||
loadEvents(true);
|
||||
Toast.makeText(this, "Actualizando eventos...", Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
|
||||
channelAdapter = new ChannelAdapter(
|
||||
channel -> openPlayer(channel.getName(), channel.getPageUrl()));
|
||||
eventAdapter = new EventAdapter(event -> openPlayer(event.getTitle(), event.getPageUrl()));
|
||||
eventRepository = new EventRepository();
|
||||
channelLayoutManager = new GridLayoutManager(this, getSpanCount());
|
||||
eventLayoutManager = new LinearLayoutManager(this);
|
||||
eventLayoutManager = new LinearLayoutManager(this) {
|
||||
@Override
|
||||
public View onInterceptFocusSearch(View focused, int direction) {
|
||||
if (direction == View.FOCUS_DOWN) {
|
||||
int pos = getPosition(focused);
|
||||
if (pos == getItemCount() - 1) {
|
||||
return focused;
|
||||
}
|
||||
}
|
||||
return super.onInterceptFocusSearch(focused, direction);
|
||||
}
|
||||
};
|
||||
|
||||
sections = buildSections();
|
||||
sectionList.setLayoutManager(new LinearLayoutManager(this));
|
||||
@@ -158,8 +180,11 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private void showChannels(SectionEntry section) {
|
||||
contentTitle.setText(section.title);
|
||||
refreshButton.setVisibility(View.GONE);
|
||||
contentList.setLayoutManager(channelLayoutManager);
|
||||
contentList.setAdapter(channelAdapter);
|
||||
// Clear any scroll listeners from Events section
|
||||
contentList.clearOnScrollListeners();
|
||||
loadingIndicator.setVisibility(View.GONE);
|
||||
channelAdapter.submitList(section.channels);
|
||||
if (section.channels.isEmpty()) {
|
||||
@@ -173,8 +198,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private void showEvents() {
|
||||
contentTitle.setText(currentSection != null ? currentSection.title : getString(R.string.section_events));
|
||||
refreshButton.setVisibility(View.VISIBLE);
|
||||
contentList.setLayoutManager(eventLayoutManager);
|
||||
contentList.setAdapter(eventAdapter);
|
||||
// Clear existing listeners
|
||||
contentList.clearOnScrollListeners();
|
||||
|
||||
if (cachedEvents.isEmpty()) {
|
||||
loadEvents(false);
|
||||
} else {
|
||||
@@ -305,7 +334,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||
try {
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(this, R.string.update_error_open_release, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
@@ -370,7 +399,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
List<StreamChannel> allChannels = ChannelRepository.getChannels();
|
||||
for (StreamChannel channel : allChannels) {
|
||||
String key = deriveGroupName(channel.getName());
|
||||
grouped.computeIfAbsent(key, k -> new ArrayList<>()).add(channel);
|
||||
List<StreamChannel> group = grouped.get(key);
|
||||
if (group == null) {
|
||||
group = new ArrayList<>();
|
||||
grouped.put(key, group);
|
||||
}
|
||||
group.add(channel);
|
||||
}
|
||||
|
||||
List<StreamChannel> espnChannels = grouped.remove("ESPN");
|
||||
|
||||
126
app/src/main/java/com/streamplayer/NetworkUtils.java
Normal file
126
app/src/main/java/com/streamplayer/NetworkUtils.java
Normal file
@@ -0,0 +1,126 @@
|
||||
package com.streamplayer;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
import okhttp3.Dns;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.dnsoverhttps.DnsOverHttps;
|
||||
|
||||
/**
|
||||
* Utilidad centralizada para configuración de red.
|
||||
* Fuerza DNS over HTTPS con fallback Google -> Cloudflare -> DNS del sistema.
|
||||
*/
|
||||
public final class NetworkUtils {
|
||||
|
||||
private static final String TAG = "NetworkUtils";
|
||||
private static final OkHttpClient CLIENT;
|
||||
private static final String USER_AGENT = "Mozilla/5.0 (Linux; Android 13; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36";
|
||||
private static final String GOOGLE_DOH_URL = "https://dns.google/dns-query";
|
||||
private static final String CLOUDFLARE_DOH_URL = "https://cloudflare-dns.com/dns-query";
|
||||
|
||||
static {
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder()
|
||||
.connectTimeout(20, TimeUnit.SECONDS)
|
||||
.readTimeout(30, TimeUnit.SECONDS)
|
||||
.writeTimeout(20, TimeUnit.SECONDS)
|
||||
.followRedirects(true)
|
||||
.followSslRedirects(true)
|
||||
.retryOnConnectionFailure(true);
|
||||
|
||||
try {
|
||||
// Configurar para aceptar todos los certificados SSL (útil para diagnosticar problemas de ISP)
|
||||
// NOTA: Esto es temporal para diagnosticar si hay problemas de certificados MITM
|
||||
final TrustManager[] trustAllCerts = new TrustManager[]{
|
||||
new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] chain, String authType) {}
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] chain, String authType) {}
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return new X509Certificate[]{};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
final SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||
|
||||
builder.sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustAllCerts[0]);
|
||||
builder.hostnameVerifier((hostname, session) -> true);
|
||||
|
||||
OkHttpClient bootstrap = new OkHttpClient.Builder()
|
||||
.connectTimeout(10, TimeUnit.SECONDS)
|
||||
.readTimeout(10, TimeUnit.SECONDS)
|
||||
.sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustAllCerts[0])
|
||||
.hostnameVerifier((hostname, session) -> true)
|
||||
.retryOnConnectionFailure(true)
|
||||
.build();
|
||||
|
||||
final DnsOverHttps googleDns = new DnsOverHttps.Builder()
|
||||
.client(bootstrap)
|
||||
.url(HttpUrl.get(GOOGLE_DOH_URL))
|
||||
.bootstrapDnsHosts(
|
||||
InetAddress.getByName("8.8.8.8"),
|
||||
InetAddress.getByName("8.8.4.4"))
|
||||
.includeIPv6(false)
|
||||
.build();
|
||||
|
||||
final DnsOverHttps cloudflareDns = new DnsOverHttps.Builder()
|
||||
.client(bootstrap)
|
||||
.url(HttpUrl.get(CLOUDFLARE_DOH_URL))
|
||||
.bootstrapDnsHosts(
|
||||
InetAddress.getByName("1.1.1.1"),
|
||||
InetAddress.getByName("1.0.0.1"))
|
||||
.includeIPv6(false)
|
||||
.build();
|
||||
|
||||
builder.dns(hostname -> {
|
||||
try {
|
||||
List<InetAddress> result = googleDns.lookup(hostname);
|
||||
if (result != null && !result.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
try {
|
||||
List<InetAddress> result = cloudflareDns.lookup(hostname);
|
||||
if (result != null && !result.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
return Dns.SYSTEM.lookup(hostname);
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
builder.dns(Dns.SYSTEM);
|
||||
Log.w(TAG, "Error configurando DNS over HTTPS", e);
|
||||
}
|
||||
|
||||
CLIENT = builder.build();
|
||||
}
|
||||
|
||||
private NetworkUtils() {
|
||||
}
|
||||
|
||||
public static OkHttpClient getClient() {
|
||||
return CLIENT;
|
||||
}
|
||||
|
||||
public static String getUserAgent() {
|
||||
return USER_AGENT;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +1,40 @@
|
||||
package com.streamplayer;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.StrictMode;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.OptIn;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.google.android.exoplayer2.ExoPlayer;
|
||||
import com.google.android.exoplayer2.MediaItem;
|
||||
import com.google.android.exoplayer2.PlaybackException;
|
||||
import com.google.android.exoplayer2.Player;
|
||||
import com.google.android.exoplayer2.DefaultRenderersFactory;
|
||||
import com.google.android.exoplayer2.ext.okhttp.OkHttpDataSource;
|
||||
import com.google.android.exoplayer2.source.MediaSource;
|
||||
import com.google.android.exoplayer2.source.hls.HlsMediaSource;
|
||||
import com.google.android.exoplayer2.ui.PlayerView;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import androidx.media3.common.MediaItem;
|
||||
import androidx.media3.common.PlaybackException;
|
||||
import androidx.media3.common.Player;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import androidx.media3.datasource.DefaultHttpDataSource;
|
||||
import androidx.media3.exoplayer.ExoPlayer;
|
||||
import androidx.media3.exoplayer.hls.HlsMediaSource;
|
||||
import androidx.media3.ui.PlayerView;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.dnsoverhttps.DnsOverHttps;
|
||||
|
||||
@OptIn(markerClass = UnstableApi.class)
|
||||
public class PlayerActivity extends AppCompatActivity {
|
||||
|
||||
public static final String EXTRA_CHANNEL_NAME = "extra_channel_name";
|
||||
public static final String EXTRA_CHANNEL_URL = "extra_channel_url";
|
||||
private static final String TAG = "PlayerActivity";
|
||||
private static final long STARTUP_TIMEOUT_MS = 12000L;
|
||||
|
||||
private PlayerView playerView;
|
||||
private ProgressBar loadingIndicator;
|
||||
@@ -49,16 +47,20 @@ public class PlayerActivity extends AppCompatActivity {
|
||||
private String channelName;
|
||||
private String channelUrl;
|
||||
private boolean overlayVisible = true;
|
||||
private OkHttpClient okHttpClient;
|
||||
private int retryCount = 0;
|
||||
private String lastStreamUrl;
|
||||
private String currentChannelPageUrl;
|
||||
private boolean playbackStarted = false;
|
||||
private boolean alternateSourceAttempted = false;
|
||||
private final Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
private Runnable startupTimeoutRunnable;
|
||||
private final Object resolveLock = new Object();
|
||||
private int resolveGeneration = 0;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
StrictMode.setThreadPolicy(
|
||||
new StrictMode.ThreadPolicy.Builder().permitAll().build()
|
||||
);
|
||||
|
||||
setContentView(R.layout.activity_player);
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
|
||||
@@ -75,11 +77,11 @@ public class PlayerActivity extends AppCompatActivity {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
currentChannelPageUrl = channelUrl;
|
||||
|
||||
initViews();
|
||||
channelLabel.setText(channelName);
|
||||
|
||||
DNSSetter.configureDNSToGoogle(this);
|
||||
loadChannel();
|
||||
}
|
||||
|
||||
@@ -93,67 +95,261 @@ public class PlayerActivity extends AppCompatActivity {
|
||||
|
||||
closeButton.setOnClickListener(v -> finish());
|
||||
playerView.setOnClickListener(v -> toggleOverlay());
|
||||
playerView.setUseController(false);
|
||||
}
|
||||
|
||||
private void loadChannel() {
|
||||
showLoading(true);
|
||||
retryCount = 0;
|
||||
alternateSourceAttempted = false;
|
||||
currentChannelPageUrl = channelUrl;
|
||||
loadChannelFromPageUrl(channelUrl);
|
||||
}
|
||||
|
||||
private void loadChannelFromPageUrl(String pageUrl) {
|
||||
currentChannelPageUrl = pageUrl;
|
||||
final int requestGeneration;
|
||||
synchronized (resolveLock) {
|
||||
resolveGeneration++;
|
||||
requestGeneration = resolveGeneration;
|
||||
}
|
||||
|
||||
Log.d(TAG, "Resolviendo stream desde: " + pageUrl + " (req=" + requestGeneration + ")");
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
String resolvedUrl = StreamUrlResolver.resolve(channelUrl);
|
||||
runOnUiThread(() -> startPlayback(resolvedUrl));
|
||||
String resolvedUrl = StreamUrlResolver.resolve(pageUrl);
|
||||
Log.d(TAG, "Stream resuelto: " + resolvedUrl + " (req=" + requestGeneration + ")");
|
||||
runOnUiThread(() -> {
|
||||
if (!isLatestResolveRequest(requestGeneration)) {
|
||||
Log.d(TAG, "Ignorando resultado viejo (req=" + requestGeneration + ")");
|
||||
return;
|
||||
}
|
||||
startPlayback(resolvedUrl);
|
||||
});
|
||||
} catch (IOException e) {
|
||||
runOnUiThread(() -> showError("No se pudo conectar con el canal: " + e.getMessage()));
|
||||
runOnUiThread(() -> {
|
||||
if (!isLatestResolveRequest(requestGeneration)) {
|
||||
return;
|
||||
}
|
||||
if (!tryAlternateSource("No se pudo conectar con el canal. " + e.getMessage())) {
|
||||
showError("No se pudo conectar con el canal: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
runOnUiThread(() -> showError("Error inesperado: " + e.getMessage()));
|
||||
runOnUiThread(() -> {
|
||||
if (!isLatestResolveRequest(requestGeneration)) {
|
||||
return;
|
||||
}
|
||||
if (!tryAlternateSource("Error inesperado al resolver stream. " + e.getMessage())) {
|
||||
showError("Error inesperado: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private boolean isLatestResolveRequest(int requestGeneration) {
|
||||
synchronized (resolveLock) {
|
||||
return requestGeneration == resolveGeneration;
|
||||
}
|
||||
}
|
||||
|
||||
private void startPlayback(String streamUrl) {
|
||||
try {
|
||||
releasePlayer();
|
||||
DefaultRenderersFactory renderersFactory = new DefaultRenderersFactory(this)
|
||||
.setEnableDecoderFallback(true)
|
||||
.setExtensionRendererMode(DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON);
|
||||
player = new ExoPlayer.Builder(this, renderersFactory)
|
||||
.setSeekForwardIncrementMs(10_000)
|
||||
.setSeekBackIncrementMs(10_000)
|
||||
.build();
|
||||
lastStreamUrl = streamUrl;
|
||||
retryCount = 0;
|
||||
playbackStarted = false;
|
||||
scheduleStartupTimeout();
|
||||
Log.d(TAG, "Iniciando reproducción: " + streamUrl);
|
||||
|
||||
DefaultHttpDataSource.Factory httpFactory = new DefaultHttpDataSource.Factory()
|
||||
.setUserAgent(VlcPlayerConfig.USER_AGENT)
|
||||
.setAllowCrossProtocolRedirects(true)
|
||||
.setConnectTimeoutMs(15000)
|
||||
.setReadTimeoutMs(20000);
|
||||
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("User-Agent", VlcPlayerConfig.USER_AGENT);
|
||||
httpFactory.setDefaultRequestProperties(headers);
|
||||
|
||||
HlsMediaSource mediaSource = new HlsMediaSource.Factory(httpFactory)
|
||||
.setAllowChunklessPreparation(true)
|
||||
.createMediaSource(MediaItem.fromUri(Uri.parse(streamUrl)));
|
||||
|
||||
player = new ExoPlayer.Builder(this).build();
|
||||
playerView.setPlayer(player);
|
||||
setupPlayerListener();
|
||||
|
||||
player.addListener(new Player.Listener() {
|
||||
@Override
|
||||
public void onPlaybackStateChanged(int playbackState) {
|
||||
if (playbackState == Player.STATE_READY) {
|
||||
player.setMediaSource(mediaSource);
|
||||
player.prepare();
|
||||
player.play();
|
||||
setOverlayVisible(false);
|
||||
} catch (Exception e) {
|
||||
cancelStartupTimeout();
|
||||
Log.e(TAG, "Error al iniciar reproducción", e);
|
||||
if (!tryAlternateSource("Error al inicializar reproductor. Probando fuente alterna...")) {
|
||||
showError("Error al inicializar reproductor: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setupPlayerListener() {
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.addListener(new Player.Listener() {
|
||||
@Override
|
||||
public void onPlaybackStateChanged(int playbackState) {
|
||||
switch (playbackState) {
|
||||
case Player.STATE_BUFFERING:
|
||||
Log.d(TAG, "Exo Event: BUFFERING");
|
||||
runOnUiThread(() -> showLoading(true));
|
||||
break;
|
||||
case Player.STATE_READY:
|
||||
Log.d(TAG, "Exo Event: READY");
|
||||
runOnUiThread(() -> {
|
||||
playbackStarted = true;
|
||||
cancelStartupTimeout();
|
||||
showLoading(false);
|
||||
retryCount = 0;
|
||||
});
|
||||
break;
|
||||
case Player.STATE_ENDED:
|
||||
Log.d(TAG, "Exo Event: ENDED");
|
||||
runOnUiThread(() -> {
|
||||
cancelStartupTimeout();
|
||||
finish();
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIsPlayingChanged(boolean isPlaying) {
|
||||
Log.d(TAG, "Exo Event: isPlaying=" + isPlaying);
|
||||
if (isPlaying) {
|
||||
runOnUiThread(() -> {
|
||||
playbackStarted = true;
|
||||
cancelStartupTimeout();
|
||||
showLoading(false);
|
||||
} else if (playbackState == Player.STATE_BUFFERING) {
|
||||
showLoading(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerError(PlaybackException error) {
|
||||
String detail = error.getCause() != null ?
|
||||
error.getCause().getMessage() : "";
|
||||
showError("Error al reproducir: " + error.getMessage() + " " + detail);
|
||||
}
|
||||
@Override
|
||||
public void onPlayerError(PlaybackException error) {
|
||||
String message = error.getMessage() != null
|
||||
? error.getMessage()
|
||||
: "code=" + error.errorCode;
|
||||
Log.e(TAG, "Exo Error: " + message, error);
|
||||
runOnUiThread(() -> {
|
||||
cancelStartupTimeout();
|
||||
handlePlaybackError("Error de reproducción Exo: " + message);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void handlePlaybackError(String errorMsg) {
|
||||
if (tryAlternateSource("Falló la reproducción. " + errorMsg)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String lower = errorMsg.toLowerCase(Locale.ROOT);
|
||||
boolean isRetryableError =
|
||||
lower.contains("404") ||
|
||||
lower.contains("403") ||
|
||||
lower.contains("timeout") ||
|
||||
lower.contains("network") ||
|
||||
lower.contains("connection") ||
|
||||
lower.contains("source");
|
||||
|
||||
if (isRetryableError && retryCount < VlcPlayerConfig.MAX_RETRIES) {
|
||||
retryCount++;
|
||||
runOnUiThread(() -> {
|
||||
showLoading(true);
|
||||
errorMessage.setVisibility(View.VISIBLE);
|
||||
errorMessage.setText(getString(R.string.player_retrying, retryCount, VlcPlayerConfig.MAX_RETRIES));
|
||||
});
|
||||
|
||||
MediaItem mediaItem = MediaItem.fromUri(streamUrl);
|
||||
player.setMediaSource(buildMediaSource(mediaItem));
|
||||
player.prepare();
|
||||
player.setPlayWhenReady(true);
|
||||
setOverlayVisible(false);
|
||||
|
||||
} catch (Exception e) {
|
||||
showError("Error al inicializar reproductor: " + e.getMessage());
|
||||
mainHandler.postDelayed(() -> {
|
||||
if (lastStreamUrl != null) {
|
||||
startPlayback(lastStreamUrl);
|
||||
} else {
|
||||
loadChannel();
|
||||
}
|
||||
}, 1500);
|
||||
} else {
|
||||
String finalMessage = "Error al reproducir: " + errorMsg;
|
||||
if (retryCount >= VlcPlayerConfig.MAX_RETRIES) {
|
||||
finalMessage += "\n\nSe agotaron los reintentos (" + VlcPlayerConfig.MAX_RETRIES + ").";
|
||||
}
|
||||
showError(finalMessage);
|
||||
}
|
||||
}
|
||||
|
||||
private void scheduleStartupTimeout() {
|
||||
cancelStartupTimeout();
|
||||
startupTimeoutRunnable = () -> {
|
||||
if (!playbackStarted) {
|
||||
Log.w(TAG, "Timeout de inicio de reproducción");
|
||||
if (!tryAlternateSource("El canal no inició a tiempo. Probando fuente alterna...")) {
|
||||
handlePlaybackError("Timeout al iniciar stream");
|
||||
}
|
||||
}
|
||||
};
|
||||
mainHandler.postDelayed(startupTimeoutRunnable, STARTUP_TIMEOUT_MS);
|
||||
}
|
||||
|
||||
private void cancelStartupTimeout() {
|
||||
if (startupTimeoutRunnable != null) {
|
||||
mainHandler.removeCallbacks(startupTimeoutRunnable);
|
||||
startupTimeoutRunnable = null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean tryAlternateSource(String reason) {
|
||||
if (alternateSourceAttempted) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String alternateUrl = buildAlternateGlobalUrl(currentChannelPageUrl);
|
||||
if (alternateUrl == null || alternateUrl.equals(currentChannelPageUrl)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
alternateSourceAttempted = true;
|
||||
Log.w(TAG, "Probando fuente alterna: " + alternateUrl + " | motivo: " + reason);
|
||||
|
||||
showLoading(true);
|
||||
errorMessage.setVisibility(View.VISIBLE);
|
||||
errorMessage.setText("Problema con la fuente actual.\nProbando fuente alterna...");
|
||||
loadChannelFromPageUrl(alternateUrl);
|
||||
return true;
|
||||
}
|
||||
|
||||
private String buildAlternateGlobalUrl(String url) {
|
||||
if (url == null || url.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (url.contains("global2.php")) {
|
||||
return url.replace("global2.php", "global1.php");
|
||||
}
|
||||
if (url.contains("global1.php")) {
|
||||
return url.replace("global1.php", "global2.php");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void showLoading(boolean show) {
|
||||
loadingIndicator.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
errorMessage.setVisibility(View.GONE);
|
||||
playerView.setVisibility(show ? View.GONE : View.VISIBLE);
|
||||
playerView.setVisibility(View.VISIBLE);
|
||||
if (show) {
|
||||
setOverlayVisible(true);
|
||||
}
|
||||
@@ -168,68 +364,20 @@ public class PlayerActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private void releasePlayer() {
|
||||
cancelStartupTimeout();
|
||||
playbackStarted = false;
|
||||
if (player != null) {
|
||||
player.release();
|
||||
player = null;
|
||||
}
|
||||
}
|
||||
|
||||
private MediaSource buildMediaSource(MediaItem mediaItem) {
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Referer", channelUrl);
|
||||
headers.put("Origin", "https://streamtpcloud.com");
|
||||
headers.put("Accept", "*/*");
|
||||
headers.put("Connection", "keep-alive");
|
||||
|
||||
String userAgent = Util.getUserAgent(this, "StreamPlayer");
|
||||
|
||||
OkHttpDataSource.Factory factory = new OkHttpDataSource.Factory(provideOkHttpClient())
|
||||
.setUserAgent(userAgent)
|
||||
.setDefaultRequestProperties(headers);
|
||||
return new HlsMediaSource.Factory(factory).createMediaSource(mediaItem);
|
||||
}
|
||||
|
||||
private OkHttpClient provideOkHttpClient() {
|
||||
if (okHttpClient != null) {
|
||||
return okHttpClient;
|
||||
}
|
||||
|
||||
try {
|
||||
OkHttpClient bootstrap = new OkHttpClient.Builder()
|
||||
.connectTimeout(15, TimeUnit.SECONDS)
|
||||
.readTimeout(15, TimeUnit.SECONDS)
|
||||
.retryOnConnectionFailure(true)
|
||||
.build();
|
||||
|
||||
DnsOverHttps dohDns = new DnsOverHttps.Builder()
|
||||
.client(bootstrap)
|
||||
.url(HttpUrl.get("https://dns.google/dns-query"))
|
||||
.bootstrapDnsHosts(
|
||||
InetAddress.getByName("8.8.8.8"),
|
||||
InetAddress.getByName("8.8.4.4"))
|
||||
.build();
|
||||
|
||||
okHttpClient = bootstrap.newBuilder()
|
||||
.dns(dohDns)
|
||||
.build();
|
||||
} catch (UnknownHostException e) {
|
||||
okHttpClient = new OkHttpClient.Builder()
|
||||
.connectTimeout(15, TimeUnit.SECONDS)
|
||||
.readTimeout(15, TimeUnit.SECONDS)
|
||||
.retryOnConnectionFailure(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
return okHttpClient;
|
||||
playerView.setPlayer(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
if (player != null) {
|
||||
playerView.onResume();
|
||||
} else if (channelUrl != null) {
|
||||
loadChannel();
|
||||
if (player != null && !player.isPlaying()) {
|
||||
player.play();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,7 +385,7 @@ public class PlayerActivity extends AppCompatActivity {
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (player != null) {
|
||||
playerView.onResume();
|
||||
player.play();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,18 +393,19 @@ public class PlayerActivity extends AppCompatActivity {
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
if (player != null) {
|
||||
playerView.onPause();
|
||||
player.pause();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
releasePlayer();
|
||||
// Keep player for quick resume.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
mainHandler.removeCallbacksAndMessages(null);
|
||||
super.onDestroy();
|
||||
releasePlayer();
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
|
||||
@@ -1,86 +1,312 @@
|
||||
package com.streamplayer;
|
||||
|
||||
import android.util.Base64;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.dnsoverhttps.DnsOverHttps;
|
||||
|
||||
/**
|
||||
* Resuelve la URL real del stream extrayendo playbackURL de la página.
|
||||
* Utiliza DNS de Google para evitar bloqueos.
|
||||
* Utiliza DNS over HTTPS (Google + Cloudflare) para evitar bloqueos.
|
||||
* Soporta múltiples formatos de páginas y streams directos.
|
||||
* Incluye fallback para páginas con JWPlayer y formatos ofuscados.
|
||||
*/
|
||||
public final class StreamUrlResolver {
|
||||
|
||||
// Patrón para extraer la URL del stream directamente
|
||||
// Patrón original para streamtp10.com
|
||||
private static final Pattern PLAYBACK_URL_PATTERN =
|
||||
Pattern.compile("var\\s+playbackURL\\s*=\\s*[\"']([^\"']+)[\"']");
|
||||
|
||||
private static final String USER_AGENT = "Mozilla/5.0 (Linux; Android 13; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36";
|
||||
// Patrón para source src en tags video
|
||||
private static final Pattern VIDEO_SOURCE_PATTERN =
|
||||
Pattern.compile("<source[^>]+src=[\"']([^\"']+)[\"']");
|
||||
|
||||
private static final OkHttpClient CLIENT;
|
||||
// Patrón para URLs M3U8 en cualquier parte del HTML
|
||||
private static final Pattern M3U8_URL_PATTERN =
|
||||
Pattern.compile("(https?://[^\\s'\"<>]+\\.m3u8[^\\s'\"<>]*)");
|
||||
|
||||
static {
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder()
|
||||
.connectTimeout(15, TimeUnit.SECONDS)
|
||||
.readTimeout(15, TimeUnit.SECONDS)
|
||||
.followRedirects(true);
|
||||
// Patrón para URLs de stream en comillas dobles o simples
|
||||
private static final Pattern STREAM_URL_PATTERN =
|
||||
Pattern.compile("['\"](https?://[^'\"<>\\s]+?\\.(?:m3u8|mp4|ts)[^'\"<>\\s]*)['\"]");
|
||||
|
||||
try {
|
||||
// DNS de Google (8.8.8.8)
|
||||
OkHttpClient bootstrap = new OkHttpClient.Builder().build();
|
||||
DnsOverHttps dns = new DnsOverHttps.Builder()
|
||||
.client(bootstrap)
|
||||
.url(HttpUrl.get("https://dns.google/dns-query"))
|
||||
.bootstrapDnsHosts(
|
||||
InetAddress.getByName("8.8.8.8"),
|
||||
InetAddress.getByName("8.8.4.4"))
|
||||
.build();
|
||||
builder.dns(dns);
|
||||
} catch (UnknownHostException e) {
|
||||
// Fallback a DNS del sistema
|
||||
}
|
||||
// Patrón para file: o url: en JavaScript
|
||||
private static final Pattern JS_URL_PATTERN =
|
||||
Pattern.compile("(?:file|url|stream|source)\\s*[:=]\\s*[\"'](https?://[^\"']+)[\"']",
|
||||
Pattern.CASE_INSENSITIVE);
|
||||
|
||||
CLIENT = builder.build();
|
||||
}
|
||||
// Patrón para JWPlayer sources con "file": "url"
|
||||
private static final Pattern JWPLAYER_FILE_PATTERN =
|
||||
Pattern.compile("\"file\"\\s*:\\s*\"([^\"]+\\.m3u8[^\"]*)\"");
|
||||
|
||||
// Patrón para pares [indice, "base64"] del nuevo playbackURL ofuscado
|
||||
private static final Pattern OBFUSCATED_PAIR_PATTERN =
|
||||
Pattern.compile("\\[(\\d+)\\s*,\\s*[\"']([^\"']+)[\"']\\]");
|
||||
|
||||
// Patrón para k = fn1() + fn2()
|
||||
private static final Pattern OBFUSCATED_K_PATTERN =
|
||||
Pattern.compile("var\\s+k\\s*=\\s*([A-Za-z_$][\\w$]*)\\(\\)\\s*\\+\\s*([A-Za-z_$][\\w$]*)\\(\\)");
|
||||
|
||||
// Patrón para function fn() { return 12345; }
|
||||
private static final Pattern JS_RETURN_NUMBER_FUNCTION_PATTERN =
|
||||
Pattern.compile("function\\s+([A-Za-z_$][\\w$]*)\\s*\\(\\)\\s*\\{\\s*return\\s*(\\d+)\\s*;?\\s*\\}",
|
||||
Pattern.DOTALL);
|
||||
|
||||
private StreamUrlResolver() {
|
||||
}
|
||||
|
||||
public static String resolve(String pageUrl) throws IOException {
|
||||
// Primero verificar si la URL ya parece ser un stream directo
|
||||
if (isDirectStreamUrl(pageUrl)) {
|
||||
return pageUrl;
|
||||
}
|
||||
|
||||
String html = downloadPage(pageUrl);
|
||||
|
||||
// Buscar playbackURL directamente en el HTML
|
||||
Matcher matcher = PLAYBACK_URL_PATTERN.matcher(html);
|
||||
if (matcher.find()) {
|
||||
String url = matcher.group(1);
|
||||
if (url != null && !url.isEmpty() && url.startsWith("http")) {
|
||||
return url;
|
||||
}
|
||||
// Si el contenido ya parece ser un stream M3U8, retornarlo directamente
|
||||
if (html.startsWith("#EXTM3U") || html.startsWith("#EXT")) {
|
||||
return pageUrl;
|
||||
}
|
||||
|
||||
// Intentar múltiples patrones de extracción
|
||||
String streamUrl = null;
|
||||
|
||||
// 1. Patrón original: var playbackURL = "..."
|
||||
streamUrl = extractWithPattern(html, PLAYBACK_URL_PATTERN);
|
||||
if (isValidStreamUrl(streamUrl)) {
|
||||
return streamUrl;
|
||||
}
|
||||
|
||||
// 2. Patrón: <source src="...">
|
||||
streamUrl = extractWithPattern(html, VIDEO_SOURCE_PATTERN);
|
||||
if (isValidStreamUrl(streamUrl)) {
|
||||
return streamUrl;
|
||||
}
|
||||
|
||||
// 3. Patrón: URLs M3U8 directas
|
||||
streamUrl = extractWithPattern(html, M3U8_URL_PATTERN);
|
||||
if (isValidStreamUrl(streamUrl)) {
|
||||
return streamUrl;
|
||||
}
|
||||
|
||||
// 4. Patrón: URLs de stream en comillas
|
||||
streamUrl = extractWithPattern(html, STREAM_URL_PATTERN);
|
||||
if (isValidStreamUrl(streamUrl)) {
|
||||
return streamUrl;
|
||||
}
|
||||
|
||||
// 5. Patrón: JavaScript file: / url: / stream:
|
||||
streamUrl = extractWithPattern(html, JS_URL_PATTERN);
|
||||
if (isValidStreamUrl(streamUrl)) {
|
||||
return streamUrl;
|
||||
}
|
||||
|
||||
// 6. Patrón: JWPlayer "file": "url.m3u8" (para reproductores web y otros)
|
||||
streamUrl = extractWithPattern(html, JWPLAYER_FILE_PATTERN);
|
||||
if (isValidStreamUrl(streamUrl)) {
|
||||
return streamUrl;
|
||||
}
|
||||
|
||||
// 7. Nuevo formato ofuscado: playbackURL generado con atob + fromCharCode
|
||||
streamUrl = decodeObfuscatedPlaybackUrl(html);
|
||||
if (isValidStreamUrl(streamUrl)) {
|
||||
return streamUrl;
|
||||
}
|
||||
|
||||
// Si no encontramos nada con patrones, intentar usar la URL original
|
||||
// como stream directo (útil para URLs que ya son streams)
|
||||
if (html.contains(".m3u8") || html.contains("stream") || html.contains("video")) {
|
||||
return pageUrl;
|
||||
}
|
||||
|
||||
// Último recurso: si la URL viene de sudamericaplay.com o similares,
|
||||
// intentar usarla directamente
|
||||
if (pageUrl.contains("sudamericaplay.com") ||
|
||||
pageUrl.contains("paramount")) {
|
||||
return pageUrl;
|
||||
}
|
||||
|
||||
// Si no encontramos la URL, mostrar un fragmento del HTML para debug
|
||||
String preview = html.length() > 500 ? html.substring(0, 500) : html;
|
||||
throw new IOException("No se encontró la URL del stream en la página. Vista previa: " + preview);
|
||||
throw new IOException("No se encontró la URL del stream en la página. URL: " + pageUrl + ". Vista previa: " + preview);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodifica páginas donde playbackURL se arma carácter por carácter con:
|
||||
* playbackURL += String.fromCharCode(parseInt(atob(v).replace(/\D/g,'')) - k)
|
||||
*/
|
||||
private static String decodeObfuscatedPlaybackUrl(String html) {
|
||||
if (html == null ||
|
||||
!html.contains("var playbackURL") ||
|
||||
!html.contains("playbackURL+=") ||
|
||||
!html.contains("String.fromCharCode") ||
|
||||
!html.contains("atob(")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int scriptStart = html.indexOf("var playbackURL");
|
||||
if (scriptStart < 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int scriptEnd = html.indexOf("var p2pConfig", scriptStart);
|
||||
if (scriptEnd < 0) {
|
||||
scriptEnd = html.indexOf("</script>", scriptStart);
|
||||
}
|
||||
if (scriptEnd < 0 || scriptEnd <= scriptStart) {
|
||||
scriptEnd = Math.min(html.length(), scriptStart + 20000);
|
||||
}
|
||||
|
||||
String script = html.substring(scriptStart, scriptEnd);
|
||||
|
||||
Matcher kMatcher = OBFUSCATED_K_PATTERN.matcher(script);
|
||||
if (!kMatcher.find()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String functionA = kMatcher.group(1);
|
||||
String functionB = kMatcher.group(2);
|
||||
|
||||
Map<String, Long> functionValues = new HashMap<>();
|
||||
Matcher functionMatcher = JS_RETURN_NUMBER_FUNCTION_PATTERN.matcher(script);
|
||||
while (functionMatcher.find()) {
|
||||
try {
|
||||
functionValues.put(functionMatcher.group(1), Long.parseLong(functionMatcher.group(2)));
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
Long valueA = functionValues.get(functionA);
|
||||
Long valueB = functionValues.get(functionB);
|
||||
if (valueA == null || valueB == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
long k = valueA + valueB;
|
||||
|
||||
List<EncodedPair> pairs = new ArrayList<>();
|
||||
Matcher pairMatcher = OBFUSCATED_PAIR_PATTERN.matcher(script);
|
||||
while (pairMatcher.find()) {
|
||||
try {
|
||||
int index = Integer.parseInt(pairMatcher.group(1));
|
||||
pairs.add(new EncodedPair(index, pairMatcher.group(2)));
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
if (pairs.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Collections.sort(pairs, new Comparator<EncodedPair>() {
|
||||
@Override
|
||||
public int compare(EncodedPair left, EncodedPair right) {
|
||||
return Integer.compare(left.index, right.index);
|
||||
}
|
||||
});
|
||||
StringBuilder decoded = new StringBuilder(pairs.size());
|
||||
|
||||
for (EncodedPair pair : pairs) {
|
||||
byte[] decodedBytes;
|
||||
try {
|
||||
decodedBytes = Base64.decode(pair.encodedValue, Base64.DEFAULT);
|
||||
} catch (IllegalArgumentException e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String decodedText = new String(decodedBytes, StandardCharsets.UTF_8);
|
||||
String digits = decodedText.replaceAll("\\D", "");
|
||||
if (digits.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
long numericValue;
|
||||
try {
|
||||
numericValue = Long.parseLong(digits);
|
||||
} catch (NumberFormatException e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
long charCode = numericValue - k;
|
||||
if (charCode < 0 || charCode > Character.MAX_VALUE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
decoded.append((char) charCode);
|
||||
}
|
||||
|
||||
if (decoded.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String url = decoded.toString().trim()
|
||||
.replace("\\/", "/")
|
||||
.replace("\\u0026", "&")
|
||||
.replace("\\u002F", "/");
|
||||
|
||||
return isValidStreamUrl(url) ? url : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifica si una URL parece ser un stream directo (M3U8, MP4, etc.)
|
||||
*/
|
||||
private static boolean isDirectStreamUrl(String url) {
|
||||
if (url == null || url.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
String lower = url.toLowerCase(Locale.ROOT);
|
||||
return lower.contains(".m3u8") ||
|
||||
lower.contains(".mpd") ||
|
||||
(lower.contains("stream") && !lower.contains(".php")) ||
|
||||
lower.endsWith(".mp4") ||
|
||||
lower.endsWith(".ts");
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifica si una URL extraída es válida
|
||||
*/
|
||||
private static boolean isValidStreamUrl(String url) {
|
||||
return url != null && !url.isEmpty() && url.startsWith("http");
|
||||
}
|
||||
|
||||
/**
|
||||
* Extrae la primera coincidencia de un patrón regex
|
||||
*/
|
||||
private static String extractWithPattern(String html, Pattern pattern) {
|
||||
Matcher matcher = pattern.matcher(html);
|
||||
if (matcher.find()) {
|
||||
String url = matcher.group(1);
|
||||
// Limpiar URL de caracteres basura
|
||||
if (url != null) {
|
||||
url = url.trim();
|
||||
// Remover caracteres especiales al final
|
||||
url = url.replaceAll("[\"'<>\\s].*$", "");
|
||||
}
|
||||
return url;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String downloadPage(String pageUrl) throws IOException {
|
||||
Request request = new Request.Builder()
|
||||
.url(pageUrl)
|
||||
.header("User-Agent", USER_AGENT)
|
||||
.header("User-Agent", NetworkUtils.getUserAgent())
|
||||
.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
|
||||
.header("Accept-Language", "es-ES,es;q=0.9,en;q=0.8")
|
||||
.header("Referer", "https://streamtpcloud.com/")
|
||||
.header("Referer", "http://streamtp10.com/")
|
||||
.build();
|
||||
|
||||
try (Response response = CLIENT.newCall(request).execute()) {
|
||||
try (Response response = NetworkUtils.getClient().newCall(request).execute()) {
|
||||
if (!response.isSuccessful()) {
|
||||
throw new IOException("Error HTTP " + response.code() + " al cargar la página del stream");
|
||||
}
|
||||
@@ -91,4 +317,14 @@ public final class StreamUrlResolver {
|
||||
return response.body().string();
|
||||
}
|
||||
}
|
||||
|
||||
private static final class EncodedPair {
|
||||
final int index;
|
||||
final String encodedValue;
|
||||
|
||||
EncodedPair(int index, String encodedValue) {
|
||||
this.index = index;
|
||||
this.encodedValue = encodedValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
@@ -31,7 +32,6 @@ import java.lang.ref.WeakReference;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
@@ -63,11 +63,8 @@ public class UpdateManager {
|
||||
this.appContext = context.getApplicationContext();
|
||||
this.mainHandler = new Handler(Looper.getMainLooper());
|
||||
this.networkExecutor = Executors.newSingleThreadExecutor();
|
||||
this.httpClient = new OkHttpClient.Builder()
|
||||
.connectTimeout(15, TimeUnit.SECONDS)
|
||||
.readTimeout(20, TimeUnit.SECONDS)
|
||||
.callTimeout(25, TimeUnit.SECONDS)
|
||||
.build();
|
||||
// Usar NetworkUtils para obtener cliente con DNS over HTTPS configurado
|
||||
this.httpClient = NetworkUtils.getClient();
|
||||
}
|
||||
|
||||
public void checkForUpdates(UpdateCallback callback) {
|
||||
@@ -120,7 +117,7 @@ public class UpdateManager {
|
||||
return;
|
||||
}
|
||||
File targetDir = appContext.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
|
||||
if (targetDir == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
if (targetDir == null) {
|
||||
targetDir = appContext.getExternalFilesDir(null);
|
||||
}
|
||||
if (targetDir == null) {
|
||||
@@ -276,21 +273,27 @@ public class UpdateManager {
|
||||
if (assets == null) {
|
||||
return null;
|
||||
}
|
||||
JSONObject fallback = null;
|
||||
JSONObject firstApk = null;
|
||||
JSONObject debugApk = null;
|
||||
for (int i = 0; i < assets.length(); i++) {
|
||||
JSONObject asset = assets.optJSONObject(i);
|
||||
if (asset == null) {
|
||||
continue;
|
||||
}
|
||||
if (fallback == null) {
|
||||
fallback = asset;
|
||||
}
|
||||
String name = asset.optString("name", "").toLowerCase(Locale.US);
|
||||
if (name.endsWith(".apk")) {
|
||||
return asset;
|
||||
if (name.contains("release")) {
|
||||
return asset;
|
||||
}
|
||||
if (firstApk == null) {
|
||||
firstApk = asset;
|
||||
}
|
||||
if (name.contains("debug") && debugApk == null) {
|
||||
debugApk = asset;
|
||||
}
|
||||
}
|
||||
}
|
||||
return fallback;
|
||||
return firstApk != null ? firstApk : debugApk;
|
||||
}
|
||||
|
||||
private String deriveVersionName(String tagName, String fallback) {
|
||||
@@ -366,7 +369,12 @@ public class UpdateManager {
|
||||
}
|
||||
downloadReceiver = new DownloadReceiver();
|
||||
IntentFilter filter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
|
||||
appContext.registerReceiver(downloadReceiver, filter);
|
||||
ContextCompat.registerReceiver(
|
||||
appContext,
|
||||
downloadReceiver,
|
||||
filter,
|
||||
ContextCompat.RECEIVER_NOT_EXPORTED
|
||||
);
|
||||
}
|
||||
|
||||
private void unregisterDownloadReceiver() {
|
||||
@@ -443,7 +451,10 @@ public class UpdateManager {
|
||||
if (callback == null) {
|
||||
return;
|
||||
}
|
||||
mainHandler.post(() -> callback.onError(message));
|
||||
String safeMessage = TextUtils.isEmpty(message)
|
||||
? appContext.getString(R.string.update_error_unknown)
|
||||
: message;
|
||||
mainHandler.post(() -> callback.onError(safeMessage));
|
||||
}
|
||||
|
||||
private void showToast(String message) {
|
||||
@@ -536,4 +547,3 @@ public class UpdateManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
14
app/src/main/java/com/streamplayer/VlcPlayerConfig.java
Normal file
14
app/src/main/java/com/streamplayer/VlcPlayerConfig.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.streamplayer;
|
||||
|
||||
public final class VlcPlayerConfig {
|
||||
|
||||
// User Agent
|
||||
public static final String USER_AGENT =
|
||||
"Mozilla/5.0 (Linux; Android 13; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36";
|
||||
|
||||
// Maximum retries for playback
|
||||
public static final int MAX_RETRIES = 3;
|
||||
|
||||
private VlcPlayerConfig() {
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_selected="true">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#18d763" />
|
||||
<corners android:radius="20dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_focused="true">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#5522c1ff" />
|
||||
<corners android:radius="20dp" />
|
||||
<stroke
|
||||
android:width="2dp"
|
||||
android:color="#88FFFFFF" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_pressed="true">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#3322c1ff" />
|
||||
<corners android:radius="20dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#222222" />
|
||||
<corners android:radius="20dp" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#44FFFFFF" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
45
app/src/main/res/drawable/btn_refresh_selector.xml
Normal file
45
app/src/main/res/drawable/btn_refresh_selector.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- Focused state - bright amber with thick border -->
|
||||
<item android:state_focused="true">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/refresh_button_focused" />
|
||||
<corners android:radius="8dp" />
|
||||
<stroke
|
||||
android:width="4dp"
|
||||
android:color="@color/refresh_button_focused_border" />
|
||||
<padding
|
||||
android:left="12dp"
|
||||
android:top="8dp"
|
||||
android:right="12dp"
|
||||
android:bottom="8dp" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<!-- Pressed state -->
|
||||
<item android:state_pressed="true">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/refresh_button_pressed" />
|
||||
<corners android:radius="8dp" />
|
||||
<stroke
|
||||
android:width="2dp"
|
||||
android:color="@color/refresh_button_border" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<!-- Default state - darker background with subtle border -->
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/refresh_button_default" />
|
||||
<corners android:radius="8dp" />
|
||||
<stroke
|
||||
android:width="2dp"
|
||||
android:color="@color/refresh_button_border" />
|
||||
<padding
|
||||
android:left="12dp"
|
||||
android:top="8dp"
|
||||
android:right="12dp"
|
||||
android:bottom="8dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 850 B |
7
app/src/main/res/drawable/scrollbar_vertical.xml
Normal file
7
app/src/main/res/drawable/scrollbar_vertical.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="#FFFFFFFF" />
|
||||
<corners android:radius="6dp" />
|
||||
<size android:width="12dp" />
|
||||
</shape>
|
||||
@@ -72,14 +72,37 @@
|
||||
app:layout_constraintStart_toEndOf="@id/divider"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/content_title"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
tools:text="Canales" />
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/content_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
tools:text="Canales" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/refresh_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="36dp"
|
||||
android:text="@string/action_refresh"
|
||||
android:textAllCaps="false"
|
||||
android:textSize="12sp"
|
||||
android:visibility="gone"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:background="@drawable/btn_refresh_selector"
|
||||
android:textColor="@color/white"
|
||||
android:elevation="2dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/loading_indicator"
|
||||
@@ -105,6 +128,14 @@
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_weight="1"
|
||||
android:overScrollMode="never"
|
||||
android:scrollbars="vertical"
|
||||
android:fadeScrollbars="false"
|
||||
android:scrollbarStyle="insideInset"
|
||||
android:scrollbarThumbVertical="@drawable/scrollbar_vertical"
|
||||
android:scrollbarTrackVertical="@color/scrollbar_track"
|
||||
android:scrollbarSize="12dp"
|
||||
android:scrollbarAlwaysDrawVerticalTrack="true"
|
||||
android:scrollbarFadeDuration="0"
|
||||
android:nextFocusLeft="@id/section_list"
|
||||
tools:listitem="@layout/item_channel" />
|
||||
</LinearLayout>
|
||||
|
||||
@@ -7,12 +7,14 @@
|
||||
android:background="@color/black"
|
||||
tools:context=".PlayerActivity">
|
||||
|
||||
<com.google.android.exoplayer2.ui.PlayerView
|
||||
<androidx.media3.ui.PlayerView
|
||||
android:id="@+id/player_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:resize_mode="fill"
|
||||
app:use_controller="true" />
|
||||
android:keepScreenOn="true"
|
||||
app:show_buffering="never"
|
||||
app:surface_type="surface_view"
|
||||
app:use_controller="false" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/player_toolbar"
|
||||
@@ -32,7 +34,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Canal"
|
||||
android:text="@string/player_channel_default"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
@@ -41,7 +43,7 @@
|
||||
android:id="@+id/close_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Elegir otro"
|
||||
android:text="@string/player_action_choose_other"
|
||||
android:textAllCaps="false" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="6dp"
|
||||
@@ -16,8 +17,8 @@
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:contentDescription="@string/app_name"
|
||||
android:tint="@color/white"
|
||||
android:src="@drawable/ic_channel_default" />
|
||||
android:src="@drawable/ic_channel_default"
|
||||
app:tint="@color/white" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/channel_name"
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
android:id="@+id/event_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingStart="8dp"
|
||||
android:textColor="#18d763"
|
||||
android:textSize="14sp"
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="channel_entries">
|
||||
<item>Azteca Deportes</item>
|
||||
<item>Canal 5 MX</item>
|
||||
<item>Caliente TV MX</item>
|
||||
<item>DAZN 1</item>
|
||||
<item>DAZN 2</item>
|
||||
<item>DAZN LaLiga</item>
|
||||
<item>DSports</item>
|
||||
<item>DSports 2</item>
|
||||
<item>DSports Plus</item>
|
||||
<item>ESPN</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
@@ -3,4 +3,14 @@
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
<color name="text_secondary">#B3FFFFFF</color>
|
||||
|
||||
<!-- Refresh button colors -->
|
||||
<color name="refresh_button_default">#2A2A2A</color>
|
||||
<color name="refresh_button_border">#4A4A4A</color>
|
||||
<color name="refresh_button_focused">#FFC107</color>
|
||||
<color name="refresh_button_focused_border">#FFD54F</color>
|
||||
<color name="refresh_button_pressed">#FF9800</color>
|
||||
|
||||
<!-- Scrollbar -->
|
||||
<color name="scrollbar_track">#1A1A1A</color>
|
||||
</resources>
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
<resources>
|
||||
<string name="app_name">StreamPlayer</string>
|
||||
<string name="home_tagline">Todo el deporte en un solo lugar</string>
|
||||
<string name="section_channels">Canales</string>
|
||||
<string name="section_events">Eventos</string>
|
||||
<string name="section_all_channels">Todos los canales</string>
|
||||
<string name="message_no_channels">No hay canales disponibles</string>
|
||||
<string name="message_no_events">No hay eventos disponibles</string>
|
||||
<string name="action_refresh">Actualizar</string>
|
||||
<string name="message_events_error">No se pudieron cargar los eventos: %1$s</string>
|
||||
<string name="player_channel_default">Canal</string>
|
||||
<string name="player_action_choose_other">Elegir otro</string>
|
||||
<string name="player_retrying">Error de conexión. Reintentando... (%1$d/%2$d)</string>
|
||||
<string name="update_required_title">Actualización obligatoria</string>
|
||||
<string name="update_available_title">Actualización disponible</string>
|
||||
<string name="update_action_download">Actualizar</string>
|
||||
@@ -21,6 +24,7 @@
|
||||
<string name="update_release_notes_title">Novedades</string>
|
||||
<string name="update_optional_hint">Puedes continuar usando la app, pero recomendamos instalar la actualización para obtener el mejor rendimiento.</string>
|
||||
<string name="update_error_checking">No se pudo verificar actualizaciones (%1$s)</string>
|
||||
<string name="update_error_unknown">Error desconocido</string>
|
||||
<string name="update_error_open_release">No se pudo abrir el detalle de la versión</string>
|
||||
<string name="update_error_empty_response">Respuesta vacía del servidor de releases</string>
|
||||
<string name="update_error_http">Error de red (%1$d)</string>
|
||||
@@ -39,7 +43,6 @@
|
||||
<string name="device_blocked_title">Dispositivo bloqueado</string>
|
||||
<string name="device_blocked_message">Este dispositivo fue bloqueado desde el panel de control. Motivo: %1$s</string>
|
||||
<string name="device_blocked_default_reason">Sin motivo especificado.</string>
|
||||
<string name="device_blocked_token_hint">Comparte este código con el administrador para solicitar acceso: %1$s</string>
|
||||
<string name="device_blocked_token_label">Código de verificación</string>
|
||||
<string name="device_blocked_close">Salir</string>
|
||||
<string name="device_blocked_copy_token">Copiar código</string>
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample backup rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/guide/topics/data/autobackup
|
||||
for details.
|
||||
Note: This file is ignored for devices older that API 23, even
|
||||
if they have auto backup available.
|
||||
-->
|
||||
<full-backup-content>
|
||||
<!--
|
||||
<include domain="sharedpref" path="."/>
|
||||
<exclude domain="sharedpref" path="device.xml"/>
|
||||
-->
|
||||
<exclude domain="sharedpref" path="." />
|
||||
</full-backup-content>
|
||||
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample data extraction rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||
for details.
|
||||
-->
|
||||
<data-extraction-rules>
|
||||
<cloud-backup>
|
||||
<!--
|
||||
<include domain="file" path="."/>
|
||||
<exclude domain="file" path="no_backup/"/>
|
||||
-->
|
||||
<exclude domain="sharedpref" path="." />
|
||||
</cloud-backup>
|
||||
<!--
|
||||
<device-transfer>
|
||||
<include domain="file" path="."/>
|
||||
<exclude domain="file" path="no_backup/"/>
|
||||
</device-transfer>
|
||||
-->
|
||||
</data-extraction-rules>
|
||||
77
create_release.py
Normal file
77
create_release.py
Normal file
@@ -0,0 +1,77 @@
|
||||
import json
|
||||
import urllib.request
|
||||
import urllib.parse
|
||||
import urllib.error
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Configuration
|
||||
GITEA_URL = "https://gitea.cbcren.online/api/v1"
|
||||
REPO_OWNER = "renato97"
|
||||
REPO_NAME = "app"
|
||||
TOKEN = "efeed2af00597883adb04da70bd6a7c2993ae92d"
|
||||
TAG_NAME = "v10.1.7"
|
||||
RELEASE_NAME = "StreamPlayer v10.1.7"
|
||||
CHANGELOG_FILE = "CHANGELOG-v10.1.7.md"
|
||||
APK_FILE = "StreamPlayer-10.1.7-debug.apk"
|
||||
|
||||
def create_release():
|
||||
try:
|
||||
with open(CHANGELOG_FILE, 'r') as f:
|
||||
body = f.read()
|
||||
except FileNotFoundError:
|
||||
print(f"Error: {CHANGELOG_FILE} not found.")
|
||||
sys.exit(1)
|
||||
|
||||
url = f"{GITEA_URL}/repos/{REPO_OWNER}/{REPO_NAME}/releases"
|
||||
headers = {
|
||||
"Authorization": f"token {TOKEN}",
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json"
|
||||
}
|
||||
data = {
|
||||
"tag_name": TAG_NAME,
|
||||
"target_commitish": "main",
|
||||
"name": RELEASE_NAME,
|
||||
"body": body,
|
||||
"draft": False,
|
||||
"prerelease": False
|
||||
}
|
||||
|
||||
req = urllib.request.Request(url, data=json.dumps(data).encode('utf-8'), headers=headers, method='POST')
|
||||
|
||||
try:
|
||||
with urllib.request.urlopen(req) as response:
|
||||
result = json.loads(response.read().decode('utf-8'))
|
||||
print(f"Release created successfully. ID: {result['id']}")
|
||||
return result['id']
|
||||
except urllib.error.HTTPError as e:
|
||||
print(f"HTTP Error creating release: {e.code} {e.reason}")
|
||||
print(e.read().decode('utf-8'))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(f"Error creating release: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
def upload_asset(release_id):
|
||||
if not os.path.exists(APK_FILE):
|
||||
print(f"Error: APK file {APK_FILE} not found.")
|
||||
sys.exit(1)
|
||||
|
||||
url = f"{GITEA_URL}/repos/{REPO_OWNER}/{REPO_NAME}/releases/{release_id}/assets"
|
||||
|
||||
# Simple multipart upload via python is tricky without requests library.
|
||||
# However, Gitea API usually accepts raw binary in body if Content-Type is set,
|
||||
# but Gitea's API for assets usually requires multipart/form-data.
|
||||
# Let's check Gitea API docs...
|
||||
# The standard Gitea API uses POST /repos/{owner}/{repo}/releases/{id}/assets with name query parameter and file content in body
|
||||
# Wait, looking at Gitea API docs (swagger usually available at /api/swagger),
|
||||
# POST /repos/{owner}/{repo}/releases/{id}/assets takes 'attachment' as form-data.
|
||||
|
||||
# Implementing multipart/form-data with urllib is painful.
|
||||
# Instead, I will use curl to upload the asset, using the release ID obtained from Python.
|
||||
return release_id
|
||||
|
||||
if __name__ == "__main__":
|
||||
release_id = create_release()
|
||||
print(f"RELEASE_ID={release_id}")
|
||||
171
event-repository-fix.patch
Normal file
171
event-repository-fix.patch
Normal file
@@ -0,0 +1,171 @@
|
||||
diff --git a/app/src/main/java/com/streamplayer/EventRepository.java b/app/src/main/java/com/streamplayer/EventRepository.java
|
||||
index f9340c7..7b3f662 100644
|
||||
--- a/app/src/main/java/com/streamplayer/EventRepository.java
|
||||
+++ b/app/src/main/java/com/streamplayer/EventRepository.java
|
||||
@@ -29,8 +29,17 @@ public class EventRepository {
|
||||
private static final String PREFS_NAME = "events_cache";
|
||||
private static final String KEY_JSON = "json";
|
||||
private static final String KEY_TIMESTAMP = "timestamp";
|
||||
+ private static final String KEY_WORKING_URL = "working_url";
|
||||
private static final long CACHE_DURATION = 24L * 60 * 60 * 1000; // 24 horas
|
||||
- private static final String EVENTS_URL = "https://streamtpcloud.com/eventos.json";
|
||||
+
|
||||
+ // Lista de URLs a intentar en orden (con sistema de fallback)
|
||||
+ private static final String[] EVENT_URLS = {
|
||||
+ "https://streamtpcloud.com/eventos.json", // URL original
|
||||
+ "https://streamtp10.com/eventos.json", // URL actual
|
||||
+ "https://streamtpmedia.com/eventos.json" // URL anterior
|
||||
+ };
|
||||
+
|
||||
+ private static final String DEFAULT_EVENTS_URL = "https://streamtpcloud.com/eventos.json";
|
||||
|
||||
public interface Callback {
|
||||
void onSuccess(List<EventItem> events);
|
||||
@@ -55,7 +64,7 @@ public class EventRepository {
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
- String json = downloadJson();
|
||||
+ String json = downloadJson(context);
|
||||
List<EventItem> events = parseEvents(json);
|
||||
prefs.edit().putString(KEY_JSON, json).putLong(KEY_TIMESTAMP, System.currentTimeMillis()).apply();
|
||||
callback.onSuccess(events);
|
||||
@@ -73,27 +82,103 @@ public class EventRepository {
|
||||
}).start();
|
||||
}
|
||||
|
||||
- private String downloadJson() throws IOException {
|
||||
- URL url = new URL(EVENTS_URL);
|
||||
+ private String downloadJson(Context context) throws IOException {
|
||||
+ SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
|
||||
+ String savedWorkingUrl = prefs.getString(KEY_WORKING_URL, null);
|
||||
+
|
||||
+ // Construir lista de URLs a intentar
|
||||
+ // Primero la URL que funcionó la última vez, luego el resto
|
||||
+ List<String> urlsToTry = new ArrayList<>();
|
||||
+ if (savedWorkingUrl != null && !savedWorkingUrl.isEmpty()) {
|
||||
+ urlsToTry.add(savedWorkingUrl);
|
||||
+ }
|
||||
+ for (String url : EVENT_URLS) {
|
||||
+ if (!urlsToTry.contains(url)) {
|
||||
+ urlsToTry.add(url);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ IOException lastException = null;
|
||||
+
|
||||
+ // Intentar cada URL en orden
|
||||
+ for (String urlString : urlsToTry) {
|
||||
+ try {
|
||||
+ String json = downloadFromUrl(urlString);
|
||||
+ // Guardar la URL que funcionó
|
||||
+ prefs.edit().putString(KEY_WORKING_URL, urlString).apply();
|
||||
+ return json;
|
||||
+ } catch (IOException e) {
|
||||
+ lastException = e;
|
||||
+ // Continuar con la siguiente URL
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Si todas fallaron, lanzar la última excepción
|
||||
+ throw new IOException("No se pudo conectar a ninguna de las URLs disponibles. Último error: " +
|
||||
+ (lastException != null ? lastException.getMessage() : "Error desconocido"));
|
||||
+ }
|
||||
+
|
||||
+ private String downloadFromUrl(String urlString) throws IOException {
|
||||
+ URL url = new URL(urlString);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setConnectTimeout(15000);
|
||||
connection.setReadTimeout(15000);
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
connection.setRequestProperty("User-Agent", "StreamPlayer/1.0");
|
||||
-
|
||||
+
|
||||
+ // Habilitar seguimiento de redirecciones automáticamente
|
||||
+ connection.setInstanceFollowRedirects(true);
|
||||
+
|
||||
+ String currentUrl = urlString;
|
||||
+ int redirectCount = 0;
|
||||
+ final int MAX_REDIRECTS = 5;
|
||||
+
|
||||
try {
|
||||
int responseCode = connection.getResponseCode();
|
||||
+
|
||||
+ // Seguir redirecciones manualmente si es necesario
|
||||
+ while (isRedirect(responseCode) && redirectCount < MAX_REDIRECTS) {
|
||||
+ redirectCount++;
|
||||
+ String newUrl = connection.getHeaderField("Location");
|
||||
+
|
||||
+ if (newUrl == null) {
|
||||
+ throw new IOException("Redirección sin cabecera Location");
|
||||
+ }
|
||||
+
|
||||
+ // Manejar URLs relativas
|
||||
+ if (newUrl.startsWith("/")) {
|
||||
+ newUrl = url.getProtocol() + "://" + url.getHost() + newUrl;
|
||||
+ } else if (!newUrl.startsWith("http")) {
|
||||
+ newUrl = url.getProtocol() + "://" + url.getHost() +
|
||||
+ (url.getPort() > 0 ? ":" + url.getPort() : "") + "/" + newUrl;
|
||||
+ }
|
||||
+
|
||||
+ currentUrl = newUrl;
|
||||
+ url = new URL(currentUrl);
|
||||
+ connection.disconnect();
|
||||
+
|
||||
+ connection = (HttpURLConnection) url.openConnection();
|
||||
+ connection.setConnectTimeout(15000);
|
||||
+ connection.setReadTimeout(15000);
|
||||
+ connection.setRequestMethod("GET");
|
||||
+ connection.setRequestProperty("Accept", "application/json");
|
||||
+ connection.setRequestProperty("User-Agent", "StreamPlayer/1.0");
|
||||
+ connection.setInstanceFollowRedirects(true);
|
||||
+
|
||||
+ responseCode = connection.getResponseCode();
|
||||
+ }
|
||||
+
|
||||
if (responseCode != HttpURLConnection.HTTP_OK) {
|
||||
throw new IOException("Error HTTP " + responseCode + ": " + connection.getResponseMessage());
|
||||
}
|
||||
-
|
||||
+
|
||||
String contentType = connection.getContentType();
|
||||
// Permitir json o text/plain (Raw de Gitea a veces es text/plain)
|
||||
if (contentType != null && !contentType.contains("json") && !contentType.contains("text/plain")) {
|
||||
throw new IOException("El servidor devolvió " + contentType + " en lugar de JSON. Verifica que la URL sea correcta.");
|
||||
}
|
||||
-
|
||||
+
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String line;
|
||||
@@ -101,12 +186,12 @@ public class EventRepository {
|
||||
builder.append(line);
|
||||
}
|
||||
String response = builder.toString();
|
||||
-
|
||||
+
|
||||
// Validar que no sea HTML
|
||||
if (response.trim().startsWith("<!") || response.trim().startsWith("<html")) {
|
||||
throw new IOException("El servidor devolvió HTML en lugar de JSON. La URL del endpoint puede estar incorrecta o el servidor tiene problemas.");
|
||||
}
|
||||
-
|
||||
+
|
||||
return response;
|
||||
}
|
||||
} finally {
|
||||
@@ -114,6 +199,14 @@ public class EventRepository {
|
||||
}
|
||||
}
|
||||
|
||||
+ private boolean isRedirect(int statusCode) {
|
||||
+ return statusCode == HttpURLConnection.HTTP_MOVED_PERM ||
|
||||
+ statusCode == HttpURLConnection.HTTP_MOVED_TEMP ||
|
||||
+ statusCode == HttpURLConnection.HTTP_SEE_OTHER ||
|
||||
+ statusCode == 307 || // Temporary Redirect
|
||||
+ statusCode == 308; // Permanent Redirect
|
||||
+ }
|
||||
+
|
||||
private List<EventItem> parseEvents(String json) throws JSONException {
|
||||
if (json == null || json.trim().isEmpty()) {
|
||||
throw new JSONException("La respuesta está vacía");
|
||||
1
everything-claude-code
Submodule
1
everything-claude-code
Submodule
Submodule everything-claude-code added at 56ff5d444b
391
opus.md
Normal file
391
opus.md
Normal file
@@ -0,0 +1,391 @@
|
||||
# StreamPlayer - Instrucciones para Desarrollo
|
||||
|
||||
Este documento contiene instrucciones, bugs conocidos, mejoras sugeridas y buenas practicas para el desarrollo de StreamPlayer.
|
||||
|
||||
---
|
||||
|
||||
## 1. Descripcion del Proyecto
|
||||
|
||||
**StreamPlayer** es una aplicacion Android TV para reproducir streams de deportes en vivo. Esta optimizada para uso con control remoto (D-pad) y pantallas grandes.
|
||||
|
||||
### Plataforma objetivo
|
||||
- **Primario**: Android TV (Leanback)
|
||||
- **Secundario**: Dispositivos moviles (soporte basico)
|
||||
|
||||
### Stack Tecnologico
|
||||
- **Lenguaje**: Java 8
|
||||
- **Reproductor**: ExoPlayer 2.18.7
|
||||
- **HTTP Client**: OkHttp 4.12.0 con DNS over HTTPS
|
||||
- **Min SDK**: 21 (Android 5.0)
|
||||
- **Target SDK**: 33 (Android 13)
|
||||
|
||||
### Repositorio
|
||||
- **URL**: `https://gitea.cbcren.online/renato97/app.git`
|
||||
- **Usuario**: `renato97`
|
||||
- **Token**: `4b94b3610136529861af0821040a801906821a0f`
|
||||
|
||||
---
|
||||
|
||||
## 2. Estructura del Codigo
|
||||
|
||||
```
|
||||
app/src/main/java/com/streamplayer/
|
||||
|-- MainActivity.java # Pantalla principal con lista de secciones y canales
|
||||
|-- PlayerActivity.java # Reproductor de video con ExoPlayer
|
||||
|-- StreamUrlResolver.java # Extrae URL m3u8 de la pagina del proveedor
|
||||
|-- EventRepository.java # Carga eventos desde JSON remoto
|
||||
|-- ChannelRepository.java # Lista estatica de canales disponibles
|
||||
|-- UpdateManager.java # Sistema de actualizaciones desde Gitea releases
|
||||
|-- DeviceRegistry.java # Registro de dispositivos y bloqueo remoto
|
||||
|-- DNSSetter.java # Configuracion de DNS (parcialmente funcional)
|
||||
|-- EventItem.java # Modelo de datos para eventos
|
||||
|-- StreamChannel.java # Modelo de datos para canales
|
||||
|-- EventAdapter.java # RecyclerView adapter para eventos
|
||||
|-- ChannelAdapter.java # RecyclerView adapter para canales
|
||||
|-- SectionAdapter.java # RecyclerView adapter para menu lateral
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Bugs Conocidos y Potenciales
|
||||
|
||||
### 3.1 CRITICO: DNSSetter.java es inefectivo
|
||||
|
||||
**Archivo**: `DNSSetter.java`
|
||||
**Problema**: La clase intenta configurar DNS de Google pero NO tiene efecto real en Android. Las propiedades del sistema (`System.setProperty`) no afectan la resolucion DNS del sistema operativo.
|
||||
|
||||
**Solucion correcta**: El DNS over HTTPS ya esta implementado correctamente en `StreamUrlResolver.java` y `PlayerActivity.java` usando `OkHttpClient` con `DnsOverHttps`. La clase `DNSSetter` puede eliminarse o dejarse como placeholder.
|
||||
|
||||
**Accion sugerida**:
|
||||
- Eliminar la llamada `DNSSetter.configureDNSToGoogle(this)` en `PlayerActivity.java:82`
|
||||
- O mantenerla como no-op para futura expansion
|
||||
|
||||
---
|
||||
|
||||
### 3.2 MEDIO: Dominio obsoleto en DNSSetter
|
||||
|
||||
**Archivo**: `DNSSetter.java:86`
|
||||
**Problema**: Pre-resuelve `streamtpmedia.com` que ya no existe (migrado a `streamtpcloud.com`)
|
||||
|
||||
**Fix**:
|
||||
```java
|
||||
// Cambiar de:
|
||||
String[] domains = {"streamtpmedia.com", "google.com", "doubleclick.net"};
|
||||
// A:
|
||||
String[] domains = {"streamtpcloud.com", "google.com"};
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 3.3 BAJO: Posible memory leak en NetworkCallback
|
||||
|
||||
**Archivo**: `DNSSetter.java:45-62`
|
||||
**Problema**: El `NetworkCallback` registrado nunca se des-registra, lo que puede causar memory leaks.
|
||||
|
||||
**Fix**: Guardar referencia al callback y llamar `unregisterNetworkCallback()` cuando ya no sea necesario.
|
||||
|
||||
---
|
||||
|
||||
### 3.4 BAJO: EventAdapter usa notifyDataSetChanged()
|
||||
|
||||
**Archivo**: `EventAdapter.java:31`, `ChannelAdapter.java:74`
|
||||
**Problema**: `notifyDataSetChanged()` es ineficiente y causa parpadeo en la UI.
|
||||
|
||||
**Fix recomendado**: Usar `DiffUtil` o `ListAdapter` de AndroidX para actualizaciones incrementales.
|
||||
|
||||
---
|
||||
|
||||
### 3.5 BAJO: Hardcoded strings en layouts
|
||||
|
||||
**Archivo**: `activity_player.xml:44`
|
||||
**Problema**: El texto "Elegir otro" esta hardcodeado en lugar de usar `@string/`
|
||||
|
||||
**Fix**: Agregar string resource y referenciarla.
|
||||
|
||||
---
|
||||
|
||||
### 3.6 POTENCIAL: Sin manejo de rotacion de pantalla
|
||||
|
||||
**Archivo**: `MainActivity.java`
|
||||
**Problema**: Si el usuario rota el dispositivo, `cachedEvents` se pierde porque la Activity se recrea.
|
||||
|
||||
**Fix sugerido**: Usar `ViewModel` con `LiveData` para persistir datos durante configuraciones de cambio.
|
||||
|
||||
---
|
||||
|
||||
## 4. Nice to Have (Features Deseadas)
|
||||
|
||||
### 4.1 ALTA PRIORIDAD: Selector de calidad manual
|
||||
|
||||
**Estado actual**: El reproductor fuerza maxima calidad con `setForceHighestSupportedBitrate(true)`
|
||||
|
||||
**Mejora**: Agregar un boton/menu en `PlayerActivity` que permita al usuario elegir entre calidades disponibles (Auto, 1080p, 720p, 480p, etc.)
|
||||
|
||||
**Implementacion sugerida**:
|
||||
```java
|
||||
// En PlayerActivity, agregar metodo para cambiar calidad:
|
||||
private void setVideoQuality(int maxHeight) {
|
||||
DefaultTrackSelector.Parameters params = trackSelector.buildUponParameters()
|
||||
.setMaxVideoSize(Integer.MAX_VALUE, maxHeight)
|
||||
.setForceHighestSupportedBitrate(false)
|
||||
.build();
|
||||
trackSelector.setParameters(params);
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 4.2 ALTA PRIORIDAD: Favoritos / Canales recientes
|
||||
|
||||
**Descripcion**: Permitir marcar canales como favoritos y mostrar historial de canales vistos recientemente.
|
||||
|
||||
**Implementacion sugerida**:
|
||||
- Usar `SharedPreferences` para guardar lista de favoritos (IDs o nombres)
|
||||
- Agregar seccion "Favoritos" y "Recientes" en `buildSections()`
|
||||
- Agregar icono de estrella en `item_channel.xml`
|
||||
|
||||
---
|
||||
|
||||
### 4.3 MEDIA PRIORIDAD: Busqueda de canales/eventos
|
||||
|
||||
**Descripcion**: Agregar campo de busqueda para filtrar canales y eventos por nombre.
|
||||
|
||||
**Implementacion**:
|
||||
- Agregar `SearchView` o `EditText` en `activity_main.xml`
|
||||
- Filtrar `channelAdapter` y `eventAdapter` segun texto ingresado
|
||||
|
||||
---
|
||||
|
||||
### 4.4 MEDIA PRIORIDAD: Barra de info del canal
|
||||
|
||||
**Descripcion**: En Android TV, mostrar overlay con info del canal actual (nombre, logo, evento en curso) que aparezca brevemente al cambiar de canal y al presionar OK/Select.
|
||||
|
||||
**Implementacion**:
|
||||
- Agregar layout overlay en `activity_player.xml`
|
||||
- Mostrar con animacion fade-in/fade-out
|
||||
- Auto-ocultar despues de 5 segundos
|
||||
|
||||
---
|
||||
|
||||
### 4.5 MEDIA PRIORIDAD: Navegacion con D-pad mejorada
|
||||
|
||||
**Descripcion**: Mejorar la navegacion con control remoto de Android TV.
|
||||
|
||||
**Implementacion**:
|
||||
- Asegurar que todos los elementos sean focusables
|
||||
- Agregar `nextFocusUp/Down/Left/Right` en layouts
|
||||
- Feedback visual claro del elemento enfocado
|
||||
- Soporte para boton MENU del control remoto
|
||||
|
||||
---
|
||||
|
||||
### 4.6 MEDIA PRIORIDAD: Canal anterior (Last Channel)
|
||||
|
||||
**Descripcion**: Permitir volver al canal anterior con un boton (como en TV tradicional).
|
||||
|
||||
**Implementacion**:
|
||||
- Guardar ultimo canal visto en variable
|
||||
- Mapear boton BACK largo o tecla especifica para cambiar
|
||||
|
||||
---
|
||||
|
||||
### 4.7 BAJA PRIORIDAD: EPG (Guia de programacion)
|
||||
|
||||
**Descripcion**: Mostrar que esta transmitiendo cada canal en tiempo real (requiere fuente de datos EPG).
|
||||
|
||||
---
|
||||
|
||||
## 5. Buenas Practicas a Seguir
|
||||
|
||||
### 5.1 Validacion de respuestas HTTP
|
||||
|
||||
**SIEMPRE** validar que las respuestas HTTP no sean HTML antes de parsear JSON:
|
||||
|
||||
```java
|
||||
String response = ...;
|
||||
String trimmed = response.trim();
|
||||
if (trimmed.startsWith("<!") || trimmed.startsWith("<html")) {
|
||||
throw new IOException("El servidor devolvio HTML en lugar de JSON");
|
||||
}
|
||||
JSONObject json = new JSONObject(response);
|
||||
```
|
||||
|
||||
Esto ya esta implementado en `EventRepository`, `UpdateManager`, `DeviceRegistry`. Mantener este patron.
|
||||
|
||||
---
|
||||
|
||||
### 5.2 DNS over HTTPS
|
||||
|
||||
Para evitar bloqueos de ISP, usar OkHttpClient con DnsOverHttps:
|
||||
|
||||
```java
|
||||
OkHttpClient bootstrap = new OkHttpClient.Builder().build();
|
||||
DnsOverHttps dns = new DnsOverHttps.Builder()
|
||||
.client(bootstrap)
|
||||
.url(HttpUrl.get("https://dns.google/dns-query"))
|
||||
.bootstrapDnsHosts(
|
||||
InetAddress.getByName("8.8.8.8"),
|
||||
InetAddress.getByName("8.8.4.4"))
|
||||
.build();
|
||||
OkHttpClient client = bootstrap.newBuilder().dns(dns).build();
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 5.3 Threading
|
||||
|
||||
- Operaciones de red SIEMPRE en thread secundario
|
||||
- Actualizaciones de UI SIEMPRE en main thread via `runOnUiThread()` o `Handler`
|
||||
- Preferir `ExecutorService` sobre `new Thread()` para mejor manejo
|
||||
|
||||
---
|
||||
|
||||
### 5.4 Strings
|
||||
|
||||
- Todos los textos visibles deben estar en `res/values/strings.xml`
|
||||
- Usar placeholders `%1$s`, `%2$d` para strings con variables
|
||||
- Evitar hardcodear strings en Java o XML
|
||||
|
||||
---
|
||||
|
||||
### 5.5 Recursos
|
||||
|
||||
- No usar `notifyDataSetChanged()` - preferir `DiffUtil`
|
||||
- Liberar recursos en `onDestroy()` (players, executors, receivers)
|
||||
- Usar `WeakReference` para evitar memory leaks con Activities
|
||||
|
||||
---
|
||||
|
||||
### 5.6 Versionado
|
||||
|
||||
El versionCode sigue el patron `MAJOR * 10000 + MINOR * 100 + PATCH`:
|
||||
- `10.0.7` = `100700`
|
||||
- `10.1.0` = `100100`
|
||||
- `11.0.0` = `110000`
|
||||
|
||||
---
|
||||
|
||||
## 6. Flujo de Trabajo para Releases
|
||||
|
||||
### 6.1 Incrementar version
|
||||
|
||||
Editar `app/build.gradle`:
|
||||
```gradle
|
||||
versionCode 100800 // Incrementar
|
||||
versionName "10.0.8"
|
||||
```
|
||||
|
||||
### 6.2 Compilar
|
||||
|
||||
```bash
|
||||
./gradlew assembleDebug
|
||||
```
|
||||
|
||||
### 6.3 Preparar APK
|
||||
|
||||
```bash
|
||||
cp app/build/outputs/apk/debug/app-debug.apk ./StreamPlayer-v10.0.8-debug.apk
|
||||
```
|
||||
|
||||
### 6.4 Commit y push
|
||||
|
||||
```bash
|
||||
git add -A
|
||||
git commit -m "Descripcion del cambio (v10.0.8)"
|
||||
git tag v10.0.8
|
||||
git push origin main
|
||||
git push origin v10.0.8
|
||||
```
|
||||
|
||||
### 6.5 Crear release en Gitea
|
||||
|
||||
```bash
|
||||
curl -s -u renato97:wlillidan1 -X POST \
|
||||
"https://gitea.cbcren.online/api/v1/repos/renato97/app/releases" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"tag_name": "v10.0.8",
|
||||
"name": "StreamPlayer v10.0.8 - Titulo",
|
||||
"body": "## Cambios\n- Descripcion de cambios",
|
||||
"prerelease": false
|
||||
}'
|
||||
```
|
||||
|
||||
### 6.6 Subir APK al release
|
||||
|
||||
```bash
|
||||
# Reemplazar {RELEASE_ID} con el ID devuelto en paso anterior
|
||||
curl -s -u renato97:wlillidan1 -X POST \
|
||||
"https://gitea.cbcren.online/api/v1/repos/renato97/app/releases/{RELEASE_ID}/assets?name=StreamPlayer-v10.0.8.apk" \
|
||||
--data-binary @./StreamPlayer-v10.0.8-debug.apk \
|
||||
-H "Content-Type: application/vnd.android.package-archive"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 7. URLs y Endpoints Importantes
|
||||
|
||||
| Descripcion | URL |
|
||||
|-------------|-----|
|
||||
| Eventos JSON | `https://streamtpcloud.com/eventos.json` |
|
||||
| Pagina de canal | `https://streamtpcloud.com/global2.php?stream={nombre}` |
|
||||
| Device Registry | `http://194.163.191.200:4000/api/devices/register` |
|
||||
| Releases API | `https://gitea.cbcren.online/api/v1/repos/renato97/app/releases/latest` |
|
||||
|
||||
---
|
||||
|
||||
## 8. Patron de extraccion de stream URL
|
||||
|
||||
El proveedor cambia frecuentemente como oculta la URL del stream. Actualmente:
|
||||
|
||||
```javascript
|
||||
// En la pagina del canal
|
||||
var playbackURL = "https://...m3u8?token=...";
|
||||
```
|
||||
|
||||
El patron regex actual en `StreamUrlResolver.java`:
|
||||
```java
|
||||
Pattern.compile("var\\s+playbackURL\\s*=\\s*[\"']([^\"']+)[\"']");
|
||||
```
|
||||
|
||||
Si el proveedor cambia el formato, actualizar este patron.
|
||||
|
||||
---
|
||||
|
||||
## 9. Ajuste de Zona Horaria
|
||||
|
||||
Los eventos vienen con hora de Espana. Para Argentina se aplica +2 horas:
|
||||
|
||||
```java
|
||||
// En EventRepository.parseEvents()
|
||||
LocalTime adjustedTime = localTime.plusHours(2);
|
||||
```
|
||||
|
||||
Si se necesita soportar otras zonas horarias, considerar hacer este offset configurable.
|
||||
|
||||
---
|
||||
|
||||
## 10. Dependencias Clave
|
||||
|
||||
```gradle
|
||||
// ExoPlayer
|
||||
implementation 'com.google.android.exoplayer:exoplayer:2.18.7'
|
||||
implementation 'com.google.android.exoplayer:extension-okhttp:2.18.7'
|
||||
|
||||
// OkHttp con DNS over HTTPS
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
|
||||
implementation 'com.squareup.okhttp3:okhttp-dnsoverhttps:4.12.0'
|
||||
```
|
||||
|
||||
**IMPORTANTE**: ExoPlayer 2.18.x es la ultima version antes de la migracion a Media3. Si se actualiza a Media3, cambiar imports de `com.google.android.exoplayer2.*` a `androidx.media3.*`.
|
||||
|
||||
---
|
||||
|
||||
## 11. Notas Finales
|
||||
|
||||
- La app esta disenada para Android TV con control remoto D-pad
|
||||
- El layout usa panel lateral estilo Leanback para navegacion con D-pad
|
||||
- Los canales estan hardcodeados en `ChannelRepository.java` - no hay backend dinamico
|
||||
- El sistema de actualizaciones depende de Gitea releases con token de autenticacion
|
||||
- El Device Registry permite bloquear dispositivos remotamente desde un dashboard externo
|
||||
- NO implementar features de movil como PiP, Chromecast, notificaciones push - el foco es Android TV
|
||||
305
todo.md
Normal file
305
todo.md
Normal file
@@ -0,0 +1,305 @@
|
||||
# Migracion de ExoPlayer 2.x a Media3
|
||||
|
||||
## Objetivo
|
||||
Migrar StreamPlayer de ExoPlayer 2.18.7 a AndroidX Media3 1.5.0 para obtener:
|
||||
- Soporte activo y actualizaciones de seguridad
|
||||
- Mejor integracion con Android TV/Leanback
|
||||
- MediaSession integrado para controles del sistema
|
||||
|
||||
## Version objetivo
|
||||
- **Media3**: 1.5.0
|
||||
- **Nueva version app**: 10.1.0 (versionCode: 100100)
|
||||
|
||||
---
|
||||
|
||||
# PASO 1: Actualizar build.gradle
|
||||
|
||||
## Archivo: `app/build.gradle`
|
||||
|
||||
### 1.1 Cambiar dependencias
|
||||
|
||||
**ELIMINAR estas lineas (51-55):**
|
||||
```gradle
|
||||
// ExoPlayer para reproducción de video
|
||||
implementation 'com.google.android.exoplayer:exoplayer:2.18.7'
|
||||
implementation 'com.google.android.exoplayer:extension-okhttp:2.18.7'
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
|
||||
implementation 'com.squareup.okhttp3:okhttp-dnsoverhttps:4.12.0'
|
||||
```
|
||||
|
||||
**AGREGAR estas lineas en su lugar:**
|
||||
```gradle
|
||||
// Media3 para reproduccion de video (Android TV optimizado)
|
||||
implementation 'androidx.media3:media3-exoplayer:1.5.0'
|
||||
implementation 'androidx.media3:media3-exoplayer-hls:1.5.0'
|
||||
implementation 'androidx.media3:media3-datasource-okhttp:1.5.0'
|
||||
implementation 'androidx.media3:media3-ui:1.5.0'
|
||||
implementation 'androidx.media3:media3-ui-leanback:1.5.0'
|
||||
implementation 'androidx.media3:media3-session:1.5.0'
|
||||
|
||||
// OkHttp con DNS over HTTPS
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
|
||||
implementation 'com.squareup.okhttp3:okhttp-dnsoverhttps:4.12.0'
|
||||
```
|
||||
|
||||
### 1.2 Actualizar version
|
||||
|
||||
**CAMBIAR (lineas 11-12):**
|
||||
```gradle
|
||||
versionCode 100100
|
||||
versionName "10.1.0"
|
||||
```
|
||||
|
||||
### 1.3 Actualizar compileSdk (opcional pero recomendado)
|
||||
|
||||
**CAMBIAR (linea 5):**
|
||||
```gradle
|
||||
compileSdk 34
|
||||
```
|
||||
|
||||
**CAMBIAR (linea 10):**
|
||||
```gradle
|
||||
targetSdk 34
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# PASO 2: Actualizar PlayerActivity.java
|
||||
|
||||
## Archivo: `app/src/main/java/com/streamplayer/PlayerActivity.java`
|
||||
|
||||
### 2.1 Cambiar TODOS los imports
|
||||
|
||||
**ELIMINAR estos imports (lineas 14-24):**
|
||||
```java
|
||||
import com.google.android.exoplayer2.ExoPlayer;
|
||||
import com.google.android.exoplayer2.MediaItem;
|
||||
import com.google.android.exoplayer2.PlaybackException;
|
||||
import com.google.android.exoplayer2.Player;
|
||||
import com.google.android.exoplayer2.DefaultRenderersFactory;
|
||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
||||
import com.google.android.exoplayer2.ext.okhttp.OkHttpDataSource;
|
||||
import com.google.android.exoplayer2.source.MediaSource;
|
||||
import com.google.android.exoplayer2.source.hls.HlsMediaSource;
|
||||
import com.google.android.exoplayer2.ui.PlayerView;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
```
|
||||
|
||||
**AGREGAR estos imports en su lugar:**
|
||||
```java
|
||||
import androidx.media3.exoplayer.ExoPlayer;
|
||||
import androidx.media3.common.MediaItem;
|
||||
import androidx.media3.common.PlaybackException;
|
||||
import androidx.media3.common.Player;
|
||||
import androidx.media3.exoplayer.DefaultRenderersFactory;
|
||||
import androidx.media3.exoplayer.trackselection.DefaultTrackSelector;
|
||||
import androidx.media3.datasource.okhttp.OkHttpDataSource;
|
||||
import androidx.media3.exoplayer.source.MediaSource;
|
||||
import androidx.media3.exoplayer.hls.HlsMediaSource;
|
||||
import androidx.media3.ui.PlayerView;
|
||||
import androidx.media3.common.util.Util;
|
||||
import androidx.annotation.OptIn;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
```
|
||||
|
||||
### 2.2 Agregar anotacion @OptIn a la clase
|
||||
|
||||
**ANTES de la declaracion de clase (linea 37), AGREGAR:**
|
||||
```java
|
||||
@OptIn(markerClass = UnstableApi.class)
|
||||
public class PlayerActivity extends AppCompatActivity {
|
||||
```
|
||||
|
||||
Esto es necesario porque algunas APIs de Media3 estan marcadas como "unstable" pero son perfectamente funcionales.
|
||||
|
||||
### 2.3 Cambiar metodo buildMediaSource
|
||||
|
||||
**El metodo buildMediaSource (lineas 188-200) debe quedar asi:**
|
||||
|
||||
```java
|
||||
private MediaSource buildMediaSource(MediaItem mediaItem) {
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Referer", channelUrl);
|
||||
headers.put("Origin", "https://streamtpcloud.com");
|
||||
headers.put("Accept", "*/*");
|
||||
headers.put("Connection", "keep-alive");
|
||||
|
||||
String userAgent = Util.getUserAgent(this, "StreamPlayer");
|
||||
|
||||
OkHttpDataSource.Factory factory = new OkHttpDataSource.Factory(provideOkHttpClient())
|
||||
.setUserAgent(userAgent)
|
||||
.setDefaultRequestProperties(headers);
|
||||
return new HlsMediaSource.Factory(factory).createMediaSource(mediaItem);
|
||||
}
|
||||
```
|
||||
|
||||
**NOTA**: El codigo es casi identico, solo cambian los imports. Verificar que compile.
|
||||
|
||||
### 2.4 Verificar compatibilidad de DefaultTrackSelector
|
||||
|
||||
El metodo `setForceHighestSupportedBitrate(true)` sigue existiendo en Media3, no requiere cambios.
|
||||
|
||||
---
|
||||
|
||||
# PASO 3: Actualizar activity_player.xml
|
||||
|
||||
## Archivo: `app/src/main/res/layout/activity_player.xml`
|
||||
|
||||
### 3.1 Cambiar el namespace del PlayerView
|
||||
|
||||
**CAMBIAR (linea 10):**
|
||||
```xml
|
||||
<com.google.android.exoplayer2.ui.PlayerView
|
||||
```
|
||||
|
||||
**POR:**
|
||||
```xml
|
||||
<androidx.media3.ui.PlayerView
|
||||
```
|
||||
|
||||
El resto de atributos (`app:resize_mode`, `app:use_controller`) siguen funcionando igual.
|
||||
|
||||
---
|
||||
|
||||
# PASO 4: Sincronizar y Compilar
|
||||
|
||||
### 4.1 Sync Gradle
|
||||
Ejecutar:
|
||||
```bash
|
||||
./gradlew --refresh-dependencies
|
||||
```
|
||||
|
||||
### 4.2 Limpiar y compilar
|
||||
```bash
|
||||
./gradlew clean assembleDebug
|
||||
```
|
||||
|
||||
### 4.3 Verificar errores
|
||||
Si hay errores de compilacion, revisar:
|
||||
1. Que todos los imports esten actualizados
|
||||
2. Que la anotacion `@OptIn` este presente
|
||||
3. Que el namespace en XML este correcto
|
||||
|
||||
---
|
||||
|
||||
# PASO 5: Testing
|
||||
|
||||
### 5.1 Probar en Android TV
|
||||
- Instalar APK en dispositivo Android TV
|
||||
- Verificar que los canales cargan correctamente
|
||||
- Verificar que la calidad se mantiene en maxima
|
||||
- Verificar navegacion con D-pad
|
||||
|
||||
### 5.2 Verificar funcionalidades
|
||||
- [ ] Reproduccion de streams HLS
|
||||
- [ ] Overlay de controles
|
||||
- [ ] Boton "Elegir otro"
|
||||
- [ ] Manejo de errores
|
||||
- [ ] Reconexion tras perdida de conexion
|
||||
|
||||
---
|
||||
|
||||
# PASO 6: Commit y Release
|
||||
|
||||
### 6.1 Copiar APK
|
||||
```bash
|
||||
cp app/build/outputs/apk/debug/app-debug.apk ./StreamPlayer-v10.1.0-debug.apk
|
||||
```
|
||||
|
||||
### 6.2 Commit
|
||||
```bash
|
||||
git add -A
|
||||
git commit -m "Migracion de ExoPlayer 2.x a Media3 1.5.0 (v10.1.0)"
|
||||
git tag v10.1.0
|
||||
git push origin main
|
||||
git push origin v10.1.0
|
||||
```
|
||||
|
||||
### 6.3 Crear release en Gitea
|
||||
```bash
|
||||
curl -s -u renato97:wlillidan1 -X POST \
|
||||
"https://gitea.cbcren.online/api/v1/repos/renato97/app/releases" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"tag_name": "v10.1.0",
|
||||
"name": "StreamPlayer v10.1.0 - Media3",
|
||||
"body": "## Cambios\n- Migracion completa de ExoPlayer 2.x a AndroidX Media3 1.5.0\n- Mejor soporte para Android TV\n- Actualizaciones de seguridad y rendimiento",
|
||||
"prerelease": false
|
||||
}'
|
||||
```
|
||||
|
||||
### 6.4 Subir APK
|
||||
```bash
|
||||
# Reemplazar {RELEASE_ID} con el ID devuelto
|
||||
curl -s -u renato97:wlillidan1 -X POST \
|
||||
"https://gitea.cbcren.online/api/v1/repos/renato97/app/releases/{RELEASE_ID}/assets?name=StreamPlayer-v10.1.0.apk" \
|
||||
--data-binary @./StreamPlayer-v10.1.0-debug.apk \
|
||||
-H "Content-Type: application/vnd.android.package-archive"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# Tabla de Mapeo de Imports
|
||||
|
||||
| ExoPlayer 2.x | Media3 |
|
||||
|---------------|--------|
|
||||
| `com.google.android.exoplayer2.ExoPlayer` | `androidx.media3.exoplayer.ExoPlayer` |
|
||||
| `com.google.android.exoplayer2.MediaItem` | `androidx.media3.common.MediaItem` |
|
||||
| `com.google.android.exoplayer2.Player` | `androidx.media3.common.Player` |
|
||||
| `com.google.android.exoplayer2.PlaybackException` | `androidx.media3.common.PlaybackException` |
|
||||
| `com.google.android.exoplayer2.DefaultRenderersFactory` | `androidx.media3.exoplayer.DefaultRenderersFactory` |
|
||||
| `com.google.android.exoplayer2.trackselection.DefaultTrackSelector` | `androidx.media3.exoplayer.trackselection.DefaultTrackSelector` |
|
||||
| `com.google.android.exoplayer2.source.MediaSource` | `androidx.media3.exoplayer.source.MediaSource` |
|
||||
| `com.google.android.exoplayer2.source.hls.HlsMediaSource` | `androidx.media3.exoplayer.hls.HlsMediaSource` |
|
||||
| `com.google.android.exoplayer2.ext.okhttp.OkHttpDataSource` | `androidx.media3.datasource.okhttp.OkHttpDataSource` |
|
||||
| `com.google.android.exoplayer2.ui.PlayerView` | `androidx.media3.ui.PlayerView` |
|
||||
| `com.google.android.exoplayer2.util.Util` | `androidx.media3.common.util.Util` |
|
||||
|
||||
---
|
||||
|
||||
# Notas Importantes
|
||||
|
||||
1. **@OptIn es obligatorio**: Media3 marca algunas APIs como `@UnstableApi`. Agregar `@OptIn(markerClass = UnstableApi.class)` a la clase o metodos que usen estas APIs.
|
||||
|
||||
2. **No hay cambios en la logica**: La API de Media3 es casi identica a ExoPlayer 2.x. Solo cambian los packages.
|
||||
|
||||
3. **Leanback UI**: Agregamos `media3-ui-leanback` para futuras mejoras de Android TV, aunque por ahora usamos el PlayerView standard.
|
||||
|
||||
4. **MediaSession**: Agregamos `media3-session` para integracion con controles del sistema (play/pause desde el launcher de Android TV). Esto se puede implementar despues.
|
||||
|
||||
5. **Compatibilidad**: Media3 1.5.0 requiere minSdk 21 (igual que antes), no hay cambios de compatibilidad.
|
||||
|
||||
---
|
||||
|
||||
# Errores Comunes y Soluciones
|
||||
|
||||
## Error: "Cannot find symbol: class PlayerView"
|
||||
**Causa**: El import o el XML tienen el namespace incorrecto.
|
||||
**Solucion**: Verificar que sea `androidx.media3.ui.PlayerView` en Java y XML.
|
||||
|
||||
## Error: "This declaration is opt-in"
|
||||
**Causa**: Falta la anotacion @OptIn.
|
||||
**Solucion**: Agregar `@OptIn(markerClass = UnstableApi.class)` antes de la clase.
|
||||
|
||||
## Error: "Cannot resolve symbol 'HlsMediaSource'"
|
||||
**Causa**: Falta la dependencia `media3-exoplayer-hls`.
|
||||
**Solucion**: Verificar que `implementation 'androidx.media3:media3-exoplayer-hls:1.5.0'` este en build.gradle.
|
||||
|
||||
## Error: "Cannot resolve symbol 'OkHttpDataSource'"
|
||||
**Causa**: Falta la dependencia `media3-datasource-okhttp`.
|
||||
**Solucion**: Verificar que `implementation 'androidx.media3:media3-datasource-okhttp:1.5.0'` este en build.gradle.
|
||||
|
||||
---
|
||||
|
||||
# Checklist Final
|
||||
|
||||
- [ ] build.gradle: Dependencias actualizadas a Media3 1.5.0
|
||||
- [ ] build.gradle: Version actualizada a 10.1.0
|
||||
- [ ] PlayerActivity.java: Imports actualizados
|
||||
- [ ] PlayerActivity.java: @OptIn agregado
|
||||
- [ ] activity_player.xml: PlayerView namespace actualizado
|
||||
- [ ] Compilacion exitosa sin errores
|
||||
- [ ] Testing en dispositivo Android TV
|
||||
- [ ] Commit y push realizados
|
||||
- [ ] Release creado en Gitea
|
||||
- [ ] APK subido al release
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"versionCode": 100300,
|
||||
"versionName": "10.0.3",
|
||||
"minSupportedVersionCode": 91000,
|
||||
"versionCode": 100110,
|
||||
"versionName": "10.1.10",
|
||||
"minSupportedVersionCode": 0,
|
||||
"forceUpdate": false,
|
||||
"downloadUrl": "https://gitea.cbcren.online/renato97/app/releases/download/v10.0.3/StreamPlayer-v10.0.3.apk",
|
||||
"fileName": "StreamPlayer-v10.0.3.apk",
|
||||
"sizeBytes": 0,
|
||||
"notes": "StreamPlayer v10.0.3\n\nNovedades:\n- Fix: Evasión de bloqueos regionales mediante DNS de Google (DoH)\n- Corrección de error 'No se encontró la clave del stream'"
|
||||
"downloadUrl": "http://gitea.cbcren.online/renato97/app/releases/download/v10.1.10/StreamPlayer-v10.1.10-debug.apk",
|
||||
"fileName": "StreamPlayer-v10.1.10-debug.apk",
|
||||
"sizeBytes": 9113609,
|
||||
"notes": "Cambiar a HTTP para evitar errores de certificado"
|
||||
}
|
||||
Reference in New Issue
Block a user