TrackInfo.BeginGetChunk Method

Beginning method of the asynchronous API for the application to get chunk content based on the timestamp.

Namespace:  Microsoft.Web.Media.SmoothStreaming
Assembly:  Microsoft.Web.Media.SmoothStreaming (in Microsoft.Web.Media.SmoothStreaming.dll)

public virtual IAsyncResult BeginGetChunk(
	TimeSpan timestamp,
	AsyncCallback callback,
	Object state


Type: System.TimeSpan
The timestamp of the chunk start time as a TimeSpan object.
Type: System.AsyncCallback
AsyncCallback delegate method that completes the get chunk action.
Type: System.Object
The state information passed in by the application as Object.

Return Value

Type: System.IAsyncResult
An IAsyncResult object.

The method will always return immediately. It may finish the operation in the same thread or start a new thread to do the work.

The following example loops through segments, streams, and tracks to get the closed captions track. The BeginGetChunk(TimeSpan, AsyncCallback, Object) method starts an asynchronous process that will get each data chunk. For the complete example and more information, see Timeline Markers and Events.

    void SmoothPlayer_MediaOpened(object sender, RoutedEventArgs e)
        foreach (SegmentInfo segmentInfo in SmoothPlayer.ManifestInfo.Segments)
            List<StreamInfo> selectStreams = segmentInfo.SelectedStreams.ToList<StreamInfo>();
            foreach (StreamInfo streamInfo in segmentInfo.AvailableStreams)
                if (streamInfo.Type == System.Windows.Media.MediaStreamType.Script)
                    if (streamInfo.Attributes["Name"] == "ClosedCaptions" ||
                                            streamInfo.Attributes["Name"] == "MARKERS")

                        foreach (TrackInfo trackInfo in streamInfo.SelectedTracks)
                            foreach (ChunkInfo chunk in streamInfo.ChunkList.ToList<ChunkInfo>())
                                IAsyncResult ar =
                                    chunk.TimeStamp, new AsyncCallback(AddMarkers), streamInfo.UniqueId);


Supported in: 5