Skip to content

Commit

Permalink
*release 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
zaaach committed Dec 4, 2020
1 parent 01da269 commit 715df22
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public void playOrPause() {
public void play(String path) {
//如果已处于播放,先停止再重新播放
if (mediaPlayer != null && !isIdle()){
mediaPlayer.stop();
stop();
}
doPlay(path);
}
Expand Down Expand Up @@ -325,6 +325,7 @@ public void restore() {
@Override
public void stop() {
abandonAudioFocus();
mHandler.removeCallbacks(timerRunnable);
if (isIdle()) return;
ALog.d(TAG, "======================stop()");
if (mediaPlayer != null) {
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ dependencies {
playerHelper = new AudioPlayerHelper(context)
.attachSeekBar(seekBar)//关联SeekBar
.setLooping(true)
.setInterval(500)//进度更新的间隔时间
.setDebug(true)
.setOnAudioPlayStateChangeListener(this)//播放器回调
.setDataSource("http://....")
.playOrPause();
//切换音乐
playerHelper.play("http://....");
```

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

@Override
public void onPrepared(MediaPlayer player, long duration) {
public void onPrepared(MediaPlayer player, int duration) {
}

@Override
public void onPlaying(MediaPlayer player) {
}

@Override
public void onProgress(MediaPlayer player, @Nullable SeekBar seekBar, boolean isDragging, long position, long duration) {
public void onProgress(MediaPlayer player, @Nullable SeekBar seekBar, boolean isDragging, int progress, int duration) {
}

@Override
Expand Down Expand Up @@ -121,7 +124,7 @@ protected void onDestroy() {
# License

```
Copyright (c) 2019 zaaach
Copyright (c) 2020 zaaach
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/zaaach/audioplayer/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public void onPlayStop(MediaPlayer player) {
@Override
public void onPlayComplete(MediaPlayer player) {
Log.e("Audio", "onPlayComplete");
tvTimer.setText("00:00 / " + formatTime(player.getDuration()));
count += 1;
playerHelper.play(MUSIC_URLS[count % 2]);
viewFlipper.showNext();
Expand Down

0 comments on commit 715df22

Please sign in to comment.