Skip to content

Commit

Permalink
fix(android): Avoid calling onDuration on position event (closes #136) (
Browse files Browse the repository at this point in the history
#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.
  • Loading branch information
Gustl22 authored Apr 6, 2023
1 parent 7ae70ff commit 6cfb375
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
25 changes: 20 additions & 5 deletions packages/audioplayers/example/.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file should be version controlled.

version:
revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
revision: 62bd79521d8d007524e351747471ba66696fc2d4
channel: stable

project_type: app
Expand All @@ -13,11 +13,26 @@ project_type: app
migration:
platforms:
- platform: root
create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
create_revision: 62bd79521d8d007524e351747471ba66696fc2d4
base_revision: 62bd79521d8d007524e351747471ba66696fc2d4
- platform: android
create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
create_revision: 62bd79521d8d007524e351747471ba66696fc2d4
base_revision: 62bd79521d8d007524e351747471ba66696fc2d4
- platform: ios
create_revision: 62bd79521d8d007524e351747471ba66696fc2d4
base_revision: 62bd79521d8d007524e351747471ba66696fc2d4
- platform: linux
create_revision: 62bd79521d8d007524e351747471ba66696fc2d4
base_revision: 62bd79521d8d007524e351747471ba66696fc2d4
- platform: macos
create_revision: 62bd79521d8d007524e351747471ba66696fc2d4
base_revision: 62bd79521d8d007524e351747471ba66696fc2d4
- platform: web
create_revision: 62bd79521d8d007524e351747471ba66696fc2d4
base_revision: 62bd79521d8d007524e351747471ba66696fc2d4
- platform: windows
create_revision: 62bd79521d8d007524e351747471ba66696fc2d4
base_revision: 62bd79521d8d007524e351747471ba66696fc2d4

# User provided section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,7 @@ class AudioplayersPlugin : FlutterPlugin, IUpdateCallback {
continue
}
isAnyPlaying = true
val duration = player.getDuration()
val time = player.getCurrentPosition()
player.eventHandler.success("audio.onDuration", hashMapOf("value" to (duration ?: 0)))
player.eventHandler.success("audio.onCurrentPosition", hashMapOf("value" to (time ?: 0)))
}
if (isAnyPlaying) {
Expand Down

0 comments on commit 6cfb375

Please sign in to comment.