title: Playing the same audio file multiple times - Audioplayers Flutter
body: <p>How can I play the same audio file as many times as I want, not loop but I want the possibility to precise how many times, I followed this <a href="https://github.com/vijayinyoutube/audioplayer/blob/master/lib/main.dart" rel="nofollow noreferrer">tutorial</a> to make the basics which mean the play/pause function. And I'm struggling with the rest.
  I use the last version of the <a href="https://pub.dev/packages/audioplayers" rel="nofollow noreferrer">audioplayers</a> package.</p>
  <p>This is my code :</p>
  <pre><code>import 'package:flutter/material.dart';
  import 'package:audioplayers/audioplayers.dart';
  import 'package:audioplayers/audio_cache.dart';
  
  
  class Player extends StatefulWidget {
    @override
    _PlayerState createState() =&gt; _PlayerState();
  }
  
  AnimationController _animationIconController ;
  
  AudioCache audioCache;
  AudioPlayer audioPlayer;
  
  
  bool issongplaying = false;
  bool isplaying = false;
  
  
  
  class _PlayerState extends State&lt;Player&gt; with TickerProviderStateMixin {
    @override
    void initState() {
      // TODO: implement initState
      super.initState();
      initPlayer();
    }
  
    void initPlayer(){
      _animationIconController = AnimationController(
        vsync: this,
        duration: Duration(milliseconds: 750),
        reverseDuration: Duration(milliseconds: 750),
      );
      audioPlayer = new AudioPlayer();
      audioCache = new AudioCache(fixedPlayer: audioPlayer);
     
    }
  
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        backgroundColor: Colors.white,
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              GestureDetector(
                onTap: (){
                  setState((){
                    isplaying
                    ? _animationIconController.reverse()
                    : _animationIconController.forward();
                    isplaying = !isplaying;
                  });
  
                  if (issongplaying == false) {
                    audioCache.play('audio.wav');
                    setState(() {
                      issongplaying = true;
                    });
                  } else {
                    audioPlayer.pause();
                    setState(() {
                      issongplaying = false;
                    });
                  }
                },
                child: ClipOval(
                  child: Container(
                    decoration: BoxDecoration(
                      border: Border.all(
                      width: 2,
                        color: Colors.greenAccent,
                      ),
                      borderRadius: BorderRadius.all(Radius.circular(50.0)
                      ),
                    ),
                    width: 75,
                    height: 75,
                    child: Center(
                      child: AnimatedIcon(
                        icon: AnimatedIcons.play_pause,
                        progress: _animationIconController,
                        color: Colors.grey,
                        size: 60,
                      )
                    ),
                  ),
                ),
              )
            ],
          ),
        ),
      );
    }
  }
  </code></pre>
  <p>Thank you</p>