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:
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
One Response to Polling Video – A Viable sub-second alternative?