Export (0) Print
Expand All

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
)

Parameters

timestamp
Type: System..::..TimeSpan
The timestamp of the chunk start time as a TimeSpan object.
callback
Type: System..::..AsyncCallback
AsyncCallback delegate method that completes the get chunk action.
state
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 (IIS Smooth Streaming).

    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")
                    {
                        selectStreams.Add(streamInfo);
                        segmentInfo.SelectStreamsAsync(selectStreams);

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

Silverlight

Supported in: 4

Show:
© 2014 Microsoft