Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
用于AudioCache播放本地资源时,它有一个播放方法:
AudioCache
AudioCache audioPlayer = AudioCache(); await audioPlayer.play('alert_tone.mp3');
但是没有停止方法。我怎样才能阻止它?
所有AudioCache启动音频的方法都返回一个AudioPlayerused 的实例(可以是全新的一个或fixedPlayer一个)。
AudioPlayer
fixedPlayer
您可以使用该返回值来停止它:
AudioCache cache = AudioCache(); AudioPlayer player = await cache.play('alert_tone.mp3'); // ... await player.stop();
或使用由audioplayers.
audioplayers