title: play audio file from where i pause, not from the beginning in Audioplayers flutter package
body: <p>i am new in flutter ... I want to play audio file from where i pause, not from the beginning in <strong><code>audioplayers</code></strong> flutter package ...</p>
  
  <p>in this example there is just:
  1- play from the beginning 
  2- pause
  3- stop</p>
  
  <p>pause and stop they have same function because by pause i can not play from where i pause ...</p>
  
  <p>so what i want is to play from where i pause, in same button!</p>
  
  <p>the <strong><code>audioplayers</code></strong> package which I use </p>
  
  <blockquote>
    <p><a href="https://pub.dev/packages/audioplayers" rel="nofollow noreferrer">https://pub.dev/packages/audioplayers</a></p>
  </blockquote>
  
  <p>my code ... </p>
  
  <pre><code>import 'package:audioplayers/audio_cache.dart';
  import 'package:audioplayers/audioplayers.dart';
  import 'package:flutter/material.dart';
  
  typedef void OnError(Exception exception);
  
  void main() {
    runApp(new MaterialApp(debugShowCheckedModeBanner: false,home:  LocalAudio()));
  }
  
  class LocalAudio extends StatefulWidget {
    @override
    _LocalAudio createState() =&gt;  _LocalAudio();
  }
  
  class _LocalAudio extends State&lt;LocalAudio&gt; {
    Duration _duration = new Duration();
    Duration _position = new Duration();
    AudioPlayer advancedPlayer;
    AudioCache audioCache;
  
    @override
    void initState() {
      super.initState();
      initPlayer();
    }
  
    void initPlayer() {
      advancedPlayer = new AudioPlayer();
      audioCache = new AudioCache(fixedPlayer: advancedPlayer);
  
      advancedPlayer.durationHandler = (d) =&gt; setState(() {
            _duration = d;
          });
  
      advancedPlayer.positionHandler = (p) =&gt; setState(() {
            _position = p;
          });
    }
  
    String localFilePath;
  
    Widget _tab(List&lt;Widget&gt; children) {
      return Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: &lt;Widget&gt;[
          Container(
            padding: EdgeInsets.all(16.0),
            child: Column(
              children: children
                  .map((w) =&gt; Container(child: w, padding: EdgeInsets.all(6.0)))
                  .toList(),
            ),
          ),
        ],
      );
    }
  
    Widget _btn(String txt, VoidCallback onPressed) {
      return ButtonTheme(
        minWidth: 48.0,
        child: Container(
          width: 150,
          height: 45,
          child: RaisedButton(
              shape:
                  RoundedRectangleBorder(borderRadius: BorderRadius.circular(25)),
              child: Text(txt),
              color: Colors.pink[900],
              textColor: Colors.white,
              onPressed: onPressed),
        ),
      );
    }
  
    Widget slider() {
      return Slider(
          activeColor: Colors.black,
          inactiveColor: Colors.pink,
          value: _position.inSeconds.toDouble(),
          min: 0.0,
          max: _duration.inSeconds.toDouble(),
          onChanged: (double value) {
            setState(() {
              seekToSecond(value.toInt());
              value = value;
            });
          });
    }
  
    Widget LocalAudio() {
      return _tab([
        _btn('Play', () =&gt; audioCache.play('disco.mp3')),
        _btn('Pause', () =&gt; advancedPlayer.pause()),
        _btn('Stop', () =&gt; advancedPlayer.stop()),
        slider()
      ]);
    }
  
    void seekToSecond(int second) {
      Duration newDuration = Duration(seconds: second);
  
      advancedPlayer.seek(newDuration);
    }
  
    @override
    Widget build(BuildContext context) {
      return DefaultTabController(
        length: 1,
        child: Scaffold(
          backgroundColor: Colors.white,
          appBar: AppBar(
            elevation: 1.0,
            backgroundColor: Colors.teal,
            title: Center(child: Text('LOCAL AUDIO')),
          ),
          body: TabBarView(
            children: [LocalAudio()],
          ),
        ),
      );
    }
  }
  
  </code></pre>