19 lines
451 B
Dart
19 lines
451 B
Dart
import 'package:audioplayers/audioplayers.dart';
|
|
class SCMessageNotifier {
|
|
|
|
static bool canPlay = true;
|
|
static final AudioPlayer _a = AudioPlayer();
|
|
// 播放提示音
|
|
static Future<void> playNotificationSound() async {
|
|
if(!canPlay){
|
|
return;
|
|
}
|
|
// _audioPlayer.setVolume(0.2);
|
|
try {
|
|
_a.play(AssetSource("sc_images/msg/im_noti_music.MP3"));
|
|
} catch (e) {
|
|
print('播放提示音失败: $e');
|
|
}
|
|
}
|
|
|
|
} |