问题描述
我正在开发一个UWP,我需要在其中显示可以在用户计算机的任何位置分配的视频。我正在使用C ++作为主代码。为了做到这一点,我首先进入了Package.appxmanifest的代码并引入了下一行:
I am working on a UWP in which I am required to display videos that could be allocated anywhere in the user's computer. I am using C++ for the maincode. To do this first I went inside the code of Package.appxmanifest and introduced the next lines:
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap mp rescap"
<Capabilities>
<rescap:Capability Name="broadFileSystemAccess" />
</Capabilities>
使用broadFileSystemAccess我应该有权从用户计算机上的任何地方打开文件(或者我仍在使用在开发中)尝试这样做我遵循这种方法:
Using broadFileSystemAccess I should have permission to open a file from anywhere on the user's computer (or mine as I am still in development) to try and do this I follow this approach:
FileOpenPicker^ fop = ref new FileOpenPicker();
fop->SuggestedStartLocation = PickerLocationId::Desktop;
fop->FileTypeFilter->Append(".mp4");
fop->FileTypeFilter->Append(".wmv");
Platform::String^ folderP = folder->Path;
create_task(fop->PickSingleFileAsync()).then([this](StorageFile^ file) {
if (file)
{
Platform::String^ path = file->Path;
_media->Source = ref new Uri(file->Path);
}
else{
Text1->Text="Operation cancelled";
}
});
其中_media是我声明的MediaElement在我的XAML中。我应该改变什么才能工作?如果我在TextBox上打印文件的路径,结果是正确的,但不知道它不被接受为Uri。
Where _media is a MediaElement that I declare in my XAML. What should I change for this to work? If I print on a TextBox the path of the file the result is correct but somehow it isn't accepted as an Uri.
推荐答案
这篇关于[UWP] [C ++]如何使用C ++从UWP中的计算机中的任何位置读取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!