本文整理汇总了C#中MediaPlayer.SetMediaStreamSource方法的典型用法代码示例。如果您正苦于以下问题:C# MediaPlayer.SetMediaStreamSource方法的具体用法?C# MediaPlayer.SetMediaStreamSource怎么用?C# MediaPlayer.SetMediaStreamSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaPlayer
的用法示例。
在下文中一共展示了MediaPlayer.SetMediaStreamSource方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateMediaSource
/// <summary>
/// Updates the media source on the player. This is called internally when a new playlist item is selected.
/// </summary>
/// <param name="mediaPlayer">The MediaPlayer to load the media source (playlist item) into.</param>
/// <param name="oldMediaSource">The old media source (this is usually a PlaylistItem object).</param>
/// <param name="newMediaSource">The new media source (this is usually a PlaylistItem object).</param>
public static void UpdateMediaSource(MediaPlayer mediaPlayer, IMediaSource oldMediaSource, IMediaSource newMediaSource)
{
if (oldMediaSource != null)
{
#if SILVERLIGHT
mediaPlayer.LicenseAcquirer = new LicenseAcquirer();
#else
mediaPlayer.ProtectionManager = null;
mediaPlayer.Stereo3DVideoPackingMode = Stereo3DVideoPackingMode.None;
mediaPlayer.Stereo3DVideoRenderMode = Stereo3DVideoRenderMode.Mono;
#endif
mediaPlayer.VisualMarkers.Clear();
mediaPlayer.AvailableAudioStreams.Clear();
mediaPlayer.AvailableCaptions.Clear();
mediaPlayer.PosterSource = null;
mediaPlayer.Close();
}
foreach (var plugin in mediaPlayer.Plugins)
{
plugin.Update(newMediaSource);
}
if (newMediaSource != null)
{
var playlistItem = newMediaSource as PlaylistItem;
#if SILVERLIGHT
mediaPlayer.LicenseAcquirer = newMediaSource.LicenseAcquirer ?? new LicenseAcquirer();
#else
mediaPlayer.ProtectionManager = newMediaSource.ProtectionManager;
mediaPlayer.Stereo3DVideoPackingMode = newMediaSource.Stereo3DVideoPackingMode;
mediaPlayer.Stereo3DVideoRenderMode = newMediaSource.Stereo3DVideoRenderMode;
#endif
mediaPlayer.PosterSource = newMediaSource.PosterSource;
mediaPlayer.AutoLoad = newMediaSource.AutoLoad;
mediaPlayer.AutoPlay = newMediaSource.AutoPlay;
mediaPlayer.StartupPosition = newMediaSource.StartupPosition;
mediaPlayer.VisualMarkers.Clear();
foreach (var marker in newMediaSource.VisualMarkers)
{
mediaPlayer.VisualMarkers.Add(marker);
}
mediaPlayer.AvailableAudioStreams.Clear();
foreach (var audioStream in newMediaSource.AvailableAudioStreams)
{
mediaPlayer.AvailableAudioStreams.Add(audioStream);
}
mediaPlayer.SelectedCaption = null;
mediaPlayer.AvailableCaptions.Clear();
foreach (var caption in newMediaSource.AvailableCaptions)
{
mediaPlayer.AvailableCaptions.Add(caption);
}
if (newMediaSource.Source != null)
{
mediaPlayer.Source = newMediaSource.Source;
}
#if !SILVERLIGHT
else if (playlistItem != null && playlistItem.SourceStream != null)
{
mediaPlayer.SetSource(playlistItem.SourceStream, playlistItem.MimeType);
}
#if !WINDOWS80
else if (playlistItem != null && playlistItem.MediaStreamSource != null)
{
mediaPlayer.SetMediaStreamSource(playlistItem.MediaStreamSource);
}
#endif
#else
else if (playlistItem != null && playlistItem.SourceStream != null)
{
mediaPlayer.SetSource(playlistItem.SourceStream);
}
else if (playlistItem != null && playlistItem.MediaStreamSource != null)
{
mediaPlayer.SetSource(playlistItem.MediaStreamSource);
}
#endif
else
{
mediaPlayer.Source = null;
}
}
}