chore: Better call UX sounds and timeline design
This commit is contained in:
parent
87c534faf2
commit
c0244c66ab
9 changed files with 50 additions and 45 deletions
|
|
@ -1,7 +1,10 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'package:assets_audio_player/assets_audio_player.dart';
|
||||
import 'package:flutter_ringtone_player/flutter_ringtone_player.dart';
|
||||
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
|
||||
class UserMediaManager {
|
||||
factory UserMediaManager() {
|
||||
return _instance;
|
||||
|
|
@ -11,17 +14,27 @@ class UserMediaManager {
|
|||
|
||||
static final UserMediaManager _instance = UserMediaManager._internal();
|
||||
|
||||
Future<void> startRingingTone() {
|
||||
if (kIsWeb) {
|
||||
throw 'Platform [web] not supported';
|
||||
AssetsAudioPlayer? _assetsAudioPlayer;
|
||||
|
||||
Future<void> startRingingTone() async {
|
||||
if (PlatformInfos.isMobile) {
|
||||
await FlutterRingtonePlayer.playRingtone(volume: 80);
|
||||
} else if ((kIsWeb || PlatformInfos.isMacOS) &&
|
||||
_assetsAudioPlayer != null) {
|
||||
const path = 'assets/sounds/phone.ogg';
|
||||
final player = _assetsAudioPlayer = AssetsAudioPlayer.newPlayer();
|
||||
await player.open(Audio(path),
|
||||
autoStart: true, loopMode: LoopMode.playlist);
|
||||
}
|
||||
return FlutterRingtonePlayer.playRingtone(volume: 80);
|
||||
return;
|
||||
}
|
||||
|
||||
Future<void> stopRingingTone() {
|
||||
if (kIsWeb) {
|
||||
throw 'Platform [web] not supported';
|
||||
Future<void> stopRingingTone() async {
|
||||
if (PlatformInfos.isMobile) {
|
||||
await FlutterRingtonePlayer.stop();
|
||||
}
|
||||
return FlutterRingtonePlayer.stop();
|
||||
await _assetsAudioPlayer?.stop();
|
||||
_assetsAudioPlayer = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue