Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/audioplayers/lib/src/audioplayer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const _uuid = Uuid();
/// hooks for handlers and callbacks.
class AudioPlayer {
static final global = GlobalAudioScope();
static Duration preparationTimeout = const Duration(seconds: 30);
static Duration seekingTimeout = const Duration(seconds: 30);

final _platform = AudioplayersPlatformInterface.instance;

/// This is the [AudioCache] instance used by this player.
Expand Down Expand Up @@ -291,7 +294,7 @@ class AudioPlayer {
await creatingCompleter.future;

final futureSeekComplete =
onSeekComplete.first.timeout(const Duration(seconds: 30));
onSeekComplete.first.timeout(AudioPlayer.seekingTimeout);
final futureSeek = _platform.seek(playerId, position);
// Wait simultaneously to ensure all errors are propagated through the same
// future.
Expand Down Expand Up @@ -357,7 +360,7 @@ class AudioPlayer {

final preparedFuture = _onPrepared
.firstWhere((isPrepared) => isPrepared)
.timeout(const Duration(seconds: 30));
.timeout(AudioPlayer.preparationTimeout);
// Need to await the setting the source to propagate immediate errors.
final setSourceFuture = setSource();

Expand Down