本文整理汇总了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);
}
}
}
示例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);
}
}
示例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);
}
}
示例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
}
}
示例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);
}
}