Skip to content

Commit 715df22

Browse files
author
zaaach
committed
*release 1.1
1 parent 01da269 commit 715df22

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

AudioPlayerHelper/src/main/java/com/zaaach/audioplayerhelper/AudioPlayerHelper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public void playOrPause() {
257257
public void play(String path) {
258258
//如果已处于播放,先停止再重新播放
259259
if (mediaPlayer != null && !isIdle()){
260-
mediaPlayer.stop();
260+
stop();
261261
}
262262
doPlay(path);
263263
}
@@ -325,6 +325,7 @@ public void restore() {
325325
@Override
326326
public void stop() {
327327
abandonAudioFocus();
328+
mHandler.removeCallbacks(timerRunnable);
328329
if (isIdle()) return;
329330
ALog.d(TAG, "======================stop()");
330331
if (mediaPlayer != null) {

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,13 @@ dependencies {
4040
playerHelper = new AudioPlayerHelper(context)
4141
.attachSeekBar(seekBar)//关联SeekBar
4242
.setLooping(true)
43+
.setInterval(500)//进度更新的间隔时间
4344
.setDebug(true)
4445
.setOnAudioPlayStateChangeListener(this)//播放器回调
4546
.setDataSource("http://....")
4647
.playOrPause();
48+
//切换音乐
49+
playerHelper.play("http://....");
4750
```
4851

4952
2、播放器回调
@@ -54,15 +57,15 @@ public void onPreparing(MediaPlayer player) {
5457
}
5558

5659
@Override
57-
public void onPrepared(MediaPlayer player, long duration) {
60+
public void onPrepared(MediaPlayer player, int duration) {
5861
}
5962

6063
@Override
6164
public void onPlaying(MediaPlayer player) {
6265
}
6366

6467
@Override
65-
public void onProgress(MediaPlayer player, @Nullable SeekBar seekBar, boolean isDragging, long position, long duration) {
68+
public void onProgress(MediaPlayer player, @Nullable SeekBar seekBar, boolean isDragging, int progress, int duration) {
6669
}
6770

6871
@Override
@@ -121,7 +124,7 @@ protected void onDestroy() {
121124
# License
122125

123126
```
124-
Copyright (c) 2019 zaaach
127+
Copyright (c) 2020 zaaach
125128
126129
Licensed under the Apache License, Version 2.0 (the "License");
127130
you may not use this file except in compliance with the License.

app/src/main/java/com/zaaach/audioplayer/MainActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ public void onPlayStop(MediaPlayer player) {
154154
@Override
155155
public void onPlayComplete(MediaPlayer player) {
156156
Log.e("Audio", "onPlayComplete");
157+
tvTimer.setText("00:00 / " + formatTime(player.getDuration()));
157158
count += 1;
158159
playerHelper.play(MUSIC_URLS[count % 2]);
159160
viewFlipper.showNext();

0 commit comments

Comments
 (0)