Lately I’m getting a lot of questions what could be done with Silverlight in in terms of work with streaming media.
Today I’ll show what could be done. I’ve built very simple media player based on MediaElement object and prepared some stream to use in my application. The major focus of this post it to briefly show what could be done with stream in Silverlight and not how specifically do it. I’ll be glad to answer any specific questions there will be any.
First about the stream. I’ve tried to find on my laptop some media, which will be longer than a minute and will also compatible with Expression Encoder 2 formats. After some time I’ve found an 80’s music clip performed by Italian singer Sabrina. This music clip was processed in Expression Encoder 2 – I’ve added some markers and script command to the stream and encoded it.
Basically, I’ve defined 4 types of markers/scripts: caption, poll, ADV (advertising) and NAME (general marker).
Now the application itself:
The application has very simple UI, and basic media player abilities. Thus, it is still able to stop/play/pause media stream, change volume and displays current position in stream.
The main thing this application does is processing the markers being received from stream. Each type of markers has it own logic. Depending on marker type I’m populating corresponding XAML object:
Each received marker being added to MarkersHistory ObservableCollection, which have ListBox bounded to it. The binding are pretty simple, and I’m skipping it here…
The application generating the polls from poll string – adding dynamic XAML objects to pre-defined pool container, and subscribes to event which gives us a way to know how user reacted:
Application XAML (along with full sources) are pretty simple and could been downloaded from here.
All animations done with simple storyboards for simplicity. There is 2 types of storyboards: “Show*” and “Hide*” – one for showing corresponding object, and one to hide it. “Show” Sotryboards being started at the time of corresponded object population, and “Hide” storyboard by timers, which defined how long specific type of object will stay visible.
Lunch the application on page, try it, and hope you will understand better what could be done with streams in Silverlight application.
As usual, will be glad to answer any question.
Full sources (including the music video) are here.