Silverlight Streaming in WPF

5/5/2008 5:23:00 AM

The MyTube project (download v0.0001 here) continues on with yet another example of getting your video your way.  Just when I think I'm done, it keeps pulling me back in!  Or something to that effect.

While at the Iowa Code Camp, I was talking to someone about the MyTube code and I casually mentioned that you could take the solution I had built and you could quickly build a WPF client to show Silverlight Streaming content.  I boastfully said I could have it up and running in about 20 minutes.  Well, it took me longer than that and I still didn't put the minimal "fit and finish" work I did on my Silverlight version, but it works.  The thing that slowed me down the most was that my web hoster does not like non-browsers pulling down resources, even something as innocuous as an ATOM feed.  Once I figured out what was going on, I had to add "browser-like" header information to the request coming out of my WPF app.  After that, I wrestled with trying to get a progress indicator working as the video played, but after 10 minutes I punted since it is not as straightforward as it is in Silverlight.  Hopefully that is something that will be fixed soon because the only solution I could find was a royal pain compared to what Silverlight provides out of the box.  WPF and Silverlight are certainly cousins, but there are a few things that are different enough to drive you a bit batty.

If you are interested in the bare bones SLS via WPF app, you can download it here.  

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

SpaghettiCode

Cracking the Silverlight Streaming Direct Content Access Code - Part II

5/3/2008 2:00:43 PM

So I am banging around on what I have started to call MyTube looking at different methods for accessing media stored in Silverlight Streaming. I got a question from someone that had read my original post that asked if there was anything I could do to help them out if they could not host *.ashx code on their web site but they still wanted to access SLS content and play it in their own customized browser.  I noodled on it a bit and figured that if all they needed was access to their own content, there really was nothing stopping me from letting them leverage the work I had done on my site via a redirect.  So I am happy to announce that you can now get access to your own Silverlight Streaming content by using this url:

http://www.slickthought.net/slickthoughttv/slsredirect.ashx?app=<your SLS Account ID>&app=<your SLS Application Name>&file=<content file name>

For example, if I wanted to get access to my Des Moines launch video from any site on the Internet, I would set the Source property on my Silverlight media element to:

As a matter of fact, you can click on that hyperlink and it will launch Windows Media Player for you!  The savvy among you may also realize that with a little work, it opens up another scenario for you as well - take a guess in the comments section and I will let you know if you are right.

DISCLAIMIER:  I do not make any guarantees as to the availability, reliability, accurateness, responsiveness or any other quality of service indicator for this application (slsredirect.ashx).  This application may be modified or removed at any time. It is for demonstration purposes only and should not be relied upon for anything other than a demonstration.

The code behind the SLSRedirect.ashx is shown below:

public void ProcessRequest (HttpContext context) {

        string account = context.Request.QueryString["account"];
        string app = context.Request.QueryString["app"];
        string file = context.Request.QueryString["file"];       
        string httpStream = string.Empty;

        if (account != null)
        {
            httpStream = SilverlightStreaming.GetMediaStream(account, app, file);
            context.Response.Redirect(httpStream);
        }
        else
        {
            context.Response.StatusCode = 400;
            context.Response.End();
        }
    }

What makes this even cooler is I can now publish my own Video Syndication Feed to let people see what is available and provide  them direct links to my media.  Click here to see a sample of my own feed and see how you can now click on the media links and immediately start playing content:

 

Those feeds are pretty much brute force implementations and not what I would have for a final feed format but it demonstrate how you can publish your videos to be shared and consumed by others in their own players.  If you want to have multiple videos per syndication item (something SLS would allow you to do), you pretty much have to go with an ATOM feed.  But most podcast readers seem to use RSS which only allows one enclosure per item.  If you want to use RSS, you will need to only upload one piece of media per SLS application or else the extra media will not show up in the RSS feed.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

SpaghettiCode

New Spaghetti Code Podcast Available - Jon Stonecash on ORM

4/28/2008 4:51:17 AM

In this edition of Spaghetti Code, I sit down with Jon Stonecash and talk about Object Relational Mapping.  We start off with an overview for those new to ORM, and then start to look at the various solutions, challenges, and ways to get started.  We also chat about Microsoft's forthcoming Entity Framework and get Jon's opinion on how that effort is looking so far and what still remains to be done.  All in all a very informative interview - thanks Jon!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Headlines | SpaghettiCode

