flame icon indicating copy to clipboard operation
flame copied to clipboard

Jitter on first play

Open lukepighetti opened this issue 1 year ago • 2 comments

FlameAudio.audioCache.loadAll(..) does not improve first play jitter

You have to play each of them with a volume of 0 to remove first play jitter

tick.m4a.zip

flame_audio: ^2.1.7
Flutter 3.16.8 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 67457e669f (3 weeks ago) • 2024-01-16 16:22:29 -0800
Engine • revision 6e2ea58a5c
Tools • Dart 3.2.5 • DevTools 2.28.5
import 'dart:developer';

import 'package:flame_audio/flame_audio.dart';

final $audio = AudioService();

class AudioService {
  Future<void> setup() async {
    final assets = ['tick.m4a'];

    await FlameAudio.audioCache.loadAll(assets);

    for (final x in assets) {
      // this is required to remove drift on first play, loadAll isn't enough
      FlameAudio.play(x, volume: 0);
    }

    log(name: 'audio', 'warmed up');
  }

  void playTick() => FlameAudio.play('tick.m4a');
}

lukepighetti avatar Feb 07 '24 13:02 lukepighetti

Does this affect all platforms (part of the template you removed :wink:)?

spydon avatar Feb 07 '24 13:02 spydon

@lukepighetti?

spydon avatar Feb 14 '24 21:02 spydon

Closing this since there was no reply.

spydon avatar May 27 '24 17:05 spydon