The Ringtones API helps get the native ringtones list on devices. And you can also use this API to play or stop the native ringtones and custom ringtones.
Ringtones.getRingtone(Ringtones.RingtoneType.RINGTONE)
.then((result) => {
result.forEach( ring =>{
console.log(ring.Name,ring.Url);
});
})
.catch((error) => {
console.error(error);
});
window.Ringtones.getRingtone(window.Ringtones.RingtoneType.RINGTONE)
.then((result) => {
result.forEach((ring) => {
console.log(ring.Name, ring.Url);
});
})
.catch((error) => {
console.error(error);
});
window.Ringtones.getRingtone(window.Ringtones.RingtoneType.RINGTONE)
.then((result) => {
result.forEach((ring) => {
console.log(ring.Name, ring.Url);
});
})
.catch((error) => {
console.error(error);
});
(<any>window).Ringtones.getRingtone((window).Ringtones.RingtoneType.RINGTONE)
.then((result) => {
result.forEach((ring) => {
console.log(ring.Name, ring.Url);
});
})
.catch((error) => {
console.error(error);
});
window.Ringtones.getRingtone(window.Ringtones.RingtoneType.RINGTONE)
.then((result) => {
result.forEach((ring) => {
console.log(ring.Name, ring.Url);
});
})
.catch((error) => {
console.error(error);
});
getRingtone(type?: RingtoneType): Promise<RingtoneResult >
Get the system ringtone list by type.
playRingtone(ringtoneUri : string): Promise<any>
Play a ringtone by passing the URI of this ringtone.
stopRingtone(ringtoneUri : string): Promise<any>
Stop a ringtone by passing the URI of this ringtone.
RingtoneResult { Name: String; // Display name Url: string; // File URL }
enum RingtoneType {
NOTIFICATION : 'notification',// Default
ALARM : 'alarm',
RINGTONE : 'ringtone'
}