我正在研究应用程序中通过Miracast铸造的屏幕,但不确定如何使用Windows.media.miracast名称空间。由于Windows 10 1903的更新,该名称空间是。
到目前为止,我唯一发现的就是此文档。
我的问题是有人知道使用此名称空间的正确方法是什么?在网上找到的任何示例或资源都将是一个很好的帮助。
欢呼。
这三个示例项目演示了可以从UWP应用程序中使用的各种奇迹源API。不确定外部UWP。
- https://github.com/microsoft/windows-universal-samples/tree/master/samples/basicmediacasting
- https://github.com/microsoft/windows-universal-samples/tree/master/samples/advancedcasting
- https://github.com/microsoft/windows-universal-samples/tree/master/samples/proctive
我个人在Windows Iot Core上使用以下代码来投射我的整个屏幕
扫描设备:
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;
连接到选定的设备:
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());
}
此图像只是用作铸造源。建立连接后,我的整个屏幕都会广播。行为没有记录。希望它在以后的更新中不会被"修复"。