Can you hear... my new WebTone? Downloading and setting a Windows Phone 7.1(5) ringtones easily and quickly...

One of the features of Mango/Windows Phone 7.1(5) that "real world" users (like my niece) seems to be excited about is custom ringtones. This has inspired a number of developers to provide app's to satisfy this desire.

Today's project highlights one such app. 

WebTone 1.1 Released in the Marketplace

The original release of WebTone made it into the Windows Phone Marketplace at the beginning of September, and after one or two issues that needed sorting during certification, version 1.1 is now released.

What’s New?

One of the frequently mentioned things in feedback emails was the lack of ability to download from a forum, or similar such hosting. The problem for this was the app was checking for .mp3 or .wma in the link. Now when it encounters a this kind of link, the app will ask you what file type it is...

WebTone now comes in more languages. Specifically: English, Spanish, Dutch, Italian, Chinese (Simplified), Chinese (Traditional)

What I thought cool was that Scott released the source to his app too, where he's still checking in code almost daily. Another thing I've not seen to often in Windows Phone 7.1(5) source available projects is additional language support.

Lets check it out;

image

Note: If you download the source and run into any issues with the GalaSoft references, they are just NuGet away. All the other references are there and it's very understandable that this actively being worked on code drop doesn't include those two DLL's (Can I just say how much I love NuGet?)

We were speaking of additional language support...

SNAGHTML37aa8b90

The meat of the project is the download. Not only does the app have to deal with all the "stuff" that's normal when downloading anything, but it also has to handle cases that are unique to Windows Phone 7.1(5) ringtones, such as file types and size, but also other Windows Phone cases like not having enough, and asking for more, isolated storage space.

private void DoDownload()
{
     Deployment.Current.Dispatcher.BeginInvoke(() =>
     {
         ProgressText = "downloading file...";
         IsIndeterminate = true;
         ProgressChanged = 0;
     });
     downloadMP3Client = new WebClient();
     
     downloadMP3Client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(downloadMP3Client_DownloadProgressChanged);
     downloadMP3Client.OpenReadCompleted += new OpenReadCompletedEventHandler(downloadMP3Client_OpenReadCompleted);
     downloadMP3Client.OpenReadAsync(FinalUrl);
}

void downloadMP3Client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
     Deployment.Current.Dispatcher.BeginInvoke(() =>
         {
             if (!e.Cancelled)
             {
                 if (e.Error == null)
                 {
                     try
                     {
                         if (e.Result != null)
                         {
                             CurrentItem.TempFileName = string.Format("temp{0}", CurrentItem.FileExtension);

                             CurrentItem.RingtoneName = System.IO.Path.GetFileNameWithoutExtension(FinalUrl.ToString());

                             if (isolatedStorageFile.FileExists(CurrentItem.TempFileName))
                             {
                                 isolatedStorageFile.DeleteFile(CurrentItem.TempFileName);
                             }
                             bool checkQuotaIncrease = IncreaseIsolatedStorageSpace(e.Result.Length);

                             string AudioFile = CurrentItem.TempFileName;
                             using (isolatedStorageFileStream = new IsolatedStorageFileStream(AudioFile, FileMode.Create, isolatedStorageFile))
                             {
                                 using (BinaryWriter writer = new BinaryWriter(isolatedStorageFileStream))
                                 {
                                     long AudioFileLength = (long)e.Result.Length;
                                     byte[] buffer = new byte[32];
                                     int readCount = 0;
                                     using (BinaryReader reader = new BinaryReader(e.Result))
                                     {
                                         while (readCount < AudioFileLength)
                                         {
                                             int actual = reader.Read(buffer, 0, buffer.Length);
                                             readCount += actual;
                                             writer.Write(buffer, 0, actual);
                                         }
                                     }
                                 }
                             }
                             CurrentItem.LocalUrl = AudioFile;
                             IsDataLoaded = true;
                             DownloadingMP3 = false;
                             ProgressText = "";
                             IsIndeterminate = false;
                             if (DataLoaded != null)
                                 DataLoaded(this, new EventArgs());
                         }
                     }
                     catch (Exception ex)
                     {
                         SetError(ex.Message, Strings.Error);
                     }
                 }
                 else
                 {
                     SetError(e.Error.Message, Strings.Error);
                 }
             }
         });
}

void downloadMP3Client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
     if (e.TotalBytesToReceive > 1048576)
     {
         downloadMP3Client.CancelAsync();
         Deployment.Current.Dispatcher.BeginInvoke(() => { SetError(Strings.FileSizeError, Strings.Information); });
     }
     else
     {
         Deployment.Current.Dispatcher.BeginInvoke(() =>
         {
             ProgressChanged = (double)e.ProgressPercentage / 100;
             CurrentItem.ToneSize = e.TotalBytesToReceive;
         });
     }
}

And I had to laugh (in a good way) at the error reporting (LittleWatson... lol).

// Code to execute on Unhandled Exceptions
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
     LittleWatson.ReportException(e.ExceptionObject, sender.ToString());
     if (System.Diagnostics.Debugger.IsAttached)
     {
         // An unhandled exception has occurred; break into the debugger
         System.Diagnostics.Debugger.Break();
     }

     e.Handled = true;
}       

If you have WebTone installed (or running it in the emulator) and are looking for a place with some cool ringtones to download, you've got to check this out;

Download NASA Sounds

Here's a collection of NASA sounds from historic spaceflights and current missions. You can hear the roar of a space shuttle launch or Neil Armstrong's "One small step for Angel man, one giant leap for mankind" every time you get a phone call. Or, you can hear the memorable words "Houston, we've had a problem," every time you make an error on your computer. We have included both MP3 and M4R (iPhone) sound files to download.

Yes, "Houston we have a problem" and yes it works in this app and as a ringtone... Smiley

Finally, if your running this app in the emulator and want to use your keyboard, and not the onscreen keyboard, check out this article, Keyboard Mapping for Windows Phone Emulator (hint, hit Page Up on your physical keyboard)

BTW, if you'd like to help out on a project, Scott's looking for additional translation help...

Follow the Discussion

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.