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

Share

About Jesse Liberty

Jesse Liberty is an independent consultant and programmer with three decades of experience writing and delivering software projects. He is the author of 2 dozen books and multiple Pluralsight courses, and has been a Senior Technical Evangelist for Microsoft, a Distinguished Software Engineer for AT&T, a VP for Information Services for Citibank and a Software Architect for PBS. He is a Xamarin Certified Mobile Developer and a Xamarin MVP, Microsoft MVP and Telerik MVP.
This entry was posted in z Silverlight Archives. Bookmark the permalink.

One Response to Polling Video – A Viable sub-second alternative?

  1. call carpet says:

    Hi, i think that i noticed you visited my blog thus i got
    here to return the prefer?.I’m trying to in finding issues to improve my web site!I guess its adequate to
    use some of your concepts!!

Leave a Reply

Your email address will not be published.