Smooth Streaming Client v2.0 walkthrough: How to figure out when data chunk failed to be downloaded

This blog belongs to a series of Smooth Streaming Client v2.0 walkthroughs. You could download this latest Smooth Streaming Client SDks here. We have made a few major changes in this version. In this blog, I will introduce to you how to figure out data chunk information while you are downloading it. 

While playing smooth streaming content, you could utilize ChunkDownloadedEventArgs to figure out downloaded chunk information, such as whether data chunk is successfully downloaded, what type of data chunk is, what duration the chunk has and etc. This is very useful for you to monitor data chunk download progress. If you find something wrong, you don’t have to wait the downloader to keep retrying, rather you could route to other media source for instance.

Here is all the information you could get from ChunkDownloadedEventArgs:

 public class ChunkDownloadedEventArgs : EventArgs
public Uri CanonicalUri { get; }
public ChunkInfo Chunk { get; }
public ChunkResult.ChunkResultState DownloadResult { get; }
public ChunkRequestType RequestType { get; }
public HttpStatusCode StatusCode { get; }
public TrackInfo Track { get; }

You could refer to the table below for more information.

The way to implement ChunkDownloadedEventArgs is quite straight forward. Firstly, we need to hook up ChunkDownloadedEventArgs with smooth streaming player. 

SmoothPlayer.ChunkDownloadFailed += new EventHandler<ChunkDownloadedEventArgs>(SSME_ChunkDownloadFailed);

Here I implement a method to read out all the useful information from the event args.

 private void SSME_ChunkDownloadFailed(object sender, ChunkDownloadedEventArgs args)
statusTxt.Text = "The actual request type is " + args.RequestType+"\n";
if (args.Chunk != null)
statusTxt.Text += "chunk is not null"+"\n";
statusTxt.Text += "chunk duration is " + args.Chunk.Duration + "\n";
statusTxt.Text+="chunk time stamp is "+args.Chunk.TimeStamp+"\n";
statusTxt.Text += "chunk stream is " + args.Chunk.Stream + "\n";

if (args.Chunk.Stream != null)
statusTxt.Text += "chunk's stream is not null"+"\n";
statusTxt.Text+="This chunk is "+ args.Chunk.Stream.Type+"\n";
if (args.Track != null)
statusTxt.Text += "track is not null"+"\n";
statusTxt.Text+="The result is "+ args.DownloadResult+"\n";
statusTxt.Text += "The result is " + args.StatusCode+"\n";
Comments (0)

Skip to main content