2018-09-17 17:50:36 +02:00
|
|
|
import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
|
2017-05-09 23:31:57 +02:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @beta
|
|
|
|
* @name Native Ringtones
|
|
|
|
* @description
|
|
|
|
* The plugin helps get the native ringtones list on Android or IOS devices.
|
|
|
|
* And you can also use this plugin to play or stop the native ringtones and custom ringtones(added in the www folder).
|
|
|
|
*
|
|
|
|
* @usage
|
|
|
|
* ```
|
|
|
|
* import { NativeRingtones } from '@ionic-native/native-ringtones';
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* constructor(private ringtones: NativeRingtones) { }
|
|
|
|
*
|
|
|
|
* ...
|
|
|
|
* this.ringtones.getRingtone().then((ringtones) => { console.log(ringtones); });
|
|
|
|
*
|
|
|
|
* this.ringtones.playRingtone('assets/ringtones/sound_1.caf');
|
|
|
|
*
|
|
|
|
* this.ringtones.stopRingtone('assets/ringtones/sound_1.caf');
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
@Plugin({
|
|
|
|
pluginName: 'native-ringtones',
|
|
|
|
plugin: 'cordova-plugin-native-ringtones',
|
|
|
|
pluginRef: 'cordova.plugins.NativeRingtones',
|
|
|
|
repo: 'https://github.com/TongZhangzt/cordova-plugin-native-ringtones',
|
|
|
|
platforms: ['Android', 'iOS']
|
|
|
|
})
|
|
|
|
@Injectable()
|
|
|
|
export class NativeRingtones extends IonicNativePlugin {
|
2018-03-16 22:04:01 +01:00
|
|
|
|
2017-05-09 23:31:57 +02:00
|
|
|
/**
|
|
|
|
* Get the ringtone list of the device
|
|
|
|
* @return {Promise<any>} Returns a promise that resolves when ringtones found successfully
|
|
|
|
*/
|
|
|
|
@Cordova()
|
2018-03-16 22:04:01 +01:00
|
|
|
getRingtone(): Promise<any> { return; }
|
2017-05-09 23:31:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This function starts playing the ringtone
|
|
|
|
* @param {string} ringtoneUri The path to the ringtone file
|
|
|
|
* @return {Promise<any>} Returns a promise
|
|
|
|
*/
|
|
|
|
@Cordova()
|
2018-03-16 22:04:01 +01:00
|
|
|
playRingtone(ringtoneUri: string): Promise<any> { return; }
|
2017-05-09 23:31:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This function stops playing the ringtone
|
|
|
|
* @param {string} ringtoneUri The path to the ringtone file
|
|
|
|
* @return {Promise<any>} Returns a promise
|
|
|
|
*/
|
|
|
|
@Cordova()
|
2018-03-16 22:04:01 +01:00
|
|
|
stopRingtone(ringtoneUri: string): Promise<any> { return; }
|
2017-05-09 23:31:57 +02:00
|
|
|
}
|