online

Thứ Sáu, 4 tháng 11, 2011

Add Ringtones to XNA games for Windows Phone 7

(This is for game developers offering ringtones through their games--for end users adding their own ringtones to their Windows Phone 7, check here.)

Shoot 1UP for Windows Phone 7 will be coming out early next year. We're excited to offer 3 custom ringtones created from game music, that you'll be able to add to your phone from within the game. Turns out though, none of the online tutorials explained everything necessary for our XNA game to install ringtones.

When we heard about the Mango update, we were excited to support new features like ringtones and 'live tiles'. Searching for help on creating ringtones in the game we found the official MSDN walkthrough.

You can have MP3s or WMAs of the ringtones and you can add the sound from the XAP itself or pull it from isolated storage. Since our game was not generating the ringtone itself (as they were previously recorded), our ringtones are added to the solution and will be pulled from the XAP as shown in the MSDN example.
This shows a .wma being used, but we used .mp3s which work as well.

try
{
saveRingtoneChooser.Source = new Uri("appdata:/myTone.wma");
//saveRingtoneChooser.Source = new Uri("isostore:/myTone.wma");

saveRingtoneChooser.DisplayName = "My custom ringtone";

saveRingtoneChooser.Show();
}
catch (System.InvalidOperationException ex)
{
MessageBox.Show("An error occurred.");
}
 

The Problem?
When we ran the game and checked for the ringtone file--the file never existed on the phone after we deployed.

The Answer?
We had have "Copy to Output Directory:" set to Copy if newer. This isn't obvious since the default which works with all other content is "Do not copy".




From what we've seen, Live Tiles images work like this too. If you want to use them, you must set them to "Copy if newer" to get them to show up on the phone, as they seems they circumvent the traditional content pipeline. And I believe this issue is only for XNA games (not Silverlight) but if I'm wrong, please inform me in the comments.

Good luck to all devs adding additional, cool content made possible by the Mango update! I think the 'new' WP7 is really sharp and it can help all new games really shine.

Không có nhận xét nào:

Đăng nhận xét