Skip to content

Commit a171746

Browse files
authored
Merge pull request svga#379 from SakyaZsl/fix_audio_error_not_callback
fix: fixed some cases where svga contains mp3 files and cannot be called back normally
2 parents 3c8b653 + fc2d35e commit a171746

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

app/src/main/assets/jojo_audio.svga

124 KB
Binary file not shown.

app/src/main/java/com/example/ponycui_home/svgaplayer/AnimationFromAssetsActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ public void onClick(View view) {
3737

3838
private void loadAnimation() {
3939
SVGAParser svgaParser = SVGAParser.Companion.shareParser();
40-
String name = this.randomSample();
40+
// String name = this.randomSample();
41+
//asset jojo_audio.svga cannot callback
42+
String name = "jojo_audio.svga";
4143
Log.d("SVGA", "## name " + name);
4244
svgaParser.setFrameSize(100, 100);
4345
svgaParser.decodeFromAssets(name, new SVGAParser.ParseCompletion() {

library/src/main/java/com/opensource/svgaplayer/SVGAVideoEntity.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,15 @@ class SVGAVideoEntity {
187187
}
188188
setupSoundPool(entity, completionBlock)
189189
val audiosFileMap = generateAudioFileMap(entity)
190+
/**
191+
* repair audio error it not callback
192+
audiosFileMap.size==0 soundPool?.load will not go
193+
setOnLoadCompleteListener will not run
194+
completionBlock not run cannot callback
195+
*/
196+
if(audiosFileMap.size==0){
197+
run(completionBlock)
198+
}
190199
this.audioList = entity.audios.map { audio ->
191200
return@map createSvgaAudioEntity(audio, audiosFileMap)
192201
}

0 commit comments

Comments
 (0)