A面进度更新
This commit is contained in:
parent
7c739312e9
commit
8d3921de0d
@ -1,28 +0,0 @@
|
||||
a787e8e868e0962815f613634aaa7623
|
||||
106f9be0e66f52f36eaaaff4dd231971
|
||||
75939c4ce23c53ad9534d43be176b3e9
|
||||
217e8f437c9fc4244d6e74653ac8a8c7
|
||||
66b774de6608db14a84e972fba1ec954
|
||||
e1c9ddef73e5621f62c717badf1be3f2
|
||||
daaea35726ab7cd457ab61d4538fb822
|
||||
b9b88d70c3d018bfbda46cd93ba3ddca
|
||||
946dbe0d5ed7fee91c8ece64d035e70b
|
||||
213ac5b6803852323d73a1292440d7be
|
||||
d41ed920405e4bd14f3a42cd93c43d89
|
||||
7eac188d3286b05ccbba774f63a2c049
|
||||
4df96d3bc9afd17b812e65e6c6add1ef
|
||||
9f5a74f6ccfb81b48969231b39bf937f
|
||||
eb3214f29c0a52815b41977d6cc9a46e
|
||||
becf75b2cc99e82716da2e6697879509
|
||||
7eec7b9476b99b3ce94533da4f2eb987
|
||||
974322f19d813702ea048d95288d2b8c
|
||||
95ff573e4cdf46a05f6c5ac703940db3
|
||||
f281c2ca1b0ba69b5805badd314ef646
|
||||
29015bbfcc182d80e7f75bd2c38e4521
|
||||
ff22dbf67af979b8b3169a242d10f166
|
||||
c4d1f1775f251f03dce94fdf267a7b89
|
||||
dd2971b0681141d57b221687791ad1bd
|
||||
86a0d598cde251321e21a0da4ab94065
|
||||
74616804a7dc29147dfb0afe122a9fd2
|
||||
35695de726f6044576c830bf197f36f7
|
||||
|
||||
Binary file not shown.
@ -1,2 +0,0 @@
|
||||
#Thu Nov 21 18:22:08 CST 2024
|
||||
json=827215329
|
||||
@ -1,5 +0,0 @@
|
||||
#
|
||||
#Thu Nov 21 18:29:25 CST 2024
|
||||
4CFHxOfvQvy95EqDxa_eNPe4pmq_KfoZPJeVscTMt2uT3VL2fO3iyZyBFMTOOTRbKw6WelbaDEhNzxOxVrlQTE=tAh5Z8CtFiG05NfRWh9UuOHCp3h3SaFvlh6Phw5ucaxFMCRs2d97F7lywfBKOEKSipdaGq8vZOaDLZkrL1fDDc
|
||||
sdk_analysis_plugin_version=5.6.2
|
||||
set_multidex=true
|
||||
@ -24,8 +24,8 @@ android {
|
||||
applicationId = "com.offline.music.playermp3"
|
||||
minSdk = 23
|
||||
targetSdk = 34
|
||||
versionCode = 1
|
||||
versionName = "1.0.0"
|
||||
versionCode = 2
|
||||
versionName = "1.0.1"
|
||||
|
||||
setProperty(
|
||||
"archivesBaseName",
|
||||
|
||||
@ -69,14 +69,14 @@ public class MusicPlayerForegroundService extends Service {
|
||||
// 服务启动时调用
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
|
||||
Log.d("MusicPlayerService", "=========onStartCommand---------");
|
||||
audioItem = (AudioItem) intent.getSerializableExtra("Path"); // 获取音频路径
|
||||
|
||||
if (audioItem != null) {
|
||||
String newAudioPath = audioItem.getFile();
|
||||
// 如果新音频路径不同于当前路径,则重新初始化播放器
|
||||
if (newAudioPath != null && !newAudioPath.equals(currentAudioPath)) {
|
||||
// Log.d("MusicPlayerService", "检测到新的音频路径,初始化播放器");
|
||||
|
||||
currentAudioPath = newAudioPath; // 更新路径
|
||||
stopAndResetMediaPlayer(); // 停止并重置播放器
|
||||
initializePlayer(newAudioPath); // 初始化播放器
|
||||
@ -103,7 +103,7 @@ public class MusicPlayerForegroundService extends Service {
|
||||
return new NotificationCompat.Builder(this, CHANNEL_ID)
|
||||
.setContentTitle("Playing audio") // 通知标题
|
||||
.setContentText("Your audio is playing") // 通知内容
|
||||
.setSmallIcon(R.drawable.home_select) // 小图标
|
||||
.setSmallIcon(R.drawable.music_player_launch) // 小图标
|
||||
.setContentIntent(pendingIntent) // 点击通知的Intent
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW) // 低优先级
|
||||
.build();
|
||||
@ -160,12 +160,12 @@ public class MusicPlayerForegroundService extends Service {
|
||||
});
|
||||
|
||||
// 播放错误监听
|
||||
mediaPlayer.setOnErrorListener((mp, what, extra) -> {
|
||||
Log.e("MusicPlayerService", "播放时发生错误: " + what + ", 额外信息: " + extra);
|
||||
isPlaying.postValue(false); // 更新状态
|
||||
// stopSelf(); // 播放出错后停止服务
|
||||
return true; // 表示错误已处理
|
||||
});
|
||||
// mediaPlayer.setOnErrorListener((mp, what, extra) -> {
|
||||
// Log.e("MusicPlayerService", "播放时发生错误: " + what + ", 额外信息: " + extra);
|
||||
// isPlaying.postValue(false); // 更新状态
|
||||
//// stopSelf(); // 播放出错后停止服务
|
||||
// return true; // 表示错误已处理
|
||||
// });
|
||||
|
||||
} catch (IOException | IllegalArgumentException | IllegalStateException e) {
|
||||
Log.e("MusicPlayerService", "初始化播放器失败,路径: " + path, e);
|
||||
@ -346,7 +346,6 @@ public class MusicPlayerForegroundService extends Service {
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.d("nowtotal","run11");
|
||||
if (mediaPlayer != null && mediaPlayer.isPlaying()) {
|
||||
Log.d("nowtotal","run222");
|
||||
currentPosition.postValue(mediaPlayer.getCurrentPosition());
|
||||
|
||||
@ -22,7 +22,7 @@ import java.util.Locale;
|
||||
|
||||
public class A_HomeActivity extends BaseActivity<ActivityAhomeBinding> {
|
||||
|
||||
private MusicPlayerForegroundService musicService; // 音乐播放服务
|
||||
public static MusicPlayerForegroundService musicService; // 音乐播放服务
|
||||
private boolean isBound = false; // 服务是否绑定
|
||||
|
||||
private final int[] defaultIcons = {R.drawable.home_unselect, R.drawable.import_unselect}; // 默认图标
|
||||
@ -55,8 +55,8 @@ public class A_HomeActivity extends BaseActivity<ActivityAhomeBinding> {
|
||||
@Override
|
||||
protected void onCreateInit() {
|
||||
Intent serviceIntent = new Intent(this, MusicPlayerForegroundService.class);
|
||||
startService(serviceIntent); // 启动音乐播放服务
|
||||
bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE); // 绑定服务
|
||||
startService(serviceIntent);
|
||||
|
||||
// 初始化界面
|
||||
vb.homeContainer.setVisibility(View.GONE);
|
||||
|
||||
@ -223,19 +223,21 @@ public class A_PlayActivity extends BaseActivity<ActivityAplayBinding> {
|
||||
if (isBound && musicService!= null) {
|
||||
// 观察当前播放进度
|
||||
musicService.getCurrentPositionLiveData().observe(this, position -> {
|
||||
Integer duration = musicService.getDurationLiveData().getValue();
|
||||
if (duration!= null && duration > 0) {
|
||||
// Integer duration = musicService.getDurationLiveData().getValue();
|
||||
int duration = musicService.getDuration();
|
||||
if (duration > 0) {
|
||||
vb.songSeekbar.setProgress((int) ((position / (float) duration) * 100));
|
||||
vb.current.setText(formatTime(position));
|
||||
Log.d("nowtotal","current");
|
||||
Log.d("nowtotal","current position="+position);
|
||||
}
|
||||
});
|
||||
|
||||
// 观察音频总时长
|
||||
musicService.getDurationLiveData().observe(this, duration -> {
|
||||
if (duration!= null) {
|
||||
vb.time.setText(formatTime(duration));
|
||||
Log.d("nowtotal","time");
|
||||
int duration1 = musicService.getDuration();
|
||||
if (duration1>0) {
|
||||
vb.time.setText(formatTime(duration1));
|
||||
Log.d("nowtotal","time duration="+duration1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -76,7 +76,6 @@ public class A_SplashActivity extends BaseActivity<ActivityAsplashBinding> {
|
||||
public void onClick(View v) {
|
||||
|
||||
}
|
||||
|
||||
private void enterHome() {
|
||||
String stringValue = Sp.getInstance().getStringValue(RemoteConfigJava.key_open_type);
|
||||
Intent intent;
|
||||
|
||||
@ -158,7 +158,7 @@
|
||||
android:layout_marginBottom="8dp"
|
||||
android:max="100"
|
||||
android:padding="8dp"
|
||||
android:progress="50"
|
||||
android:progress="0"
|
||||
android:progressDrawable="@drawable/custom_seekbar_progress"
|
||||
android:thumb="@drawable/custom_seekbar_thumb"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/top_container"
|
||||
|
||||
@ -18,4 +18,5 @@ android.useAndroidX=true
|
||||
# Enables namespacing of each library's R class so that its R class includes only the
|
||||
# resources declared in the library itself and none from the library's dependencies,
|
||||
# thereby reducing the size of the R class for that library
|
||||
android.nonTransitiveRClass=true
|
||||
android.nonTransitiveRClass=true
|
||||
android.enableJetifier=true
|
||||
Loading…
Reference in New Issue
Block a user