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

About Jesse Liberty

Jesse Liberty has three decades of experience writing and delivering software projects and is the author of 2 dozen books and a couple dozen online courses. His latest book, Building APIs with .NET will be released early in 2025. Liberty is a Senior SW Engineer for CNH and he was 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 Microsoft MVP.
This entry was posted in z Silverlight Archives. Bookmark the permalink.

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

Comments are closed.