Исключение Exoplayer появилось слишком поздно ⇐ JAVA
Исключение Exoplayer появилось слишком поздно
I am trying to learn exoplayer.So far I am able to play a mediasource with exoplayer. I want to show an error dialouge if any mediasource can not be played. the error dialouge is appearing but taking a bit time. so I tried to handle the response time the following way but no improvement.
if (channelUrl != null && !channelUrl.isEmpty()) { try { MediaItem mediaItem = MediaItem.fromUri(Uri.parse(channelUrl)); DataSource.Factory dataSourceFactory = new DefaultHttpDataSource.Factory(); HlsMediaSource hlsMediaSource = new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(mediaItem); player.setMediaSource(hlsMediaSource); player.prepare(); player.setPlayWhenReady(true); player.addListener(new Player.Listener() { @Override public void onPlayerError(@NonNull PlaybackException error) { Log.e("ExoPlayer", "Error playing media: " + error.getMessage()); // Delay the error dialog by 3 seconds new Handler(Looper.getMainLooper()).postDelayed(() -> { showAlertDialogError(); player.stop(); }, 3000); } }); } catch (Exception e) { e.printStackTrace(); } }
Источник: https://stackoverflow.com/questions/781 ... too-lately
I am trying to learn exoplayer.So far I am able to play a mediasource with exoplayer. I want to show an error dialouge if any mediasource can not be played. the error dialouge is appearing but taking a bit time. so I tried to handle the response time the following way but no improvement.
if (channelUrl != null && !channelUrl.isEmpty()) { try { MediaItem mediaItem = MediaItem.fromUri(Uri.parse(channelUrl)); DataSource.Factory dataSourceFactory = new DefaultHttpDataSource.Factory(); HlsMediaSource hlsMediaSource = new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(mediaItem); player.setMediaSource(hlsMediaSource); player.prepare(); player.setPlayWhenReady(true); player.addListener(new Player.Listener() { @Override public void onPlayerError(@NonNull PlaybackException error) { Log.e("ExoPlayer", "Error playing media: " + error.getMessage()); // Delay the error dialog by 3 seconds new Handler(Looper.getMainLooper()).postDelayed(() -> { showAlertDialogError(); player.stop(); }, 3000); } }); } catch (Exception e) { e.printStackTrace(); } }
Источник: https://stackoverflow.com/questions/781 ... too-lately
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Не слишком ли поздно Maven внедряет системное свойство java.io.tmpdir в JVM для JDK 17?
Anonymous » » в форуме JAVA - 0 Ответы
- 64 Просмотры
-
Последнее сообщение Anonymous
-