Windows Phone: Working with MediaLibrary.GetPictureFromToken

I struggled with this for a while, so I thought I would throw up a post, to help out people running into this is in the future.

From MSDN: Here is the code sample you’re lead to, to use the Extras item in the photo hub.

Add the Extras.xml file …

   1: <?xml version=1.0 encoding=utf-8 ?>

   2: <Extras>

   3:   <PhotosExtrasApplication>

   4:     <Enabled>true</Enabled>

   5:   </PhotosExtrasApplication>

   6: </Extras>

and then use the OnNavigatedTo method.

   1: protected override void OnNavigatedTo(NavigationEventArgs e)

   2: {

   3:     //Gets a dictionary of query string keys and values

   4:     IDictionary<string, string> queryStrings = this.NavigationContext.QueryString;

   5:  

   6:  

   7:     //This code ensures that there is at least one key in the query string, and check if the "token" key is present.

   8:     if (queryStrings.ContainsKey("token"))

   9:     {

  10:         

  11:         //This code retrieves the picture from the local Zune Media Database using the token passed to the application.

  12:         MediaLibrary library = new MediaLibrary();

  13:         Picture picture = library.GetPictureFromToken(queryStrings["token"]);

  14:  

  15:         //Creates WriteableBitmap object and adds to the Image control Source property.

  16:         BitmapImage bitmap = new BitmapImage();

  17:         bitmap.SetSource(picture.GetImage());

  18:         WriteableBitmap picLibraryImage = new WriteableBitmap(bitmap);

  19:         retrievePic.Source = picLibraryImage;

  20:     }

  21: }

The problem is …. well there are a couple problems.

When you run this code (or when I ran it), I was getting an “An Unknown Exception has Occurred” error. Great – thanks for that. Inner Exception was null, so no help there. The error was happening on line 13, where the photo was trying to be fetched.

First. You can’t debug this. Because you can’t see pictures on your phone, while it’s connected to Zune, which it must be to have the debugger attached. So you unplug your phone, and then you can see your pictures, and the Extras in the application bar, but … if it fails you don’t know why.

Here are the steps I took, and then finally solved the problem.

First, I wrote the token (which is a GUID) to a text box. Once I knew the GUID, I could run the code outside of OnNavigatedTo, and then I noticed in the Quick Watch window that Library was instantiated, but had no photos, saved photos, genres, nothing. Everything was zero count. Then it hit me. The App Cap’s weren’t turned on.

So the answer is …..

Make sure you have the ID_CAP_MEDIALIB turned on in your WMAppManifest.xml file, like line 6 below.

   1: <Capabilities>

   2:   <Capability Name="ID_CAP_LOCATION"/>

   3:   <Capability Name="ID_CAP_NETWORKING"/>

   4:   <Capability Name="ID_CAP_WEBBROWSERCOMPONENT"/>

   5:   <Capability Name="ID_CAP_GAMERSERVICES"/>

   6:   <Capability Name="ID_CAP_MEDIALIB"/>

   7: </Capabilities>

Microsoft Listens–WinPhone7 App Submission Changes

Wait, what’s going on again?

It’s all around Windows Phone 7 application development and the submission process to the Windows Phone Marketplace. Microsoft is on the hunt for app devs to build apps for Windows Phone 7. Of course they are, right? You need apps to make the platform more enticing for users to buy, to build a marketplace, for apps to be developed, and round-and-round.

I’ve built a bunch of applications for Windows Phone 7. Some for me, some for friends, some for Microsoft, some of other companies, etc. Originally, each developer was allowed 5 free application submissions. If an app was rejected, you could fix it, and resubmit, and that counts two submission points. Because the platform is new, and I’m still learning the ins-and-outs, I’m not afraid to admit I’ve had a few rejections. Some I agree with, and some I don’t, but that’s not the point of this post. After your 5 app submissions (pass or fail) the submission price is $20USD.

Since the beginning of WP7, I’ve been telling Microsoft Rep’s that the $20 hit is hurting more than helping them. Most seemed to agree, and as of today, the free submission count, per developer account is raised to 100.

WooHoo – Thank you Microsoft for listening!

Azure Boot Camp Trip Report–Feb 5, 2010

This past week, I hosted another bootcamp @Gangplank in Chandler, AZ. This was done in conjunction with AZGroups.org, our local Microsoft Evangelist Michael Palermo( @Palermo4 ) and a few rock solid guys in the community. Namely, Andre Wilson (@awilsong), and Chris Coneybeer (@coneybeer).

