[UWP]更改用CameraCaptureUI录制的视频的名称[C ++] [英] [UWP]Change the name of a video recorded with CameraCaptureUI [C++]

查看:64
本文介绍了[UWP]更改用CameraCaptureUI录制的视频的名称[C ++]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I我正在使用C ++和XAML开发UI应用程序。在执行中有一点我使用CameraCaptureUI来
录制视频。代码如下所示:


 CameraCaptureUI ^ dialog = ref new CameraCaptureUI(); 
dialog-> VideoSettings-> Format = CameraCaptureUIVideoFormat :: Mp4;




concurrency :: task< StorageFile ^>(dialog-> CaptureFileAsync(CameraCaptureUIMode :: Video))。then([this](StorageFile) ^ file){
if(file!= nullptr){

concurrency :: task< Streams :: IRandomAccessStream ^>(file-> OpenAsync(FileAccessMode :: Read))。然后([this](Streams :: IRandomAccessStream ^ stream){
// CapturedVideo-> SetSource(stream," video / mp4");
logger-> Text =" grabando" ;
});

Windows :: Foundation :: Collections :: IPropertySet ^ appSettings = ApplicationData :: Current-> LocalSettings->值;

appSettings->插入(" CaptureVideo",PropertyValue :: CreateString(file-> Path));

});

这就是我所做的一切我录制了一个视频,它总是有"CCapture(X)"。作为一个名字,X是一个创建独特的
名称。我尝试使用CopyAsync函数复制文件:


 create_task(StorageLibrary :: GetLibraryAsync(KnownLibraryId :: Videos))
.then([this](StorageLibrary ^ videosLibrary)
{
Windows :: Storage :: StorageFolder ^ _videoLib = videosLibrary-> SaveFolder;
if(_videoLib == nullptr)
{
//在这种情况下回退到本地应用程序存储,因为图片库不可用
_videoLib = ApplicationData :: Current-> LocalFolder;
}


});

// EtiquetaVid是早先创建的字符串
file-> CopyAsync(_videoLib,stringToPlatformString(etiquetaVid),NameCollisionOption :: GenerateUniqueName);





但是我的视频库中没有任何内容,并且没有任何错误可以指导我。



我的问题是:如何控制输出视频的名称?我搜索了文档和论坛,但似乎无法找到解决方案。




解决方案

嗨Carlos Her,


>>

我该怎么办?控制输出视频的名称?


由于您已经在StorageFile对象中获取了视频,因此您可以使用
直接重命名该视频
StorageFile.RenameAsync方法


最好的问候,


罗伊


I am using C++ and XAML to develop an UI application. There is a point in the execution that I use a CameraCaptureUI to record a video. The code looks like this:

CameraCaptureUI^ dialog = ref new CameraCaptureUI();
    dialog->VideoSettings->Format = CameraCaptureUIVideoFormat::Mp4;




    concurrency::task<StorageFile^>(dialog->CaptureFileAsync(CameraCaptureUIMode::Video)).then([this](StorageFile^ file) {
        if (file != nullptr) {

            concurrency::task<Streams::IRandomAccessStream^>(file->OpenAsync(FileAccessMode::Read)).then([this](Streams::IRandomAccessStream^ stream) {
                //  CapturedVideo->SetSource(stream, "video/mp4");
                logger->Text = "grabando";
            });

            Windows::Foundation::Collections::IPropertySet^ appSettings = ApplicationData::Current->LocalSettings->Values;

            appSettings->Insert("CaptureVideo", PropertyValue::CreateString(file->Path));

     });

This is all I do to it, once I record a video, it always has "CCapture(X)" as a name, being X a away to create unique names. I tried copying the file by using CopyAsync function:

create_task(StorageLibrary::GetLibraryAsync(KnownLibraryId::Videos))
                .then([this](StorageLibrary^ videosLibrary)
            {
                Windows::Storage::StorageFolder^ _videoLib = videosLibrary->SaveFolder;
                if (_videoLib == nullptr)
                {
                    // In this case fall back to the local app storage since the Pictures Library is not available
                    _videoLib = ApplicationData::Current->LocalFolder;
                }


            });

            //EtiquetaVid is a string created earlier
            file->CopyAsync(_videoLib, stringToPlatformString(etiquetaVid), NameCollisionOption::GenerateUniqueName);


But I nothing appeared on my video library and there were no errors to guide me.

My question is: How can I control the name of the output video? I've searched through the documentation and forums but I can't seem to find a solution.

解决方案

Hi Carlos Her,

>> How can I control the name of the output video?

Since you have already get the video in a StorageFile Object, you could directly rename it using StorageFile.RenameAsync Method.

Best regards,

Roy


这篇关于[UWP]更改用CameraCaptureUI录制的视频的名称[C ++]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