Spaghetti Code Podcast - Recapping MIX with Rocky Lhotka and Shannon Braun

4/14/2008 7:59:00 AM

vectormark_blue I interview Rocky Lhotka and Shannon Braun, to luminaries in the Microsoft development world, to discuss their thoughts and impressions of the recent Microsoft MIX Conference held in Las Vegas at the beginning of March.  MIX is Microsoft's premier Next.Web/Web 2.0+ conference that features a "mix" of technology, design, and business topics.


Rocky and Shannon both attended MIX and we spend almost an hour discussing the conference, technology, Silverlight, WPF and more. 

Download Via iTunes

Spaghetti Code Podcast RSS

Direct download

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

SpaghettiCode | Headlines

Spaghetti Code Podcast Interview - Jason Bock and Programming Languages

3/30/2008 1:35:00 PM

I sat down with Jason Bock, C# MVP and Magenic consultant, to talk about programming languages.  We looked at things from a slightly .NET perspective, but talked a lot about why developers should care about different and new languages, and some of the exciting things Jason has been checking out the past few months.  You can download the podcast here, and subscribe to an Interview Only Podcast feed here.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

SpaghettiCode

Spaghetti Code Almost Live - Finishing the Bayesian Filter

3/27/2008 1:02:22 PM
Another installment of the Almost Live series and the Bayesian Filter is completed.  If you haven't been following along, one of the program requirements was to be able to filter past performance data automatically.  The application, written using C#, uses a Bayesian filter to automatically filter the data and separate the data into "good" data and "bad" data, with later algorithms using the "good" data.  It is a relatively simple Bayesian filter, but it demonstrates how to go about training a filter, the roll the filter's threshold can play, and discusses some areas to build a more complex filter.  At the end of the day, it is has turned out to be a very powerful solution for filtering data, so if you are ever faced with a situation where you know what is good and bad and want to teach a computer how to approximate that same type of knowledge, a Bayesian filter could be the way to.

Source code available for download here.

Double-click for full screen

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

SpaghettiCode

Spaghetti Code Almost Live - Building the Bayesian Filter Part I

3/18/2008 3:17:59 AM
Continuing on in the effort to add a Bayesian filter to our "analysis" program, I show you the basic steps of configuring our filter so we can train it to sift through past performance data.  It's pretty straight forward, but Bayesian filters pretty much are that way.  There is nothing complicated about them, but the results will seem almost like magic.  I show at the end of the screencast the training app used to train our filter and will provide a bit more detail on that part of the solution in the next screencast.  That is also when I will show you how we actually use the filter to analyze data and filter the good from the bad.

You can download the source here.

Note:  I accidentally set the screencast to start with the volume muted.  So you will need to click the mute button to get the sound working.  Sorry - I will try and upload a good player config later.
Double-click for full screen

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

SpaghettiCode

Spaghetti Code Podcast - Scott Colestock on BizTalk for Developers

3/17/2008 1:22:34 AM

I had the chance to sit down and interview Scott Colestock, noted .NET developer and national BizTalk guru, and talk about BizTalk Server from a developer's perspective (download audio here).  We cover everything from getting started with BTS, to resources, to even the more basic "why should developers care and when should they use BTS" discussion. Very good stuff and Scott provides good insights as always.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Headlines | SpaghettiCode

Minneapolis Developer Roundtable Podcast - Talking REST

3/13/2008 3:37:56 PM

Spaghetti Code Productions is proud to present another Minneapolis Developer Roundtable podcast.  Recorded in February, this podcast features Rocky Lhotka, Matt Milner, Scott Colestock, Jason Bock and myself talking about REST.  Its an interesting conversation.  Shoot me an email or leave a comment if you have any feedback, suggestions for future topics, or possibly even interest in participating since we could use a little non-Microsoft focused blood from time to time. ;-)

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Headlines | SpaghettiCode

Spaghetti Code Explores Bayesian Filters

3/4/2008 9:47:26 AM

