@capgo/native-audio 6.4.21 → 6.4.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/android/src/main/java/ee/forgr/audio/AudioAsset.java +11 -0
- package/android/src/main/java/ee/forgr/audio/AudioCompletionListener.java +5 -0
- package/android/src/main/java/ee/forgr/audio/AudioDispatcher.java +1 -1
- package/android/src/main/java/ee/forgr/audio/NativeAudio.java +2 -0
- package/android/src/main/java/ee/forgr/audio/RemoteAudioAsset.java +3 -0
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -13,6 +13,7 @@ public class AudioAsset {
|
|
|
13
13
|
private int playIndex = 0;
|
|
14
14
|
private final String assetId;
|
|
15
15
|
protected final NativeAudio owner;
|
|
16
|
+
protected AudioCompletionListener completionListener;
|
|
16
17
|
|
|
17
18
|
AudioAsset(
|
|
18
19
|
NativeAudio owner,
|
|
@@ -167,4 +168,14 @@ public class AudioAsset {
|
|
|
167
168
|
|
|
168
169
|
return audioList.get(playIndex).isPlaying();
|
|
169
170
|
}
|
|
171
|
+
|
|
172
|
+
public void setCompletionListener(AudioCompletionListener listener) {
|
|
173
|
+
this.completionListener = listener;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
protected void notifyCompletion() {
|
|
177
|
+
if (completionListener != null) {
|
|
178
|
+
completionListener.onCompletion(this.assetId);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
170
181
|
}
|
|
@@ -504,6 +504,7 @@ public class NativeAudio
|
|
|
504
504
|
audioChannelNum,
|
|
505
505
|
volume
|
|
506
506
|
);
|
|
507
|
+
remoteAudioAsset.setCompletionListener(this::dispatchComplete);
|
|
507
508
|
audioAssetList.put(audioId, remoteAudioAsset);
|
|
508
509
|
} else if (
|
|
509
510
|
uri.getScheme() != null && uri.getScheme().equals("file")
|
|
@@ -535,6 +536,7 @@ public class NativeAudio
|
|
|
535
536
|
audioChannelNum,
|
|
536
537
|
volume
|
|
537
538
|
);
|
|
539
|
+
asset.setCompletionListener(this::dispatchComplete);
|
|
538
540
|
audioAssetList.put(audioId, asset);
|
|
539
541
|
} else {
|
|
540
542
|
throw new IllegalArgumentException(
|
|
@@ -45,6 +45,9 @@ public class RemoteAudioAsset extends AudioAsset {
|
|
|
45
45
|
isPrepared = true;
|
|
46
46
|
Log.d(TAG, "MediaPlayer prepared for " + uri.toString());
|
|
47
47
|
});
|
|
48
|
+
mediaPlayer.setOnCompletionListener(mp -> {
|
|
49
|
+
notifyCompletion();
|
|
50
|
+
});
|
|
48
51
|
mediaPlayer.setOnErrorListener((mp, what, extra) -> {
|
|
49
52
|
Log.e(TAG, "MediaPlayer error: " + what + ", " + extra);
|
|
50
53
|
return false;
|