Share via


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)

Syntax

'Declaration

Public Overridable Function BeginGetChunk ( _
    timestamp As TimeSpan, _
    callback As AsyncCallback, _
    state As Object _
) As IAsyncResult
'Usage

Dim instance As TrackInfo
Dim timestamp As TimeSpan
Dim callback As AsyncCallback
Dim state As Object
Dim returnValue As IAsyncResult

returnValue = instance.BeginGetChunk(timestamp, _
    callback, state)
public virtual IAsyncResult BeginGetChunk(
    TimeSpan timestamp,
    AsyncCallback callback,
    Object state
)
public:
virtual IAsyncResult^ BeginGetChunk(
    TimeSpan timestamp, 
    AsyncCallback^ callback, 
    Object^ state
)
abstract BeginGetChunk : 
        timestamp:TimeSpan * 
        callback:AsyncCallback * 
        state:Object -> IAsyncResult 
override BeginGetChunk : 
        timestamp:TimeSpan * 
        callback:AsyncCallback * 
        state:Object -> IAsyncResult 
public function BeginGetChunk(
    timestamp : TimeSpan, 
    callback : AsyncCallback, 
    state : Object
) : IAsyncResult

Parameters

Return Value

Type: System.IAsyncResult
An IAsyncResult object.

Remarks

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")
                    {
                        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);
                            }
                        }
                    }
                }
            }
        }
    }

Version Information

Silverlight

Supported in: 5

See Also

Reference

TrackInfo Class

Microsoft.Web.Media.SmoothStreaming Namespace