locked
Save video file properties RRS feed

  • Question

  • Hi,

    I have a store app which creates videos and uploads to YouTube.  I would like to store info in the video file so I can tell if the user has already uploaded a file.  So I tried the following code

    StorageFolder^ folder = KnownFolders::VideosLibrary;
    String^ fname = ref new String(L"abctest.mp4");
    task<StorageFile^>(folder->GetFileAsync(fname)).then([this](StorageFile^ file)
      {
        m_file = file;
        return m_file->Properties->GetVideoPropertiesAsync();
      }).then([this](VideoProperties^ vp)
      {
        String^ pub = vp->Publisher;
        vp->Publisher = ref new String(L"TestPublisher");
        return m_file->Properties->SavePropertiesAsync();
      }).then([this](task<void> tvoid)
      {
        try
        {
          tvoid.get();
        }
        catch (Exception ^e)
        {
        	HandleException ( e->Message->Data() );
        }
      });

    I would expect the second time I run this pub would be assigned "TestPublisher".  


    SAP

    Tuesday, April 1, 2014 2:43 AM

Answers

  • In your code you are trying to save the default properties of the file by doing a m_file->Properties->SavePropertiesAsync. The Publisher property is a property of the VideoProperties, so when you try to set the Publisher property, you should try to do a vp->SavePropertiesAsync() to get the correct behavior.

    Here's the code that should work for you:

            //...code as before
            vp->Publisher = ref new String(L"TestPublisher");
            //return m_file->Properties->SavePropertiesAsync();
            vp->SavePropertiesAsync();
        }).then([this](task<void> tvoid)
            //...code as before


    Windows Store Developer Solutions, follow us on Twitter: @WSDevSol|| Want more solutions? See our blog

    Tuesday, April 1, 2014 11:45 PM
    Moderator

All replies

  • In your code you are trying to save the default properties of the file by doing a m_file->Properties->SavePropertiesAsync. The Publisher property is a property of the VideoProperties, so when you try to set the Publisher property, you should try to do a vp->SavePropertiesAsync() to get the correct behavior.

    Here's the code that should work for you:

            //...code as before
            vp->Publisher = ref new String(L"TestPublisher");
            //return m_file->Properties->SavePropertiesAsync();
            vp->SavePropertiesAsync();
        }).then([this](task<void> tvoid)
            //...code as before


    Windows Store Developer Solutions, follow us on Twitter: @WSDevSol|| Want more solutions? See our blog

    Tuesday, April 1, 2014 11:45 PM
    Moderator
  • Thanks.  That works.

    SAP

    Wednesday, April 2, 2014 1:29 AM