Fixed pause on bluetooth disconnect, minor fixes

This commit is contained in:
Nite 2020-06-29 16:17:22 +02:00
parent fdc1748f8a
commit 7dad738fce
No known key found for this signature in database
GPG Key ID: 1D1AD59B1C6386C1
6 changed files with 15 additions and 4 deletions

View File

@ -77,17 +77,22 @@ public class Downloader
executorService = Executors.newSingleThreadScheduledExecutor(); executorService = Executors.newSingleThreadScheduledExecutor();
executorService.scheduleWithFixedDelay(downloadChecker, 5, 5, TimeUnit.SECONDS); executorService.scheduleWithFixedDelay(downloadChecker, 5, 5, TimeUnit.SECONDS);
Log.i(TAG, "Downloader created"); Log.i(TAG, "Downloader created");
} }
public void onDestroy() public void onDestroy()
{ {
executorService.shutdown(); stop();
clear(); clear();
clearBackground(); clearBackground();
Log.i(TAG, "Downloader destroyed"); Log.i(TAG, "Downloader destroyed");
} }
public void stop()
{
executorService.shutdown();
Log.i(TAG, "Downloader stopped");
}
public synchronized void checkDownloads() public synchronized void checkDownloads()
{ {
if (!Util.isExternalStoragePresent() || !externalStorageMonitor.isExternalStorageAvailable()) if (!Util.isExternalStoragePresent() || !externalStorageMonitor.isExternalStorageAvailable())

View File

@ -1081,7 +1081,7 @@ public class LocalMediaPlayer
cachedPosition = mediaPlayer.getCurrentPosition(); cachedPosition = mediaPlayer.getCurrentPosition();
} }
Util.sleepQuietly(25L); Util.sleepQuietly(50L);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -96,7 +96,6 @@ public class MediaPlayerControllerImpl implements MediaPlayerController
{ {
externalStorageMonitor.onDestroy(); externalStorageMonitor.onDestroy();
context.stopService(new Intent(context, MediaPlayerService.class)); context.stopService(new Intent(context, MediaPlayerService.class));
shufflePlayBuffer.onDestroy();
downloader.onDestroy(); downloader.onDestroy();
Log.i(TAG, "MediaPlayerControllerImpl destroyed"); Log.i(TAG, "MediaPlayerControllerImpl destroyed");

View File

@ -245,6 +245,9 @@ public class MediaPlayerLifecycleSupport
mediaPlayerController.pause(); mediaPlayerController.pause();
mediaPlayerController.seekTo(0); mediaPlayerController.seekTo(0);
break; break;
case Constants.CMD_PAUSE:
mediaPlayerController.pause();
break;
case Constants.CMD_PROCESS_KEYCODE: case Constants.CMD_PROCESS_KEYCODE:
receiveIntent(intent); receiveIntent(intent);
break; break;

View File

@ -194,6 +194,8 @@ public class MediaPlayerService extends Service
downloadQueueSerializer.serializeDownloadQueueNow(downloader.downloadList, downloadQueueSerializer.serializeDownloadQueueNow(downloader.downloadList,
downloader.getCurrentPlayingIndex(), getPlayerPosition()); downloader.getCurrentPlayingIndex(), getPlayerPosition());
localMediaPlayer.onDestroy(); localMediaPlayer.onDestroy();
downloader.stop();
shufflePlayBuffer.onDestroy();
} catch (Throwable ignored) { } catch (Throwable ignored) {
} }

View File

@ -65,11 +65,13 @@ public class ShufflePlayBuffer
} }
}; };
executorService.scheduleWithFixedDelay(runnable, 1, 10, TimeUnit.SECONDS); executorService.scheduleWithFixedDelay(runnable, 1, 10, TimeUnit.SECONDS);
Log.i(TAG, "ShufflePlayBuffer created");
} }
public void onDestroy() public void onDestroy()
{ {
executorService.shutdown(); executorService.shutdown();
Log.i(TAG, "ShufflePlayBuffer destroyed");
} }
public List<MusicDirectory.Entry> get(int size) public List<MusicDirectory.Entry> get(int size)