SmoothStreamingMediaElement.SelectTracksForStream Method
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Sets tracks that will be available for download for a particular stream.
Namespace: Microsoft.Web.Media.SmoothStreaming
Assembly: Microsoft.Web.Media.SmoothStreaming (in Microsoft.Web.Media.SmoothStreaming.dll)
Syntax
'Declaration
Public Function SelectTracksForStream ( _
stream As StreamInfo, _
tracks As IList(Of TrackInfo), _
flushBuffer As Boolean _
) As Boolean
'Usage
Dim instance As SmoothStreamingMediaElement
Dim stream As StreamInfo
Dim tracks As IList(Of TrackInfo)
Dim flushBuffer As Boolean
Dim returnValue As Boolean
returnValue = instance.SelectTracksForStream(stream, _
tracks, flushBuffer)
public bool SelectTracksForStream(
StreamInfo stream,
IList<TrackInfo> tracks,
bool flushBuffer
)
public:
bool SelectTracksForStream(
StreamInfo^ stream,
IList<TrackInfo^>^ tracks,
bool flushBuffer
)
public function SelectTracksForStream(
stream : StreamInfo,
tracks : IList<TrackInfo>,
flushBuffer : boolean
) : boolean
Parameters
- stream
Type: Microsoft.Web.Media.SmoothStreaming.StreamInfo
A StreamInfo object.
- tracks
Type: System.Collections.Generic.IList<TrackInfo>
A generic list of TrackInfo objects.
- flushBuffer
Type: System.Boolean
A Boolean value that specifies whether to flush the buffer associated with the stream.
Return Value
Type: System.Boolean
A Boolean value, true if the selection is valid, otherwise false.
Remarks
For more information, see Select and Monitor Bit Rate (IIS Smooth Streaming).
Examples
The following example uses an implementation of the ManifestReady event to limit the bit rate for customers who do not have premium accounts. The method GetStreamInfoForStreamType gets the StreamInfo object for the "video" stream. From the StreamInfo object, the code adds the bit rates of each TrackInfo object to a list and assigns a midrange bit rate from the manifest to the highRate variable. Only bit rates less than this highRate number will be available to users with non-premium accounts. (Addition of 1 tick to the highRate variable simplifies the lambda expression in the next step.)
The lambda expression re-initializes the StreamInfo AvailableTracks property with a list that contains only the bit rates that are less than highRate. The method SelectTracksForStream sets the SmoothStreamingMediaElement usable tracks to the lower bit rate streams.
void SmoothPlayer_ManifestReady(object sender, EventArgs e)
{
if (!PremiumAccount)
{
StreamInfo videoStream = SmoothPlayer.GetStreamInfoForStreamType("video");
List<ulong> bitRates = new List<ulong>();
foreach(TrackInfo track in videoStream.AvailableTracks)
{
bitRates.Add(track.Bitrate);
}
// Limit bit-rate to 866000.
ulong highRate = 866000 + 1;
List<TrackInfo> allowedTracks =
videoStream.AvailableTracks.Where((ti) => ti.Bitrate < highRate).ToList();
SmoothPlayer.SelectTracksForStream(videoStream, allowedTracks, false);
boolPremium.IsChecked = false;
}
}
For more information, see Select and Monitor Bit Rate (IIS Smooth Streaming).
Permissions
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see https://msdn.microsoft.com/en-us/library/8skskf63(v=vs.90).
See Also
Reference
SmoothStreamingMediaElement Class