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


C# MediaElement.SetMediaStreamSource方法代码示例

本文整理汇总了C#中Windows.UI.Xaml.Controls.MediaElement.SetMediaStreamSource方法的典型用法代码示例。如果您正苦于以下问题:C# MediaElement.SetMediaStreamSource方法的具体用法?C# MediaElement.SetMediaStreamSource怎么用?C# MediaElement.SetMediaStreamSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.UI.Xaml.Controls.MediaElement的用法示例。


在下文中一共展示了MediaElement.SetMediaStreamSource方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetSourceAsync

        public async Task SetSourceAsync(MediaElement mediaElement, StorageFile file)
        {
            if (file != null)
            {
                mediaElement.Stop();

                var readStream = await file.OpenAsync(FileAccessMode.Read);
                var ffmpegMSS = FFmpegInteropMSS.CreateFFmpegInteropMSSFromStream(readStream, false, false);
                var mss = ffmpegMSS.GetMediaStreamSource();

                if (mss != null)
                {
                    mediaElement.SetMediaStreamSource(mss);
                }
            }
        }
开发者ID:AlexZayats,项目名称:N7.MediaPlayer,代码行数:16,代码来源:FFmpegSourceProvider.cs

示例2: InitializeAdaptiveMediaSource

        async private void InitializeAdaptiveMediaSource(System.Uri uri, MediaElement m)
        {
            httpClient = new Windows.Web.Http.HttpClient();
            httpClient.DefaultRequestHeaders.TryAppendWithoutValidation("X-CustomHeader", "This is a custom header");

            AdaptiveMediaSourceCreationResult result = await AdaptiveMediaSource.CreateFromUriAsync(uri, httpClient);
            if (result.Status == AdaptiveMediaSourceCreationStatus.Success)
            {
                ams = result.MediaSource;
                m.SetMediaStreamSource(ams);

                //Register for download requested event
                ams.DownloadRequested += DownloadRequested;

                //Register for download success and failure events
                ams.DownloadCompleted += DownloadCompleted;
                ams.DownloadFailed += DownloadFailed;
            }
            else
            {
                rootPage.NotifyUser("Error creating the AdaptiveMediaSource\n\t" + result.Status, NotifyType.ErrorMessage);
            }
        }
开发者ID:COMIsLove,项目名称:Windows-universal-samples,代码行数:23,代码来源:Scenario3.xaml.cs

示例3: InitializeAdaptiveMediaSource

        async private void InitializeAdaptiveMediaSource(System.Uri uri, MediaElement m)
        {
            AdaptiveMediaSourceCreationResult result = await AdaptiveMediaSource.CreateFromUriAsync(uri);
            if(result.Status == AdaptiveMediaSourceCreationStatus.Success)
            {
                ams = result.MediaSource;
                m.SetMediaStreamSource(ams);

                outputBitrates(); //query for available bitrates and output to the log
                txtDownloadBitrate.Text = ams.InitialBitrate.ToString();
                txtPlaybackBitrate.Text = ams.InitialBitrate.ToString();

                //Register for download requests
                ams.DownloadRequested += DownloadRequested;

                //Register for bitrate change events
                ams.DownloadBitrateChanged += DownloadBitrateChanged;
                ams.PlaybackBitrateChanged += PlaybackBitrateChanged;
            }
            else
            {
                rootPage.NotifyUser("Error creating the AdaptiveMediaSource\n\t" + result.Status, NotifyType.ErrorMessage);
            }
        }
开发者ID:RasmusTG,项目名称:Windows-universal-samples,代码行数:24,代码来源:Scenario2.xaml.cs

示例4: Initialize

        /// <summary>
        /// Downloads the manifest from the given source, parses the manifest
        /// and sets the source on the media element 
        /// </summary>
        /// <param name="source">The URL of the source MPD</param>
        /// <param name="mediaElement">The MediaElement to start playback</param>
        /// <returns></returns>
        public async Task Initialize(Uri source, MediaElement mediaElement)
        {
            //1) Download manifest
            var sourceUrlText = source.AbsoluteUri;
            try
            {
                var manifest = new Manifest(sourceUrlText);
                var document = await manifest.LoadManifestAsync(sourceUrlText);

                //2) Parse manifest
                DashManifestParser mpdParser = new DashManifestParser(document, ref manifest);
                if (mpdParser.Parse())
                {

                    if (!manifest.IsSupportedProfile)
                    {
#if DEBUG
                        Logger.Log("The profiles attribute does not contain the \"urn:mpeg:dash:profile:isoff-live:2011\" profile, so it may not work as expected.");
#endif
                    }
                    if (manifest.IsLive)
                    {
                        //3) Play using MSE if it is live
                        MseStreamSource mseSource = new MseStreamSource();
                        player = new Player(mediaElement, mseSource, manifest);
                        if (haveSetLiveOffset && manifest.IsLive)
                        {
                            player.HasLiveOffsetValue = true;
                            player.LiveOffset = liveOffset;
                        }
                        player.Initialize();
                    }
                    else
                    {
                        // Otherwise, use our Adaptive Media Source for on demand content
                        var result = await AdaptiveMediaSource.CreateFromUriAsync(source);
                        if (result.Status != AdaptiveMediaSourceCreationStatus.Success)
                        {
                            throw new Exception("Unable to create media source because: " + result.Status);
                        }
                        var adaptiveSource = result.MediaSource;

                        mediaElement.SetMediaStreamSource(adaptiveSource);
                        mediaElement.Play();
                    }


                }

                else
                {
#if DEBUG
                    Logger.Log("The Parser failed to parse this mpd");
#endif
                    return;
                }
            }
            catch (Exception e)
            {
#if DEBUG
                Logger.Log("Exception when initializing player: " + e.Message + " " + Logger.Display(e));
#endif
            }
        }
开发者ID:RasmusTG,项目名称:Windows-universal-samples,代码行数:71,代码来源:LiveDashPlayer.cs

示例5: InitializeAdaptiveMediaSource

 async private void InitializeAdaptiveMediaSource(System.Uri uri, MediaElement m)
 {
    
     AdaptiveMediaSourceCreationResult result = await AdaptiveMediaSource.CreateFromUriAsync(uri);
     if (result.Status == AdaptiveMediaSourceCreationStatus.Success)
     {
         ams = result.MediaSource;
         SetUpProtectionManager(ref m);
         m.SetMediaStreamSource(ams);
     }
     else
     {
         rootPage.NotifyUser("Error creating the AdaptiveMediaSource\n\t" + result.Status, NotifyType.ErrorMessage);
     }
 }
开发者ID:COMIsLove,项目名称:Windows-universal-samples,代码行数:15,代码来源:Scenario4.xaml.cs


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