Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Hiraqui/cordova-plugin-ringtone
A Cordova / Phonegap ringtone plugin for Android
https://github.com/Hiraqui/cordova-plugin-ringtone
Last synced: about 2 months ago
JSON representation
A Cordova / Phonegap ringtone plugin for Android
- Host: GitHub
- URL: https://github.com/Hiraqui/cordova-plugin-ringtone
- Owner: Hiraqui
- License: gpl-3.0
- Created: 2015-03-16T05:44:34.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-04T15:38:31.000Z (over 7 years ago)
- Last Synced: 2024-07-11T18:15:38.625Z (3 months ago)
- Language: Java
- Size: 23.4 KB
- Stars: 6
- Watchers: 4
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# com.hiraqui.ringtone v0.6.1
Ringtone
======A Cordova / Phonegap ringtone plugin for Android. Set an audio file as ringtone, notification tone or alarm tone.
cordova plugin add https://github.com/Hiraqui/cordova-plugin-ringtone
orcordova plugin add com.hiraqui.ringtone
Methods
-------- window.ringtone.setRingtone
- window.ringtone.exportAssetAndSetRingtonewindow.ringtone.setRingtone
=================Set a sound file as default Ringtone, notification tone or alarm tone
param {String}
file The path to the audio file ("file:..." or "/android_asset/www/...")
param {String}
title The title shown on the ringtone selection screen
param {String}
artist The artist for the file, set to null or "" to use the name of the Application as artist
param {String}
type The type of sound you want to set ["ringtone"|"notification"|"alarm"]
param {Function}
successCallback The function to call when the heading data is available
param {Function}
errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
window.ringtone.setRingtone(file, title, artist, type, successCallback, errorCallback)window.ringtone.exportAssetAndSetRingtone
=================Copy an asset sound file to the sdcard or app directory and set it as Ringtone, notification tone or alarm tone
*If you have a writable sdcard the new file is created in "sdcard/Ringtones/myFile.mp3"
*If the sdcard is not writable or if it is missing, the new file is created inside the application folder "data/com.hiraqui.myApplication/ringtones/myFile.mp3"param {String}
file The path to the asset audio file ("/android_asset/www/...")
param {String}
title The title shown on the ringtone selection screen
param {String}
artist The artist for the exported file, set to null or "" to use the name of the Application as artist
param {String}
type The type of sound you want to set ["ringtone"|"notification"|"alarm"]
param {Function}
successCallback The function to call when the heading data is available
param {Function}
errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
window.ringtone.exportAssetAndSetRingtone(file, title, artist, type, successCallback, errorCallback)Supported Platforms
-------------------- Android
Example 1
---------//Seting a sound file from the "www" folder as ringtone
window.ringtone.setRingtone("/android_asset/www/sounds/beep.wav",
"Beep", null, "ringtone",
function(success) {
alert(success);
},
function(err) {
alert(err);
})
Example 2
---------//Seting a sound file from the SD card as notification tone
window.ringtone.setRingtone("file:///storage/sdcard/Android/data/com.hiraqui.myApplication/files/beep.mp3",
"Beep", "Myself", "notification",
function(success) {
alert(success);
},
function(err) {
alert(err);
})Example 3
---------//Seting a sound file from the "www/sounds" folder as ringtone after copying it to another folder
window.ringtone.exportAssetAndSetRingtone("/android_asset/www/sounds/beep.wav",
"Beep", "", "alarm",
function(success) {
alert(success);
},
function(err) {
alert(err);
})Permissions
-----------android.permission.WRITE_SETTINGS
android.permission.READ_EXTERNAL_STORAGE
android.permission.WRITE_EXTERNAL_STORAGE
NOTE: Using sdk 23 or Android 6.0 global permission WRITE_SETTINGS is not allowed.
There are two solutions:
+ Restrict sdk to 22 or lower
+ Use https://github.com/dpa99c/cordova-diagnostic-plugin to prompt app permission before using this plugin