|
141 | 141 | import org.schabi.newpipe.R; |
142 | 142 | import org.schabi.newpipe.databinding.PlayerBinding; |
143 | 143 | import org.schabi.newpipe.databinding.PlayerPopupCloseOverlayBinding; |
| 144 | +import org.schabi.newpipe.error.ErrorInfo; |
| 145 | +import org.schabi.newpipe.error.ErrorUtil; |
| 146 | +import org.schabi.newpipe.error.UserAction; |
144 | 147 | import org.schabi.newpipe.extractor.MediaFormat; |
145 | 148 | import org.schabi.newpipe.extractor.stream.StreamInfo; |
146 | 149 | import org.schabi.newpipe.extractor.stream.StreamSegment; |
|
165 | 168 | import org.schabi.newpipe.player.playback.PlaybackListener; |
166 | 169 | import org.schabi.newpipe.player.playback.PlayerMediaSession; |
167 | 170 | import org.schabi.newpipe.player.playback.SurfaceHolderCallback; |
168 | | -import org.schabi.newpipe.player.playererror.PlayerErrorHandler; |
169 | 171 | import org.schabi.newpipe.player.playqueue.PlayQueue; |
170 | 172 | import org.schabi.newpipe.player.playqueue.PlayQueueAdapter; |
171 | 173 | import org.schabi.newpipe.player.playqueue.PlayQueueItem; |
@@ -268,8 +270,6 @@ public final class Player implements |
268 | 270 | @Nullable private MediaSourceTag currentMetadata; |
269 | 271 | @Nullable private Bitmap currentThumbnail; |
270 | 272 |
|
271 | | - @NonNull private PlayerErrorHandler playerErrorHandler; |
272 | | - |
273 | 273 | /*////////////////////////////////////////////////////////////////////////// |
274 | 274 | // Player |
275 | 275 | //////////////////////////////////////////////////////////////////////////*/ |
@@ -413,8 +413,6 @@ public Player(@NonNull final MainPlayer service) { |
413 | 413 | videoResolver = new VideoPlaybackResolver(context, dataSource, getQualityResolver()); |
414 | 414 | audioResolver = new AudioPlaybackResolver(context, dataSource); |
415 | 415 |
|
416 | | - playerErrorHandler = new PlayerErrorHandler(context); |
417 | | - |
418 | 416 | windowManager = ContextCompat.getSystemService(context, WindowManager.class); |
419 | 417 | } |
420 | 418 |
|
@@ -2518,29 +2516,30 @@ public void onPlayerError(@NonNull final ExoPlaybackException error) { |
2518 | 2516 |
|
2519 | 2517 | saveStreamProgressState(); |
2520 | 2518 |
|
| 2519 | + // create error notification |
| 2520 | + final ErrorInfo errorInfo; |
| 2521 | + if (currentMetadata == null) { |
| 2522 | + errorInfo = new ErrorInfo(error, UserAction.PLAY_STREAM, |
| 2523 | + "Player error[type=" + error.type + "] occurred, currentMetadata is null"); |
| 2524 | + } else { |
| 2525 | + errorInfo = new ErrorInfo(error, UserAction.PLAY_STREAM, |
| 2526 | + "Player error[type=" + error.type + "] occurred while playing " |
| 2527 | + + currentMetadata.getMetadata().getUrl(), |
| 2528 | + currentMetadata.getMetadata()); |
| 2529 | + } |
| 2530 | + ErrorUtil.createNotification(context, errorInfo); |
| 2531 | + |
2521 | 2532 | switch (error.type) { |
2522 | 2533 | case ExoPlaybackException.TYPE_SOURCE: |
2523 | 2534 | processSourceError(error.getSourceException()); |
2524 | | - playerErrorHandler.showPlayerError( |
2525 | | - error, |
2526 | | - currentMetadata.getMetadata(), |
2527 | | - R.string.player_stream_failure); |
2528 | 2535 | break; |
2529 | 2536 | case ExoPlaybackException.TYPE_UNEXPECTED: |
2530 | | - playerErrorHandler.showPlayerError( |
2531 | | - error, |
2532 | | - currentMetadata.getMetadata(), |
2533 | | - R.string.player_recoverable_failure); |
2534 | 2537 | setRecovery(); |
2535 | 2538 | reloadPlayQueueManager(); |
2536 | 2539 | break; |
2537 | 2540 | case ExoPlaybackException.TYPE_REMOTE: |
2538 | 2541 | case ExoPlaybackException.TYPE_RENDERER: |
2539 | 2542 | default: |
2540 | | - playerErrorHandler.showPlayerError( |
2541 | | - error, |
2542 | | - currentMetadata.getMetadata(), |
2543 | | - R.string.player_unrecoverable_failure); |
2544 | 2543 | onPlaybackShutdown(); |
2545 | 2544 | break; |
2546 | 2545 | } |
|
0 commit comments