11 February, 2011

WP7: Enum.GetNames not present?

It has really been a source of great pain, that “someone” forgot to put in the Enum.GetNames() method in the SL-subset of .NET. Only the Enum.GetName() is present!

Anyway – a utility class I found in a blog comment somewhere came in quite handy:

public class Enum<T>
{
public static IEnumerable<string> GetNames()
{
var type = typeof(T);

if (!type.IsEnum)
throw new ArgumentException("Type '" + type.Name + "' is not an enum");

return (from field in type.GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static)
where field.IsLiteral
select field.Name).ToList();
}
}

You use it like this:

var names = Enum<StockExchange>.GetNames();
ExchangeNames.AddRange(names);


(here the StockExchange is an enum.)



Technorati Tags:

Azure: How to create local emulator storage

If you find yourself attempting to start up on Azure/Cloud development, you might encounter an error in the emulator when lauching this saying that it is unable to start the storage?

The reason is, that you initially need to initialize the (local) data storage to be able to support the emulator. The key to this is the console utility called DSInit (found in the below command prompt).

image

To setup this storage in a local SQLServer, you go this command: DSInit /SqlInstance:. /forceCreate

It will ultimately present you with this prompt:
image

 

Update (26/5/2011):
This has been moved in version 1.4 of the SDK. DsInit.exe is now found at:
”C:\Program Files\Windows Azure SDK\v1.4\bin\devstore>DSInit.exe”

 

Technorati Tags:

06 February, 2011

WP7 development tools update (January 2011)

Okay – the update to WP7 development tools is available for download. It includes a new emulator (with copy/paste) and some other minor updates. See full details in the below link.

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=49b9d0c5-6597-4313-912a-f0cca9c7d277&displaylang=en

Technorati Tags:

04 February, 2011

WP7: How to receive streaming video in your application

I yesterday set out to produce a streaming video client as a POC. Basically, I wanted the ability to show live video feeds on the phone and that without having to download the video onto the device first.

Therefore, the solution should be to receive a video in a streaming manner from a resource (server) on the internet.

image

How to do?

It turns out it is pretty easy to create. MS has creating a streaming video client control (Microsoft.Web.Media.SmoothStreaming, Link) that should be able to do the job, but it is not all that easy to use. On CodePlex, some guys have made a control that in contrast makes it very easy to set up. This framework is called SMF (Silverlight Media Framework) and includes a SMFPlayer control (http://smf.codeplex.com/)

References:
The references you need to have in your project are shown below.

image

You need to add these to ref. in your page XAML:

    xmlns:Core="clr-namespace:Microsoft.SilverlightMediaFramework.Core;assembly=Microsoft.SilverlightMediaFramework.Core.Phone" 
xmlns:Media
="clr-namespace:Microsoft.SilverlightMediaFramework.Core.Media;assembly=Microsoft.SilverlightMediaFramework.Core.Phone"


and finally the player is embedded like this:


<Core:SMFPlayer>
<
Core:SMFPlayer.Playlist>
<
Media:PlaylistItem
DeliveryMethod="AdaptiveStreaming"
MediaSource="http://ecn.channel9.msdn.com/o9/content/smf/smoothcontent/bbbwp7/big buck bunny.ism/manifest"/>
</
Core:SMFPlayer.Playlist>
</
Core:SMFPlayer>

That is basically all there is to it. Of-course a lot of properties/settings can me tweaked to make the player look/behave as you prefer – but a basic setup is the above. Note the mediaSource here is the bugsbunny sample stream; in this case hosted on a channel9-server.


Not sure as to why SMF suggests that you should reference the Microsoft.Web.SmoothStreaming assembly, as the project runs fine without it. But that’s what they state?


Happy coding!



Technorati Tags: ,

InRiver: Not loading your extensions?

(You really need to in the loop to appreciate the issue this post addresses). Man, I've been fighting this problem for hours before I ...