Skip to content

Commit

Permalink
https://github.com/lizixian18/MusicLibrary/issues/44
Browse files Browse the repository at this point in the history
  • Loading branch information
EspoirX committed Jul 18, 2018
1 parent 91804f3 commit 076d363
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.RemoteException;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;

import com.lzx.musiclibrary.cache.CacheConfig;
import com.lzx.musiclibrary.control.PlayControl;
Expand Down Expand Up @@ -78,8 +76,10 @@ public void onTaskRemoved(Intent rootIntent) {
@Override
public void onDestroy() {
super.onDestroy();
mBinder.stopMusic();
mBinder.releaseMediaSession();
if (mBinder != null) {
mBinder.stopMusic();
mBinder.releaseMediaSession();
}
}

private static class DelayedStopHandler extends Handler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,13 @@ public MediaSessionCompat.Callback getMediaSessionCallback() {
*/
public void handlePlayRequest() {
SongInfo currentMusic = mQueueManager.getCurrentMusic();
if (currentMusic != null) {

if (currentMusic != null && mPlayback.getState() != State.STATE_ASYNC_LOADING) {
String mediaId = currentMusic.getSongId();
boolean mediaHasChanged = !TextUtils.equals(mediaId, mCurrentMediaId);
if (mediaHasChanged) {
mCurrentMediaId = mediaId;
notifyPlaybackSwitch(currentMusic);
}

//播放
mPlayback.play(currentMusic);
//更新媒体信息
Expand Down

0 comments on commit 076d363

Please sign in to comment.