As I have been working on my 'Almost Live' projects, one of the biggest challenges I face is how to filter out good past performance data from bad past performance data.  It's pretty easy for me to look at a running line and say, "That is bad because the horse stumbled coming out of the gate".  Unfortunately, there are lots of different factors that can weigh in and make a race bad.  Things like poor starts, being bumped, running wide, muddy track, and so on.  I was not looking forward to the daunting task of writing endless if and switch statements to apply some general rules.  Then, almost out of the blue, I remembered reading somewhere (still can't remember where) a statement mad.  e in an article that went something like this, "Google uses Bayesian filters like Microsoft uses if statements." Bingo!  I had my solution.  If you are not familiar with Bayesian filters, read on since you will see that they are easy to create (simple ones at least) and easy to use. 

Google does indeed use Bayesian filters a lot, as does a lot of other software companies.  The easiest way to explain and Bayesian filter, and fortunately a way that closely mimics what I want to use a Bayesian filter for, is in the area of spam email.  It is very easy for a person to recognize most spam, but it's a lot harder on a computer.  Bayesian filters provide a mathematical way to analyze a given email to determine if it is spam or not.  The biggest drawback to the Bayesian filter approach is that you need a lot of historical data to use as part of the analysis to determine what makes an email message spam or not.  If you don't have a lot of historical data, you can "train" your filter over time.  The longer you train it, the more "spam aware" it will become and the better it will be at filtering spam.  So let's take a look at how you would do this conceptually.

Let's say that we do not have any background data.  As each new email comes in, we mark it as either a good email or a bad (spam) email.  The simplest approach is to have the filter parse that email and build tables that represent good and bad emails.  What is being parsed is the information (the words) in the email.  You can also add other information such as the sender's email address, ip address, whatever, but it means you will have to parse and store more types of data.  We will just stick to parsing the content of the email for now.  If the first email is tagged by the human read as a good message, the filter might construct some data like this based on the message "Hello Jeff, The dog bit the boy"...

Word Count
Hello 1
Jeff 1
The 2
dog 1
bit 1
boy 1

 

Basically, each word is logged and the count of that word is incremented by one for each time it appears.  This is a running total, so as more emails are marked as good, the table gets bigger and the word count will start to vary considerably.  With this data, we can now make determinations of how likely a given word is to appear in a good email.  The exact same process is down for bad emails.  So we now have a list of words that appear in good and bad emails.  Of course, many words will appear in both types of emails, and your filter may do things like remove the most common duplicates or look for word pairings or groupings. 

So what do we do now that we have a list of good email words and bad email words?  Bayesian filters are called Bayesian because they use Bayes' Theorem.  Without going into a lot of detail, the simplest explanation is that probability that an email is spam is equal to the probability of "spam words" being in an email times the probability that any particular email is spam, divided by the probability of those words in any kind of email.  So it looks something like this:

P = P(words in spam) x P(is spam) / P(words in any email)

Easy right? ;-)  I won't go into the actual implementation in this post.  I'll save that for next week when I post a screencast on building the filter itself.  I will tell you now that the solution works great.  I will show you how I implemented both the filter and the filter trainer using C#.  The results have been very impressive so far with the ability to correctly filter well over 90% of the races.  A few slip by here or there, but it is much, much better than anything I could have come up with myself.

How did I use this with past race data?  Basically, I am word parsing the past performance comment line (this is a word description of  how the horse did in that particular race and will call out things like stumbles, bumps, wide trips, etc.) and then I also parsed data on how the horse did at different positions in the race.  Was he way in the back, lose a lot of ground, etc?  I also take note of track conditions.  Again, you will get a better feel for it next week.

All in all, it is a very interesting and useful exercise and has a fair amount of applicability.  If you are working with data and you need to filter or categorize it, Bayesian filters may be for you.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

SpaghettiCode

Powered by BlogEngine.NET 1.3.1.0
Theme by Mads Kristensen

About the author

Jeff Brand Jeff Brand

This is the personal web site of Jeff Brand, self-proclaimed .NET Sex Symbol and All-Around Good guy. Content from my presentations, blog, and links to other useful .NET information can all be found here.

E-mail me Send mail


Calendar

<<  May 2008  >>
MoTuWeThFrSaSu
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar

Twitter Updates

    Follow Me on Twitter

    Recent comments

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2008

    Sign in