我想在启动画面中添加背景音频。所以尝试了下面的代码。但我有一些例外。 (颤振)

I want to add background audio in my splash screen. So tried the below code. But I got some exceptions. ( Flutter )

我想在启动画面中添加背景音频。所以尝试了下面的代码。但我有一些例外。任何人都请帮助我解决this.Here 我使用的是 Flutter Sound 包。

------------这是我的代码----------------

import 'dart:async';
import 'package:FlutterNewApp/Screens/HomeMain.dart';
import 'package:flutter/material.dart';
import 'package:animated_text_kit/animated_text_kit.dart';
import 'package:flutter_sound/flutter_sound.dart';
class Splash extends StatefulWidget {
  @override
  _SplashState createState() => _SplashState();
}
class _SplashState extends State<Splash> {
  @override
  void initState() {
    FlutterSound flutterSound = FlutterSound();
    flutterSound.thePlayer.startPlayer(fromURI: 'assets/audio/splash.mp3');//My splash.mp3 is inside the audio folder in assets folder    
    super.initState();
    Timer(
        Duration(minutes: 50),
        () => Navigator.pushReplacement(
            context, MaterialPageRoute(builder: (context) => HomeMain())));
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
        Center(
          child: AnimatedTextKit(
            totalRepeatCount: 1,
            //repeatForever: true,
            animatedTexts: [
            TyperAnimatedText(
              'Tofee Ride',
              //speed: Duration(milliseconds: 50),
              textStyle: TextStyle(
                fontFamily: 'Ultra-Regular',
                color: Colors.pink[600],
                fontSize: 30,
              )
              ),  
          ]),
        ),
        Center
        (child:AnimatedTextKit(
          totalRepeatCount: 1,
          //repeatForever: true,
          animatedTexts: [
          TyperAnimatedText('Learning App for classes I - IV')
        ]) ,)
      ],)
    );
  }
}

例外情况如下。请帮助。这里我用的是Flutter Sound包

This is the Exception I got

如异常消息中所述:“播放器未打开”

Flutter_sound 文档说:

  1. Open and close the audio session

Before calling startPlayer() you must open the Session.

When you have finished with it, you must close the session. A good places to put those verbs are in the procedures initState() and dispose().

@override
  void initState() {
    super.initState();
    // Be careful : openAudioSession return a Future.
    // Do not access your FlutterSoundPlayer or FlutterSoundRecorder before the completion of the Future
    _myPlayer.openAudioSession().then((value) {
      setState(() {
        _mPlayerIsInited = true;
      });
    });
  }



  @override
  void dispose() {
    // Be careful : you must `close` the audio session when you have finished with it.
    _myPlayer.closeAudioSession();
    _myPlayer = null;
    super.dispose();
  }

https://tau.canardoux.xyz/guides_getting_started.html#2-open-and-close-the-audio-session