Support the load initialPosition/initialIndex parameters on web.

This commit is contained in:
Ryan Heise 2020-10-16 14:23:34 +11:00
parent f38ff383f5
commit 082666d9d1
3 changed files with 34 additions and 12 deletions

View File

@ -114,6 +114,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.16.1"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3-nullsafety.1"
just_audio:
dependency: "direct main"
description:
@ -127,7 +134,7 @@ packages:
path: "../../just_audio_platform_interface"
relative: true
source: path
version: "1.1.0"
version: "1.2.0"
just_audio_web:
dependency: transitive
description:
@ -148,7 +155,7 @@ packages:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
version: "1.3.0-nullsafety.4"
path:
dependency: transitive
description:
@ -237,7 +244,7 @@ packages:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety.1"
version: "1.10.0-nullsafety.2"
stream_channel:
dependency: transitive
description:
@ -302,5 +309,5 @@ packages:
source: hosted
version: "0.1.2"
sdks:
dart: ">=2.10.0-110 <2.11.0"
dart: ">=2.10.0-110 <=2.11.0-213.1.beta"
flutter: ">=1.12.13+hotfix.5 <2.0.0"

View File

@ -182,11 +182,19 @@ class Html5AudioPlayer extends JustAudioPlayer {
print("web load");
_currentAudioSourcePlayer?.pause();
_audioSourcePlayer = getAudioSource(request.audioSourceMessage);
_index = 0;
_index = request.initialIndex ?? 0;
if (_shuffleModeEnabled) {
_audioSourcePlayer?.shuffle(0, _index);
}
return LoadResponse(duration: await _currentAudioSourcePlayer.load());
final duration = await _currentAudioSourcePlayer.load();
if (request.initialPosition != null) {
await _currentAudioSourcePlayer
.seek(request.initialPosition.inMilliseconds);
}
if (_playing) {
_currentAudioSourcePlayer.play();
}
return LoadResponse(duration: duration);
}
Future<Duration> loadUri(final Uri uri) async {

View File

@ -25,20 +25,27 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3-nullsafety.1"
just_audio_platform_interface:
dependency: "direct main"
description:
name: just_audio_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
path: "../just_audio_platform_interface"
relative: true
source: path
version: "1.2.0"
meta:
dependency: "direct main"
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
version: "1.3.0-nullsafety.4"
plugin_platform_interface:
dependency: transitive
description:
@ -66,5 +73,5 @@ packages:
source: hosted
version: "2.1.0-nullsafety.3"
sdks:
dart: ">=2.10.0-110 <2.11.0"
dart: ">=2.10.0-110 <=2.11.0-213.1.beta"
flutter: ">=1.12.13+hotfix.5"