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. |