1 0 Tag Archives: mobile
post icon

Silverlight: Tasks on the Win7 Mobile Phone

In the namespace Microsoft.Phone.Task there are a number of external tasks that your Win7 Mobile application can launch, perform an action, and take the results back to your application.

These tasks include:

For example, to have your Win7 Mobile application make a phone call you can do this by simply creating what is called the PhoneCallTask. The following example demonstrates how easy this is to do from a button click event:

private void PhoneBtn_Click(object sender, RoutedEventArgs e)
{
    try
    {
        PhoneCallTask task = new PhoneCallTask();
        task.PhoneNumber = “555-1212”;
        task.Show();
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

Sending email is done in a similar way through the object called EmailComposeTask.

private void EmailBtn_Click(object sender, RoutedEventArgs e)
{
    EmailComposeTask ect = new EmailComposeTask();
    ect.To = "youremail@hotmail.com";
    ect.Subject = "Hello world";
            
    ect.Show();
}

 

Thanks,

–Mike

Leave a Comment
post icon

Loading COM components in your Web Service

I ran into an issue the other day where my Silverlight Mobile App was calling my web service that was trying to load a COM component. Ran fine when debugging locally under Cassini. However, once deployed to IIS, loading the COM component failed with the following error:

"Retrieving the COM class factory for component with CLSID {D6567EF8-0A6C-48E7-9288-A2463123C2F3} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0×80070005 (E_ACCESSDENIED))."   

The solution was to make a change in DCOM Config adding permissions to IIS_USERS for my component.

Exact steps:

1. Start Menu->Run dcomcnfg.
2. Expand Component Services->Computers->My Computer –> DCOM Config.
3. Right-click on your component in the tree view, select properties and click on the Security Tab.
4. Under Launch and Activation Permissions, click the Edit button.
5. Click Advanced button, click Find Now Button.
6. Select IIS_IUSERS and click the OK button.
7. Check checkboxes for Local Launch and Local Activation.

Thanks,
–Mike

Leave a Comment
post icon

Win7 Mobile Phone Comparison Chart

If you are looking to buy a Win7 Mobile phone (which you should!) I found a very useful Win7 phone versus Win7 phone comparison chart over at Elektricforest that I thought I would share with you.

Click on this image to get the original full sized version from the source:

phonechart2

For a further breakdown visit: http://www.microsoft.com/presspass/presskits/windowsphone/glance.aspx

Thanks,
–Mike

Leave a Comment
post icon

Funny Sounds, Radio Streams & Japanese – Win7 Mobile Apps

Well, I am having a lot of fun on my vacation creating applications in Silverlight for the Win7 mobile phone.

My latest published application allows you to play a variety of sounds including some funny, obnoxious ones that will find some good laughs at a party.

The application is called “Funny Sounds” and can be downloaded via the marketplace. Direct Zune link: http://social.zune.net/redirect?type=phoneApp&id=10fb5adc-390b-e011-9264-00237de2db9e

Let me know if there are any sounds you would like to have in this app to make your friends laugh!

I have two other applications I am about to publish soon next week.

The first is a program that allows you to listen to radio stations that support SHOUTCast streams. This application allows you to pick a genre and a sub-genre to help you find the radio station that is right for you. Screenshots:

image image

Finally, if you are interested in learning Japanese you will love my next application. Titled “PeraPera” (which means “fluent” in Japanese), this application allows you to study Kanji, Hiragana, Katakana as well as vocabulary. Before I got into Computer Science, Japanese was my passion and I spent over 5 years in Japan studying Japanese. I have always wanted to make a program like this and the Win7 Mobile Platform was the perfect place. Couple sneak preview screenshots below:

image image

Thanks,
–Mike

Leave a Comment
post icon

Playing sound effects on Windows Phone 7

To play sounds on the Windows Phone 7 you can make use of the SoundEffect library that comes with XNA even if you are building an application in Silverlight.

Start by adding a reference to Microsoft.Xna.Framework.dll.

Next, add the following using statements to your file:

using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework;


This class supports using WAV files. If you have an MP3 file, you can convert it to a WAV using a conversion tool (there are tons of free tools on the Internet).

Next, add your wav file to your project. Finally, open the stream to the WAV file using TitleContainer.OpenStream() and create a SoundEffect from that stream. In the example below, I am opening a wave file called crickets.wav that is located in my folder called sounds.

Stream stream = TitleContainer.OpenStream("sounds/crickets.wav");
SoundEffect effect = SoundEffect.FromStream(stream);
FrameworkDispatcher.Update();
effect.Play();


In general wave files are much larger than compressed MP3 files. On the phone, you can play one Mp3 at a time using the MediaElement object. When creating your MediaElement, make certain you add it to the Silverlight tree if it’s not statically declared otherwise it will not load.

Also, when you deploy the app to your actual phone device through VS 2010 and Zune make certain you unplug or close Zune first before attempting to play sound otherwise they will fail to load. You can play sounds without this problem if you run your app in the emulator.

The following code gives and example of playing sound through the MediaElement:

MainPage.xaml:

<MediaElement x:Name="MainME" AutoPlay="False" MediaOpened="MainME_MediaOpened" MediaFailed="MainME_MediaFailed"></MediaElement>

MainPage.xaml.cs:

private void SoundBtn_Click(object sender, RoutedEventArgs e)
{
    MainME.Source = new Uri("sounds/mySound.mp3", UriKind.Relative);
    MainME.Position = new TimeSpan(0);
}
 
private void MainME_MediaOpened(object sender, RoutedEventArgs e)
{
    MainME.Play();
}


Thanks,

–Mike

Leave a Comment