Polling Video – A Viable sub-second alternative? - Jesse Liberty - Silverlight Geek Page view counter

Polling Video – A Viable sub-second alternative?

SLHvpLogo

An interesting suggestion was made with regard to my intended use of embedded “heartbeat” markers.  Mike Loynd (WL) referred me to this fascinating article by John Deutscher (PM for IIS Media).  That caused me to experiment with the following code in the HVP Silverlight Video Player,

public partial class Player : Page
{
  private readonly DispatcherTimer timer;
 
  public Player()
  {
    InitializeComponent();
    timer = new DispatcherTimer { Interval = new TimeSpan( 500 ) };
    timer.Tick += new EventHandler( timer_Tick );
    timer.Start();
  }
 
  void timer_Tick(object sender, EventArgs e)
  {
    var position = CoreMedia.Position;
    var minutes = position.Minutes;
    var seconds = position.Seconds;
    var milliseconds = position.Milliseconds;
    TopPlaceHolder.Content = 
       string.Format("{0:d2}:{1:d2}:{2:d4}", 
       minutes, seconds, milliseconds);  
  }
 

 

Essentially, every 1/2 second I’m asking the streaming video for its position, which is returned as a timespan. Here’s a (cropped) snapshot of the player in action:

Timer

The advantages of this approach are:

  • No markers need be embedded, all the information about the TOC, links, etc, can be encapsulated in an xml file or database, and be applied to any video
  • Granularity (do care about 1/2 second intervals or 5 second intervals?) can be adjusted based on the media, the bandwidth, etc.
  • Adding links and other HyperVideo information can be applied to any video without having to modify the video in any way.

The key question is how often one can poll without noticeably affecting performance, but this does show a great deal of promise. More on this very soon.

The code for this is now checked into the Silverlight HyperVideo Project  as build 53344

Published Wednesday, December 30, 2009 11:27 PM by jesseliberty

Comments

# Twitted by JesseLiberty

Pingback from  Twitted by JesseLiberty

Wednesday, December 30, 2009 11:31 PM by Twitted by JesseLiberty

# re: Polling Video – A Viable sub-second alternative?

There is the media marker object that can be added to a media element given a timespan that is representative of the marker. These can be added at any point and time into the piece of media. Once the media markers are added the media element will raise a MarkerReached event.

By adding the media markers to the MediaElement you completely remove the necessity of adding the markers during encoding.

We're curently using this approach for marking media for training material and works pretty well.  I add a marker to the scrubber control so users konw where the marker is, this too has its own events, i.e. markerclicked,  markermouseenter and markermouseleave.

hth

Thursday, December 31, 2009 9:44 AM by BigDubb

# re: Polling Video – A Viable sub-second alternative?

hth, that approach is great, but won't work for this project as we need to decouple the markers from how they are used.

It is entirely possible that we would have more than 1 xml file creating linkages between moments in a video and what the player should do (e.g., at 1 minute 53 seconds show this link vs. at 1 minute 28 seconds show that link).  

The design choice then is:

1. Along with or based on the config file you  inject the markers at run time and then handle the events raised

2. Put in a heartbeat marker that is frequent enough to give you an approximation

3. Poll for position every (e.g.,) 100 ms

From what I can see, the 3rd option is cleanest and gives us an adjustable granularity.

Thursday, December 31, 2009 11:21 AM by jesseliberty

# re: Polling Video – A Viable sub-second alternative?

Personally I think that both approaches have their merit, and the ideal solution would be to have them raise the same type of event, which can be examined and a decisions can be made on how to act on said event.

Having a large library of assets which have embedded markers values, I would definitively want to be able to preserve their functionality, but also be able to extend them with either run time additions of markers to the media element, or a player based polling mechanism.

The Markers object having a Type property, which has been used for closed captioning, it might be worth extending that base object for the HVP project to create classes of markers types (CC, URLs, Notes, Images, etc...) (timer polling mechanism could do a RaiseEvent MarkerReached(...)), allowing everyone to continue using the pre-existing mechanism, and having the HVP engine determine at run time how to process the said markers, irrespective of their source...

Thursday, December 31, 2009 12:13 PM by NicS

# re: Polling Video – A Viable sub-second alternative?

Open thoughts -- why not bind the position how the player already is doing it (why the need for a second position display mechanism?).

Also, nitpick but the timer should only start when the player starts, not when it is instantiated (and likewise stop when the user clicks pause/stop).

Thursday, December 31, 2009 1:01 PM by heuertk

# Polling Video ??? A Viable sub-second alternative? Silverlight Blog

Pingback from  Polling Video ??? A Viable sub-second alternative? Silverlight Blog

# re: Polling Video – A Viable sub-second alternative?

Nics, I think your idea is excellent and an great way to leverage existing videos with markers, and to allow content providers to decide for themselves which markers to provide if any.

A unified event is a very interesting idea. It would be great to have you join the development effort and work this up :-)

Friday, January 01, 2010 1:14 AM by jesseliberty

# re: Polling Video – A Viable sub-second alternative?

Tim,

Can you provide a bit more info about binding to the way the player already is doing it? (a code sample would be grand!)

And yes, your pick is not such a nit.

Friday, January 01, 2010 1:15 AM by jesseliberty

# re: Polling Video – A Viable sub-second alternative?

I just posted some example code that creates dynamic markers using the built in TimelineMarkers:

openlightgroup.net/.../Closed-Captioning-with-Silverlight-using-MVVM.aspx

They really seem to work just fine and can meet all the "The advantages of this approach" you have indicated.

Sunday, January 03, 2010 3:12 PM by adefwebserver