Save Music as a ringtone in Windows Phone

Source: Internet
Author: User

 

1. The file must be in MP3 or WMA format.

2. The length of the ringtone file must be less than 40 seconds.

3. No copyright restrictions on ringtone files

4. The ringtone file size must be smaller than 1 MB.

In actual processing, the file we want to save as a ringtone is likely to be a complete song with a size greater than 1 MB. So how can we save the song climax as a ringtone? For example, "on the beach" definitely wants to save what is "on the waves, on the waves.

According to some of my non-professional understandings: a song generally has two reincarts, and the climax usually appears at the end of each cycle, that is, between 1/4 and 1/3 of a song. Then we can save that part as another file.

The Demo below demonstrates how to save a part of a local song as a ringtone.

First, let's take a look at the intercepted code:

The code is as follows: Copy code

Private void save1_iso ()
{
Stream stream = App. GetResourceStream (new Uri ("mangoRingtones; component/beat_it.mp3", UriKind. Relative). Stream;

// Read some of them
Stream. Seek (stream. Length/4, 0 );
Byte [] buffer = new byte [stream. Length/3-stream. Length/4];
Stream. Read (buffer, 0, buffer. Length );

// Save into isostore
Using (var isostore = IsolatedStorageFile. GetUserStoreForApplication ())
    {
Using (var indium = isostore. OpenFile (fileName, FileMode. OpenOrCreate, FileAccess. Write ))
        {
Indium. Write (buffer, 0, buffer. Length );
        }
    }

Stream. Close ();
Stream. Dispose ();


} Read the stream from the local device and save the part as another file.

Let's take a look at how we save the audio file as a ringtone on Windows Phone.

The code is as follows: Copy code

SaveRingtoneTask task = new SaveRingtoneTask ();
Task. DisplayName = "beat it ";
Task. Source = new Uri (@ "isostore:/" + fileName );
Task. Completed + = new EventHandler <TaskEventArgs> (task_Completed );
Task. Show (); note that you can use the new Uri (@ "isostore:/" + fileName); Method to reference files in an independent bucket.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.