我正在研究应用程序中通过Miracast进行的屏幕转换,但不确定如何使用Windows.Media.Miracast命名空间。由于Windows 10 1903更新的时间较短,命名空间作为其一部分出现,互联网上的信息有限。
到目前为止,我发现的唯一一件事是这份文件。
我的问题是,有人知道使用这个名称空间的正确方式是什么吗?任何在网上找到的例子或资源都会有很大的帮助。
干杯。
发布于 2019-06-18 16:27:46
这三个示例项目演示了可以从UWP应用程序中使用的各种MiraCast源apis。不确定在UWP之外。
我个人正在使用类似于的代码来投出我的整个屏幕
设备扫描:
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());
}此图像仅用作转换源。一旦连接成功,我的整个屏幕就会被广播。这种行为没有记录在案。希望它不会在未来的更新中得到“修正”。
https://stackoverflow.com/questions/56059494
复制相似问题