当前位置: 首页>>代码示例>>C#>>正文


C# MediaPlayer.SetMediaStreamSource方法代码示例

本文整理汇总了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;
                }
            }
        }
开发者ID:bondarenkod,项目名称:pf-arm-deploy-error,代码行数:93,代码来源:PlaylistPlugin.cs


注:本文中的MediaPlayer.SetMediaStreamSource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。