Windows-8.1

How to save ringtone in Windows phone using SaveRingtone Task

This is the sixth blog post of this series in which I am going to tell you about how to save a media file as ringtone of your Windows phone using SaveRingtone Task.
This task launches the Ringtones application, where the user saves the ringtone and can optionally set it as their default ringtone. Once the audio file is added to the list, the user can set it as the ringtone for individual contacts in the Contacts application.

Ringtone audio files must meet the following requirements.

  • Files must be of type M4R, MP3, or WMA.
  • Files must be less than 30 MB in size.
  • Files must not have digital rights management (DRM) protection.

 

Follow the steps given below

1. First create a new project Ringtonetask.

 


 

2. Before going further add the following namespace in the MainPage.xaml.cs. This namespace is required for email tasks in windows phone app.

  3. Create a button on the MainPage and add the following code given below in the click event handler of the button to launch a SaveRingtoneTask.  

The task has got different properties the important one is the source which defines the path of music file in the application.


Note:
Use appdata: for audio files that are part of the application project. They are bundled into the XAP file and stored in the installation directory of the application. Use isostore: for audio files that are stored in isolated storage.

 

The event handler which we need to concentrate now is the Ringtone_Save_completed event handler.

Just below the code of button click event handler add the following code of Ringtone_Save_completed event handler which gives a confirmation message to user.

4. Now just launch the application and click on the save button.

 


 

5. You will see the following message on your screen.

 


 

6. If you have any doubts related to this post you can download the full source project file from the link given below.

Download Full source project file Ringtonetask.zip

Chetan Gulati

Currently am doing B TECH in IT from Delhi Technological University. App development is my passion. Believe in quality rather than quantity.

Read more:
How to create your first Windows Phone app
How to change the App name and Tile name of your Windows phone app
Data binding in Windows Phone app – One way binding
Close