This commit is contained in:
yutou 2021-05-24 17:35:49 +08:00
parent 728d700e54
commit 249568aa11
4 changed files with 19 additions and 45 deletions

View File

@ -136,6 +136,11 @@ public class MusicData {
if (StringUtil.isEmpty(track)) {
return "0";
}
try{
Integer.parseInt(track);
}catch (Exception e){
return track.substring(0,1);
}
return track;
}

View File

@ -134,7 +134,7 @@ public class MediaBrowserHelper {
}
}
public class MediaBrowserSubscriptionCallback extends MediaBrowserCompat.SubscriptionCallback {
public static class MediaBrowserSubscriptionCallback extends MediaBrowserCompat.SubscriptionCallback {
}
}

View File

@ -125,7 +125,9 @@ public class MusicService extends MediaBrowserServiceCompat {
IntentFilter intentFilter = new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY);;
public void updateNotification() {
MediaMetadataCompat metadataCompat = MusicContainer.getInstance().getNowPlayMetadataCompat();
System.out.println("更新通知栏:"+metadataCompat.getString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID));
mediaSession.setMetadata(metadataCompat);
mediaSession.setActive(true);
Notification notification =

View File

@ -51,7 +51,6 @@ public class MainActivity extends AppCompatActivity {
private TextView positionTime, durationTime, bitRate;
private SeekBar seekBar;
private Handler handler;
private KProgressHUD hud;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -64,11 +63,7 @@ public class MainActivity extends AppCompatActivity {
play.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (hud != null) {
hud.dismiss();
hud = null;
}
hud = AppTools.showLoading(MainActivity.this);
handler.post(new Runnable() {
@Override
public void run() {
@ -78,10 +73,6 @@ public class MainActivity extends AppCompatActivity {
} else {
browserHelper.getTransportControls().play();
}
if (hud != null && hud.isShowing()) {
hud.dismiss();
hud = null;
}
}
});
@ -90,19 +81,12 @@ public class MainActivity extends AppCompatActivity {
next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (hud != null) {
hud.dismiss();
hud = null;
}
hud = AppTools.showLoading(MainActivity.this);
handler.post(new Runnable() {
@Override
public void run() {
browserHelper.getTransportControls().skipToNext();
if (hud != null && hud.isShowing()) {
hud.dismiss();
hud = null;
}
}
});
@ -111,19 +95,10 @@ public class MainActivity extends AppCompatActivity {
previous.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (hud != null) {
hud.dismiss();
hud = null;
}
hud = AppTools.showLoading(MainActivity.this);
handler.post(new Runnable() {
@Override
public void run() {
browserHelper.getTransportControls().skipToPrevious();
if (hud != null && hud.isShowing()) {
hud.dismiss();
hud = null;
}
}
});
}
@ -141,19 +116,11 @@ public class MainActivity extends AppCompatActivity {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
if (hud != null) {
hud.dismiss();
hud = null;
}
hud = AppTools.showLoading(MainActivity.this);
handler.post(new Runnable() {
@Override
public void run() {
if (browserHelper.getTransportControls() != null)
if (browserHelper.getTransportControls() != null) {
browserHelper.getTransportControls().seekTo(MainActivity.this.seekBar.getProgress());
if (hud != null && hud.isShowing()) {
hud.dismiss();
hud = null;
}
}
});
@ -200,7 +167,7 @@ public class MainActivity extends AppCompatActivity {
Intent intent = new Intent(
MainActivity.this, PlayLibsActivity.class);
intent.putExtra("bar_pos",seekBar.getProgress());
intent.putExtra("bar_pos", seekBar.getProgress());
if (bundle != null) {
startActivity(intent, bundle);
} else {
@ -251,13 +218,13 @@ public class MainActivity extends AppCompatActivity {
+ String.format(Locale.CHINA, "%02d", seconds));
int model = ConfigTools.getPreferences().getInt("playModel", MusicContainer.PLAY_MODEL_RANDOM);
setPlayModelButton(model);
if (data.getImg(-1,-1) != null) {
if (data.getImg(-1, -1) != null) {
setImage(data);
} else {
new Timer().schedule(new TimerTask() {
@Override
public void run() {
if (data.getImg(-1,-1) != null) {
if (data.getImg(-1, -1) != null) {
AppData.handler.post(new Runnable() {
@Override
public void run() {
@ -294,10 +261,10 @@ public class MainActivity extends AppCompatActivity {
private void setImage(MusicData data) {
setBarColor(data.getImageColor());
Glide.with(this).load(data.getImg(-1,-1))
Glide.with(this).load(data.getImg(-1, -1))
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(25, 3)))
.into(album_image);
Glide.with(this).load(data.getImg(200,200))
Glide.with(this).load(data.getImg(200, 200))
.apply(RequestOptions.bitmapTransform(new BlurTransformation(25, 3)))
.into(background_image);
}
@ -326,9 +293,9 @@ public class MainActivity extends AppCompatActivity {
@Override
protected void onDestroy() {
super.onDestroy();
if(browserHelper!=null){
if (browserHelper != null) {
browserHelper.onStop();
browserHelper=null;
browserHelper = null;
}
finish();
}