# speech_play **Repository Path**: xiaofei9070/speech_play ## Basic Information - **Project Name**: speech_play - **Description**: 语音播放自动调整听筒 - **Primary Language**: Dart - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-05-05 - **Last Updated**: 2025-06-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # speech_play 语音播放功能,能自动切换听筒 ## Getting Started ```agsl final speechPlay = SpeechPlay(); // 初始化 ``` ```agsl // 注册以下监听方法 Future initPlay() async{ speechPlay.addEventListener( onListenerCompleted: (Map data) async{ print(data); }, onListenerPlayTime: (Map data) async { print(data); } ); } ``` ```agsl TextButton( onPressed: () { speechPlay.speechPlay('https://xxxx.com/xxx.mp3', 0, 100) .then((time){ print(time); }); }, child: Text('播放语音') ), TextButton( onPressed: () { speechPlay.pausePlay().then((time) { print(time); }); }, child: Text('暂停播放') ), TextButton( onPressed: () { speechPlay.cancelPause(); }, child: Text('取消暂停') ), TextButton( onPressed: () { speechPlay.playSeekTo(10 * 1000); }, child: Text('跳转到第10秒') ), TextButton( onPressed: () { speechPlay.switchSpeaker(true); }, child: Text('切换扬声器') ), TextButton( onPressed: () { speechPlay.switchSpeaker(false); }, child: Text('切换听筒') ), ```