Skip to content

Commit 6cfb375

Browse files
authored
fix(android): Avoid calling onDuration on position event (closes #136) (#1460)
# Description Unlike on other platforms, onDuration is constantly called on Android. This PR avoids calling onDuration on every position event. OnDuration is still once called with the correct duration after having prepared the source.
1 parent 7ae70ff commit 6cfb375

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

packages/audioplayers/example/.metadata

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This file should be version controlled.
55

66
version:
7-
revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
7+
revision: 62bd79521d8d007524e351747471ba66696fc2d4
88
channel: stable
99

1010
project_type: app
@@ -13,11 +13,26 @@ project_type: app
1313
migration:
1414
platforms:
1515
- platform: root
16-
create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
17-
base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
16+
create_revision: 62bd79521d8d007524e351747471ba66696fc2d4
17+
base_revision: 62bd79521d8d007524e351747471ba66696fc2d4
1818
- platform: android
19-
create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
20-
base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
19+
create_revision: 62bd79521d8d007524e351747471ba66696fc2d4
20+
base_revision: 62bd79521d8d007524e351747471ba66696fc2d4
21+
- platform: ios
22+
create_revision: 62bd79521d8d007524e351747471ba66696fc2d4
23+
base_revision: 62bd79521d8d007524e351747471ba66696fc2d4
24+
- platform: linux
25+
create_revision: 62bd79521d8d007524e351747471ba66696fc2d4
26+
base_revision: 62bd79521d8d007524e351747471ba66696fc2d4
27+
- platform: macos
28+
create_revision: 62bd79521d8d007524e351747471ba66696fc2d4
29+
base_revision: 62bd79521d8d007524e351747471ba66696fc2d4
30+
- platform: web
31+
create_revision: 62bd79521d8d007524e351747471ba66696fc2d4
32+
base_revision: 62bd79521d8d007524e351747471ba66696fc2d4
33+
- platform: windows
34+
create_revision: 62bd79521d8d007524e351747471ba66696fc2d4
35+
base_revision: 62bd79521d8d007524e351747471ba66696fc2d4
2136

2237
# User provided section
2338

packages/audioplayers_android/android/src/main/kotlin/xyz/luan/audioplayers/AudioplayersPlugin.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,7 @@ class AudioplayersPlugin : FlutterPlugin, IUpdateCallback {
290290
continue
291291
}
292292
isAnyPlaying = true
293-
val duration = player.getDuration()
294293
val time = player.getCurrentPosition()
295-
player.eventHandler.success("audio.onDuration", hashMapOf("value" to (duration ?: 0)))
296294
player.eventHandler.success("audio.onCurrentPosition", hashMapOf("value" to (time ?: 0)))
297295
}
298296
if (isAnyPlaying) {

0 commit comments

Comments
 (0)