How to play a custom sound in Flutter?

后端 未结 4 1231
感动是毒
感动是毒 2020-12-24 12:29

I was able to play a simple sound this line of code:

SystemSound.play(SystemSoundType.click);

How can I play a customized sound?

L

4条回答
  •  情深已故
    2020-12-24 13:29

    [Answer updated: this approach doesn't work, see comments] You can use the video_player plugin maintained by the Flutter team. It can reproduce many kinds of media across platforms, including sound files. More specifically, you may want to use the the VideoPlayerController class.

    eg.

       _controller = VideoPlayerController.network('https://www.example.com/soundsFile.wav');
       _controller.play();
    

提交回复
热议问题