<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">Gilles' Thoughts</title><subtitle type="html">A random collection of tidbits</subtitle><id>http://blogs.msdn.com/gillesk/atom.xml</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/gillesk/default.aspx" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/gillesk/atom.xml" /><generator uri="http://communityserver.org" version="2.1.61025.2">Community Server</generator><updated>2009-03-23T11:32:00Z</updated><entry><title>Bringing Multicast to Silverlight</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/gillesk/archive/2009/05/12/bringing-multicast-to-silverlight.aspx" /><id>http://blogs.msdn.com/gillesk/archive/2009/05/12/bringing-multicast-to-silverlight.aspx</id><published>2009-05-13T03:13:41Z</published><updated>2009-05-13T03:13:41Z</updated><content type="html">&lt;p&gt;Qumu and Microsoft just annouced that Qumu will offer a Silverlight plugin that will receive multicast streams (&lt;a href="http://www.qumu.com/newsroom/news-releases/2009/silverlightplugin.htm"&gt;Qumu Press Release&lt;/a&gt;). It’s great because this will allow enterprises to broadcast internal events much more efficiently. I’ll admit that supporting directly in Silverlight would have been nicer, but at least we’ve got a viable solution now. It’s been very frustrating to have internal events being streamed in WMP and not accessible to Silverlight, finally this will change. The other nice thing, is that Mac users will also be able to use the solution, afaik, this is the first release of a multicast client for Mac in a very long time.&lt;/p&gt;  &lt;p&gt;Personally, I’m still very excited by the fact that Silverlight is open enough to enable people to extend our functionality in such a way.&lt;/p&gt;  &lt;p&gt;If you’re interested the code will be available on &lt;a title="http://projectstarlight.codeplex.com/" href="http://projectstarlight.codeplex.com/"&gt;http://projectstarlight.codeplex.com/&lt;/a&gt;&lt;a href="http://projectstarlight.codeplex.com/"&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9608419" width="1" height="1"&gt;</content><author><name>gillesk</name><uri>http://blogs.msdn.com/members/gillesk.aspx</uri></author></entry><entry><title>Playing back Wave files in Silverlight</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/gillesk/archive/2009/03/23/playing-back-wave-files-in-silverlight.aspx" /><id>http://blogs.msdn.com/gillesk/archive/2009/03/23/playing-back-wave-files-in-silverlight.aspx</id><published>2009-03-23T21:32:00Z</published><updated>2009-03-23T21:32:00Z</updated><content type="html">&lt;p&gt;I’ve been working on Silverlight for a couple of years now, and finally decided to start talking about it in my blog. With the recent beta, we’ve added raw A/V support to Silverlight 3, and that means not only that people will be able to write their own decoders for Silverlight, but also that they can now play back PCM audio through managed code. The easiest way to get PCM data is simply to use a Wave file. Wave files are a container format for multiple audio encodings, so not all files will play back in Silverlight, but the PCM encoded ones will. To help out, I’ve published a sample MediaStreamSource implementation on Code Gallery (&lt;a href="http://code.msdn.microsoft.com/wavmss" mce_href="http://code.msdn.microsoft.com/rawmss"&gt;http://code.msdn.microsoft.com/wavmss&lt;/a&gt;).&lt;/p&gt;  &lt;p&gt;The easiest way to try out the code is to open a local wave file from your drive using the OpenFileDialog (C:\Windows\Media has a bunch of little sound bites).&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Button_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e) 
{
    OpenFileDialog ofd = &lt;span class="kwrd"&gt;new&lt;/span&gt; OpenFileDialog(); 

    &lt;span class="kwrd"&gt;if&lt;/span&gt; (ofd.ShowDialog().Value)
    {
        Stream s = ofd.File.OpenRead();
        WaveMediaStreamSource wavMss = &lt;span class="kwrd"&gt;new&lt;/span&gt; WaveMediaStreamSource(s);
        &lt;span class="kwrd"&gt;try&lt;/span&gt;
        {
            me.SetSource(wavMss);
        }
        &lt;span class="kwrd"&gt;catch&lt;/span&gt; (InvalidOperationException)
        {
            &lt;span class="rem"&gt;// This file is not valid&lt;/span&gt;
        }
    }
} &lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;This snippet will play the wave file right away. Remember that to get the FileOpenDialog, you need to hook the handler to a user initiated action. An easy way for this, is to put a MediaElement and a button on a page.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;UserControl&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;SampleWave.MainPage&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;400&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;300&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;LayoutRoot&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Background&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;White&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;MediaElement&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;me&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;b&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;200&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;20&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Open&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Click&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Button_Click&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;UserControl&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;That’s it, you can now play wave files.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9502154" width="1" height="1"&gt;</content><author><name>gillesk</name><uri>http://blogs.msdn.com/members/gillesk.aspx</uri></author></entry></feed>