We had 31 people in attendance, who all left happy, and more knolwedgebale about azure.

Goal.Accomplished = True;

We ran the full day event in two halves, first half Learn, second half Do. The “Do” part was made possible by the Azure Bootcamp team, supplying us with 30 day free/trial Azure accounts. These were pre-provisioned Azure accounts that were associated with LiveIDs. Ready to log into and start using. Andrew started with a Basic intro to what is Azure, then @coneybeer did a bit on Azure storage (table, sql, blob, and queue), and Andrew finished up the learning section with Deployment.

The second half of the day was spent building a project that was a basic shopping cart. One team built the order entry system, and posted orders to an Azure queue. The other team monitored the Azure queue, and processed the order. Pretty simple, and we finished the day with an ordering system that was pretty cool. I hosted the code in my DiscountASP.net Team System TFS account. This made it easy for the two teams to work on the same project.

In wrapping up with @coneybeer and @awilsong, we chatted about a better way for next time. Like life, things evolve, and sometimes you don’t know the best way, until you’ve done it once or twice. Remember the first half of the day was Learn? We had labs for people to do, and everyone finished the labs. So our “better idea for next time” is to build the labs, so they support the beginnings of the project that will be used/built later.

So in stead of the labs being throw away learning, they would actually be the foundation of the application that would later be built. This is slightly different than the Windows Phone 7 bootcamp we did where we had a contest for users/teams to build a better application than everyone else.

I like the one big project as a team better, and the idea that it’s all in my TFS (on DiscountASP.NET) means that the learning / project doesn’t have to stop at the end of the day.

Hey @coneybeer and @awilsong THANK YOU for providing the content, funding, and general fun.

Hey @Palermo4 THANK YOU for the funding you provided from Microsoft for Food and Beverages.

Hey @Gangplank THANK YOU for the facility.

azurephoto

@ScottCate

Best customer service EVER–Berries.com

Berries.com for the win. I don’t have a ton of time – so this will be short.

I sent a thank you gift to some friends, but I used an old (wrong) address. The people who live there now, called and told Berries.com about the mistake. Berries (Called Shari’s Berries online) called me and left a very nice voice mail. I got the new address, called back to customer service, and there are replacing my order, to the new address no charge.

Within 10 minutes of hanging up, I rec’d a FedEx notification, and the Berries gift will be delivered overnight, tomorrow.

WOW.

Amazing.

If you have a gift for someone, please consider using Berries.com to send it. I think they’re somehow part of a much larger company, but who cares. With this kind of service, it doesn’t make sense to use anyone else.

Thank you Berries.com – best of luck to you and your business.

Aptera Disappoints Me

ApteraAptera Motors promises to be an amazing vehicle. I’ve been wanting one since I first heard about it from my buddy Lorin, back in the day. In fact, I wanted one so bad, that I put in the $500 deposit. Not a lot of scratch and it get’s me on the list. How cool will it be to someday (maybe??) have one of these to drive around?

The Aptera messaging is filled with “We listen to our customers?” and “We will build what they want” and “We’re trying our hardest”. I’m here to tell you different. As of this writing, I have been 100% left in the dark to what’s going on as an Aptera Pre-order(er?). I get a newsletter. That’s it. And that’s only because I signed up for the newsletter on the website, the same as anyone else can do. I’m not looking for insider information, just something that keeps me informed.

Since I placed my deposit many years ago, I haven’t heard anything. Not a “Thank you for your interest”, Not a “We hope to have cars before 2015”, not a “You’re still on the list”, nothing.  Actually, that’s not true – I did once get an email that said (paraphrase) “Double your deposit to show us your serious and lock in ……{something}”.

I’ve contacted their customer service, and twitter team, and both times I’ve been given the run around, trying to get this answer. Here is what I want to know Aptera.

Am I still on the list?

I’m just an investor, and to be honest, maybe I’m not even that. I’m guessing my little (tiny) dollars are in some escrow account safe and sound for a someday/maybe when the Aptera is released. I have to think that Aptera values it’s depositors, but so far there is no proof of that. How can a company take what is essentially a Pre-Order customer, and ignore them? More than ignore, actually avoid, those customers?

I’m not sure I have any belief that this company will ever listen to, or be helpful to it’s customers. While I really want this cool looking car, and I don’t have any worries about it’s safety, I do seriously consider the service/repair end of the game with as much as I have been ignored.