Applies To: Silverlight (the restriction applies to XNA, but the MediaElement is only Silverlight)
Quick Bits
Simply setting the Source of a MediaElement to a valid source will stop any current background playback, causing you to fail Marketplace certification, according to section 6.5.1 from the certification guide.
The Fine Print
From the certification guide:
6.5.1 Initial Launch Functionality
When the user is already playing music on the phone when the application is launched, the application must not pause, resume, or stop the active music in the phone MediaQueue by calling the Microsoft.Xna.Framework.Media.MediaPlayer class. If the application plays its own background music or adjusts background music volume, it must ask the user for consent to stop playing/adjust the background music (e.g. message dialog or settings menu).
Note: This requirement does not apply to applications that play sound effects through the Microsoft.Xna.Framework.Audio.SoundEffect class, as sound effects will be mixed with the MediaPlayer. The SoundEffect class should not be used to play background music.
Note: This requirement does not apply to Music + Videos Hub applications that are described in Section 6.4
The Setup
You have a MediaElement which only used to play back one file, so you set the Source in your XAML.
The Sting
The user starts playing some music in Zune, then launches your XAP. As soon as your XAML loads and the MediaElement‘s Source is set, the background music stops playing, even if the MediaElement is not playing. That’s right, even if you set AutoPlay = "False", the background music will still be stopped.
Since you must ask the user for consent, you will have failed certification.
The Solution
- Never set a
MediaElement‘s Source in XAML, unless that XAML is on a page that you navigate to after asking the user for consent.
- Check to see if background music is playing and then set the source (in code).
Note: If you set the source and then immediately call Play(), the Play() will have no affect since the MediaElement will still be in the "Opening" state, instead set "AutoPlay = true" (works from code)
Categories: Uncategorized Tags:
Applies To: Silverlight & XNA
Quick Bits
Microsoft.Xna.Framework.Media.MediaPlayer.GameHasControl
The Setup
Your app does some sort of music playing that doesn’t make sense to blend into any already playing background music (for example, you’re going to stream your own music) or you simply want to show a video.
Why You Care?
If you just start playing music you will fail certification according to section 6.5.1 of the certification guide if you don’t ask the user if you can stop the background music, but how can you stop the background music if you don’t know it’s playing? Hence, you care!
The Solution
Query Microsoft.Xna.Framework.Media.MediaPlayer.GameHasControl (it’s a bool) – if you have control, then you’re good to go. If you don’t have control, then there is something in the background and you need to prompt the user before continuing.
Silverlight Note: you’ll need to link in Microsoft.Xna.Framework.dll for this to work, but make sure you don’t distribute this file with your XAP by mistake (or you’ll also fail certification for redistributing phone assemblies)
Categories: Uncategorized Tags:
Applies To: Silverlight & XNA (anyone using Launchers / Choosers)
Quick Bits
Always wrap [some launcher object].Show() with a try/catch block which catches InvalidOperationException, since running Show() while navigating (for example, if the user clicks your button multiple times quickly in succession) will cause this Exception to be thrown.
The Setup
You have a button that says “Purchase Me” which launches the Marketplace or one that says “Send Feedback” which launches Outlook to send an email. For example:
EmailComposeTask emailComposeTask = new EmailComposeTask();
emailComposeTask.To = "feedback@awesomeapps.contoso.com";
emailComposeTask.Subject = "Feedback for AwesomeApp";
emailComposeTask.Show();
The Sting
The user hits the button multiple times, quickly. The app crashes.
The Cause
If you debug this you’ll find that you can’t reproduce this behaviour on the Emulator (at least, I couldn’t) but that it reproduces pretty consistently on the phone.
On the phone you’ll get an InvalidOperationException with the following message:
Navigation is not allowed when the task is not in the foreground. Error: -2147220989
The Solution
There are a couple of solutions – you could remember your state, so that if you clicked the button once and haven’t navigated back yet then you just don’t callShow(). Alternatively you could check if you were currently Navigating, and not call Show(). I personally prefer to wrap the statement in a try/catch block since it’s the easiest to have to worry about and the cost for the try/catch block is minimal (performance wise).
Categories: Uncategorized Tags:
It’s been a while, and there’s been a lot of confusion surrounding this topic of “5 free apps”, so here’s the final low down:
- Unlimited number of paid applications
- This includes updates to said applications
- A paid application cannot be made free
- 5 submissions of free applications
- Unlimited updates to accepted free apps
- WARNING: failed submission of free applications will count against the 5 submissions
So let’s walk through a scenario
A (for “awesome” which seems to be my word of the last couple of months) signs up for the marketplace, pays his $99 (or equivalent in local currency) and gets approved. He then submits “A’s AwesomePaid App” which fails submission. He fixes the problems, resubmits and the app is published. Based on feedback he submits 4 subsequent updates. Up to this point A has paid no extra fees.
A then decides to become philanthropic and submits a free application. The application fails submission – and now A is only left with 4 free submissions. A resubmits and the submission goes through, at which point he starts submitting updates, and has 3 submissions left. No matter how many updates A pushes, they will still have 3 submissions remaining.
Categories: Uncategorized Tags:
If you happen to be down at TechEd Europe this week, don’t forget to come by the Windows Phone 7 and Silverlight booths (they’re opposite each other in the Technical Learning Centre) and say hello. You’ll get to play with some phones from HTC and interact directly with both teams – don’t miss out!
Something else you shouldn’t be missing out on are all of the Windows Phone 7 oriented talks (both XNA and Silverlight) and especially, shameless plug, my session on performance. You can find me tomorrow (Thursday, November 11) from 12:00 PM – 1:00 PM in Hall 7.3b Europa 1.
See you there!
Categories: Uncategorized Tags:
Updated Policy!
Sure, the App Hub site says:
Submit up to five free apps to Windows Phone Marketplace, additional submissions are $19.99 USD
But here’s what it really means:
Submit up to five free apps (including updates) to the Windows Phone Marketplace, additional submissions (of apps or updates) are $19.99USD
FTFY
Seriously
The policy is simple, just not stated that simply. The first five submissions of any free Windows Phone 7 application – be it a new application or an app update is going to be free, anything further is going to be $19.99USD.
In reality I don’t see this affecting the average casual free app developer out there (since they’re not making any revenue off this apps and, (very) generally, not submitting that many updates). It will affect those with free apps that have an alternate revenue source (think advertising or subscription) – but since they’re actually making money anyway, the $US19.99 shouldn’t be a big deal.
Stay tuned for an official blog post from the App Hub team at some point in the near future, and a revision to the wording on the website to clear this up…
Categories: Uncategorized Tags:
It’s that time of year again – PDC 2010 kicks of tomorrow! Join the Silverlight Performance Team as we take you through the high level analysis of common performance issues that apps commonly run into. I’ll be giving a live session titled “Optimizing Performance for Silverlight WP7 Apps” at 3:15pm (PDT) on day 1 (28 October 2010).
Even if you couldn’t make it here to heckle me in person, the rest of the team will be online and answering your questions (or heckling on your behalf) as you watch the live stream via the online player, which you’ll be able to find at http://player.microsoftpdc.com.
Make sure to check out the session before mine (“Things I Wish I Knew about Building WP7 Apps” by Jaime Rodriguez) and all of the rest of the Windows Phone 7track. There’s other great content at PDC that’s worth checking out, but we all know that that’s secondary!
See you there!
Categories: Uncategorized Tags:
I’m working on a WP7 library which helps analyze your VisualTree and to provide a visual aid, I take WriteableBitmap snaps of the elements. Unfortunately I (seemingly) randomly encounter the following exception:
A first chance exception of type ‘System.Exception’ occurred in System.Windows.dll
When digging into the exception you may find that the error is actually a HRESULT which is being bubbled up from the lower native layer:
E_UNEXPECTED (0x8000ffff)
What’s going on?
You guessed it – this isn’t random! In fact, this only happens on completely obscured (or off screen) elements which have never had a chance to render. In this case when you try to take a WriteableBitmap snap, instead of it forcing the control to render, it simply fails. This will hit you in the case of any element that has always been obscured. As soon as the element is unobscured it will be good to go (so you could do some VisualTree manipulation if you *really* needed to grab that shot).
Categories: Uncategorized Tags:
… as opposed to multiple apps, each with a different locale.
Why?
- If these are free apps, then each language will count towards your free app quota (you get 5 free apps that you don’t need to pay certification costs for)
- Regardless of price, each app will need to go through independent certification (which will then take longer for all apps to be released), instead of one app being certified and published with all languages
Happy App Hubbing!
Categories: Uncategorized Tags:
YES! Visit: http://create.msdn.com/en-us/home/getting_started and click “Install Now” to download the tools, directly, for free, without the need to sign up first.
Ever since the release of the new developer portal (http://create.msdn.com) I’ve been hearing that you need to signup to get the tools, hence they must no longer be free. In reality, what happened is that the old developer website url redirects directly to a login screen, instead of to the new site, leading people to believe that the tools are no longer free. Let me assure you – they are
Happy App Hubbing!
Categories: Uncategorized Tags: