flutter_ringtone_player
सिस्टम के डिफ़ॉल्ट रिंगटोन, अलार्म और सूचनाओं के लिए एक सरल प्लेयर
रिंगटोन, अलार्म और सूचना ध्वनियों को चलाने के लिए सरल Flutter प्लगइन
यह अंग्रेज़ी मूल स्नैपशॉट है। नवीनतम सामग्री GitHub पर देखें।
A simple ringtone, alarm & notification player plugin.
Add following import to your code:
import 'package:flutter_ringtone_player/flutter_ringtone_player.dart';
Then simply call this to play system default notification sound:
FlutterRingtonePlayer().playNotification();
There's also this generic method allowing you to specify in detail what kind of ringtone should be played:
FlutterRingtonePlayer().play(
android: AndroidSounds.notification,
ios: IosSounds.glass,
looping: true, // Android only - API >= 28
volume: 0.1, // Android only - API >= 28
asAlarm: false, // Android only - all APIs
);
Also you can specify a custom ringtone from assets, or provide direct path to file that works for both Android and iOS:
FlutterRingtonePlayer().play(fromAsset: "assets/ringtone.wav");
FlutterRingtonePlayer().play(fromFile: "assets/ringtone.wav");
You can specify a platform specific ringtone and it will override the one from assets:
FlutterRingtonePlayer().play(
fromAsset: "assets/ringtone.wav", // will be the sound on Android
ios: IosSounds.glass // will be the sound on iOS
);
| Attribute | Description |
|---|---|
bool looping |
Enables looping of ringtone. Requires FlutterRingtonePlayer().stop(); to stop ringing. |
double volume |
Sets ringtone volume in range 0 to 1.0. |
bool asAlarm |
Allows to ignore device's silent/vibration mode and play given sound anyway. |
To stop looped ringtone please use:
FlutterRingtonePlayer().stop();
Above works only on Android, and please note that by default Alarm & Ringtone sounds are looped.
| Method | Android | iOS |
|---|---|---|
| playAlarm | RingtoneManager.TYPE_ALARM | IosSounds.alarm |
| playNotification | RingtoneManager.TYPE_NOTIFICATION | IosSounds.triTone |
| playRingtone | RingtoneManager.TYPE_RINGTONE | IosSounds.electronic |
If you want to use any other sound on iOS you can always specify a valid Sound ID and manually construct [IosSound]:
FlutterRingtonePlayer().play(
android: AndroidSounds.notification,
ios: const IosSound(1023),
looping: true,
volume: 0.1,
);
निर्भरता सूची 5 आइटम
{"sdk":"flutter"}^2.1.1^2.1.7{"sdk":"flutter"}>=3.0.1 <6.0.0उपयोग के अनुसार छाँटें, गतिविधि की तुलना करें और अपनाने से पहले मूल प्रोजेक्ट की आवश्यकताएँ जाँचें।
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