3 Commits

Author SHA1 Message Date
Apple
97adc46509 feat: mejoras de interfaz v10.1.4 - botón refresh visible, límite de scroll y barra indicadora
Cambios implementados:

1. Botón de Actualización Más Visible (para control remoto)
   - Nuevo archivo: btn_refresh_selector.xml con estados de foco
   - Color ámbar brillante (#FFC107) cuando está enfocado
   - Borde grueso (4dp) para mejor visibilidad

2. Prevención de Navegación Entre Secciones
   - Modificado: MainActivity.java showEvents()
   - Agregado OnScrollListener que detiene scroll al final de eventos
   - Previene paso accidental a sección de canales

3. Barra de Indicador de Scroll
   - Nuevo archivo: scrollbar_vertical.xml (drawable)
   - Modificado: activity_main.xml con atributos de scrollbar
   - Barra visual derecha como indicador de posición

Archivos modificados:
- app/src/main/java/com/streamplayer/MainActivity.java
- app/src/main/res/layout/activity_main.xml
- app/src/main/res/values/colors.xml

Archivos nuevos:
- app/src/main/res/drawable/btn_refresh_selector.xml
- app/src/main/res/drawable/scrollbar_vertical.xml

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 21:33:09 -03:00
Apple
ec360cf303 fix: implementar sistema de fallback y redirecciones HTTP para carga de eventos
- Agregar sistema de fallback con múltiples URLs (streamtpcloud.com, streamtp10.com, streamtpmedia.com)
- Implementar seguimiento automático de redirecciones HTTP (301, 302, 303, 307, 308)
- Guardar última URL exitosa en SharedPreferences para optimizar futuras peticiones
- Corregir error "Unable to resolve host 'streamtpcloud.com'" cuando el dominio cambia

Resuelve issue donde los eventos no cargaban debido a cambios en el dominio del servidor.
La app ahora se adapta automáticamente sin necesidad de actualización.
2026-02-09 21:14:35 -03:00
renato97
3c1a323b35 🎉 v10.1.2: Reproductor robusto con calidad adaptativa
 Mejoras principales:
- Reproductor más robusto: reintenta automáticamente en errores 404
- Calidad adaptativa: eliminado forzamiento de 1080p
- Sistema de reintentos: 3 intentos automáticos con delays
- Timeouts mejorados: 20s connect, 30s read
- Manejo granular de errores recuperables

📱 Cambios técnicos:
- setForceHighestSupportedBitrate(false) - calidad adaptativa
- Configuración de reintentos (MAX_RETRIES = 3)
- Detección de errores 404, 403, timeout, network
- Feedback visual durante reintentos
- Timeouts incrementados para conexiones lentas

🔧 Build:
- Incrementado versionCode: 100101 → 100102
- Incrementado versionName: 10.1.1 → 10.1.2
- APK compilado y subido a Gitea

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-28 21:26:58 +01:00
11 changed files with 332 additions and 21 deletions

2
.env
View File

@@ -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
View 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
View 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

View File

@@ -8,8 +8,8 @@ android {
applicationId "com.streamplayer"
minSdk 21
targetSdk 35
versionCode 100101
versionName "10.1.1"
versionCode 100102
versionName "10.1.2"
buildConfigField "String", "DEVICE_REGISTRY_URL", '"http://194.163.191.200:4000"'
}

View File

@@ -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,8 +82,44 @@ 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);
@@ -82,8 +127,48 @@ public class EventRepository {
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());
}
@@ -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");

View File

@@ -14,6 +14,7 @@ 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;
@@ -169,6 +170,8 @@ public class MainActivity extends AppCompatActivity {
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()) {
@@ -185,6 +188,26 @@ public class MainActivity extends AppCompatActivity {
refreshButton.setVisibility(View.VISIBLE);
contentList.setLayoutManager(eventLayoutManager);
contentList.setAdapter(eventAdapter);
// Add scroll listener to prevent scrolling from Events to Channels section
contentList.clearOnScrollListeners();
contentList.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
// Only prevent downward scroll when at the last item
if (dy > 0) { // Scrolling down
int visibleItemCount = eventLayoutManager.getChildCount();
int totalItemCount = eventLayoutManager.getItemCount();
int firstVisibleItemPosition = eventLayoutManager.findFirstVisibleItemPosition();
// Check if we're at the last item
if (firstVisibleItemPosition + visibleItemCount >= totalItemCount) {
// Prevent further scrolling by stopping the scroll
recyclerView.stopScroll();
}
}
}
});
if (cachedEvents.isEmpty()) {
loadEvents(false);
} else {

View File

@@ -55,6 +55,9 @@ public class PlayerActivity extends AppCompatActivity {
private String channelUrl;
private boolean overlayVisible = true;
private OkHttpClient okHttpClient;
private int retryCount = 0;
private static final int MAX_RETRIES = 3;
private String lastStreamUrl;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -102,6 +105,7 @@ public class PlayerActivity extends AppCompatActivity {
private void loadChannel() {
showLoading(true);
retryCount = 0; // Resetear contador al cargar nuevo canal
new Thread(() -> {
try {
String resolvedUrl = StreamUrlResolver.resolve(channelUrl);
@@ -117,14 +121,17 @@ public class PlayerActivity extends AppCompatActivity {
private void startPlayback(String streamUrl) {
try {
releasePlayer();
lastStreamUrl = streamUrl; // Guardar URL para reintentos
retryCount = 0; // Resetear contador al iniciar nueva reproducción
DefaultRenderersFactory renderersFactory = new DefaultRenderersFactory(this)
.setEnableDecoderFallback(true)
.setExtensionRendererMode(DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON);
// Configurar track selector para máxima calidad
// Configurar track selector para calidad adaptativa (no forzar máxima calidad)
trackSelector = new DefaultTrackSelector(this);
DefaultTrackSelector.Parameters params = trackSelector.buildUponParameters()
.setForceHighestSupportedBitrate(true) // Forzar máximo bitrate
.setForceHighestSupportedBitrate(false) // Permitir calidad adaptativa
.setMaxVideoBitrate(Integer.MAX_VALUE) // Sin límite máximo de bitrate
.build();
trackSelector.setParameters(params);
@@ -140,6 +147,7 @@ public class PlayerActivity extends AppCompatActivity {
public void onPlaybackStateChanged(int playbackState) {
if (playbackState == Player.STATE_READY) {
showLoading(false);
retryCount = 0; // Resetear contador de reintentos al reproducir exitosamente
} else if (playbackState == Player.STATE_BUFFERING) {
showLoading(true);
}
@@ -147,9 +155,46 @@ public class PlayerActivity extends AppCompatActivity {
@Override
public void onPlayerError(PlaybackException error) {
String errorMsg = error.getMessage() != null ? error.getMessage() : "";
String detail = error.getCause() != null ?
error.getCause().getMessage() : "";
showError("Error al reproducir: " + error.getMessage() + " " + detail);
String fullError = errorMsg + " " + detail;
// Verificar si es un error que justifica reintento (404, conectividad, etc.)
boolean isRetryableError =
fullError.contains("404") ||
fullError.contains("403") ||
fullError.contains("timeout") ||
fullError.contains("Unable to connect") ||
fullError.contains("Network") ||
fullError.contains("source error") ||
error.errorCode == PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_FAILED ||
error.errorCode == PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_TIMEOUT ||
error.errorCode == PlaybackException.ERROR_CODE_IO_BAD_HTTP_STATUS;
if (isRetryableError && retryCount < MAX_RETRIES) {
retryCount++;
runOnUiThread(() -> {
showLoading(true);
showError("Error de conexión. Reintentando... (" + retryCount + "/" + MAX_RETRIES + ")");
});
// Reintentar después de 2 segundos
new android.os.Handler(android.os.Looper.getMainLooper()).postDelayed(() -> {
if (lastStreamUrl != null) {
startPlayback(lastStreamUrl);
} else {
loadChannel();
}
}, 2000);
} else {
// Mostrar error final después de agotar reintentos
String finalMessage = "Error al reproducir: " + fullError;
if (retryCount >= MAX_RETRIES) {
finalMessage += "\n\nSe agotaron los reintentos (" + MAX_RETRIES + ").";
}
showError(finalMessage);
}
}
});
@@ -210,8 +255,8 @@ public class PlayerActivity extends AppCompatActivity {
try {
OkHttpClient bootstrap = new OkHttpClient.Builder()
.connectTimeout(15, TimeUnit.SECONDS)
.readTimeout(15, TimeUnit.SECONDS)
.connectTimeout(20, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.retryOnConnectionFailure(true)
.build();
@@ -228,8 +273,8 @@ public class PlayerActivity extends AppCompatActivity {
.build();
} catch (UnknownHostException e) {
okHttpClient = new OkHttpClient.Builder()
.connectTimeout(15, TimeUnit.SECONDS)
.readTimeout(15, TimeUnit.SECONDS)
.connectTimeout(20, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.retryOnConnectionFailure(true)
.build();
}

View 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>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#4DFFFFFF" />
<corners android:radius="2dp" />
</shape>

View File

@@ -97,7 +97,10 @@
android:textSize="12sp"
android:visibility="gone"
android:focusable="true"
android:focusableInTouchMode="true" />
android:focusableInTouchMode="true"
android:background="@drawable/btn_refresh_selector"
android:textColor="@color/white"
android:elevation="2dp" />
</LinearLayout>
@@ -125,6 +128,9 @@
android:layout_marginTop="16dp"
android:layout_weight="1"
android:overScrollMode="never"
android:scrollbars="vertical"
android:scrollbarStyle="outsideOverlay"
android:scrollbarThumbVertical="@drawable/scrollbar_vertical"
android:nextFocusLeft="@id/section_list"
tools:listitem="@layout/item_channel" />
</LinearLayout>

View File

@@ -3,4 +3,11 @@
<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>
</resources>