首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Windows.Media.Miracast命名空间的正确方式是什么?

使用Windows.Media.Miracast命名空间的正确方式是什么?
EN

Stack Overflow用户
提问于 2019-05-09 12:30:03
回答 1查看 942关注 0票数 0

我正在研究应用程序中通过Miracast进行的屏幕转换,但不确定如何使用Windows.Media.Miracast命名空间。由于Windows 10 1903更新的时间较短,命名空间作为其一部分出现,互联网上的信息有限。

到目前为止,我发现的唯一一件事是这份文件

我的问题是,有人知道使用这个名称空间的正确方式是什么吗?任何在网上找到的例子或资源都会有很大的帮助。

干杯。

EN

回答 1

Stack Overflow用户

发布于 2019-06-18 16:27:46

这三个示例项目演示了可以从UWP应用程序中使用的各种MiraCast源apis。不确定在UWP之外。

我个人正在使用类似于的代码来投出我的整个屏幕

设备扫描:

代码语言:javascript
复制
miraDeviceWatcher = DeviceInformation.CreateWatcher(CastingDevice.GetDeviceSelector(CastingPlaybackTypes.Video)); 
miraHandlerAdded = new TypedEventHandler<DeviceWatcher, DeviceInformation>(async (watcher, deviceInfo) =>
{
   await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
   {
      //Add each discovered device to our listbox
      CastingDevice addedDevice = await CastingDevice.FromIdAsync(deviceInfo.Id);
      var disp = new CastingDisplay(addedDevice); //my viewmodel
      MiraDevices.Add(disp); //ObservableCollection
   });
});
miraDeviceWatcher.Added += miraHandlerAdded;

连接到选定的设备:

代码语言:javascript
复制
public async Task StartCasting(CastingDisplay castee)
{
   //When a device is selected, first thing we do is stop the watcher so it's search doesn't conflict with streaming
   if (miraDeviceWatcher.Status != DeviceWatcherStatus.Stopped)
   {
      miraDeviceWatcher.Stop();
   }

   //Create a new casting connection to the device that's been selected
   connection = castee.Device.CreateCastingConnection();
   //Register for events
   connection.ErrorOccurred += Connection_ErrorOccurred;
   connection.StateChanged += Connection_StateChangedAsync;

   var image = new Windows.UI.Xaml.Controls.Image();
   await connection.RequestStartCastingAsync(image.GetAsCastingSource());
}

此图像仅用作转换源。一旦连接成功,我的整个屏幕就会被广播。这种行为没有记录在案。希望它不会在未来的更新中得到“修正”。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56059494

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档