FileOpenPicker in wp8-xaml

FileOpenPicker in wp8-xaml
0

#1

hey guys

I wanted to open the explorer images for an image and then use it as a profile picture.
I could do this in my draft wp8 native. But now when I click the button it gives me the following error: Platform::COMException ^ at memory location 0x01D3F56C.

my code:

void HelloWorld::menuCloseCallback(CCObject* pSender)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
using namespace Windows::Storage::Pickers;
using namespace Windows::Storage;
using namespace concurrency;
using namespace Platform;
using namespace Windows::Phone::Media::Capture;

Platform::String^ m_PickedFileName;
FileOpenPicker^ openPicker = ref new FileOpenPicker();
openPicker->ViewMode = PickerViewMode::Thumbnail;
openPicker->SuggestedStartLocation = PickerLocationId::PicturesLibrary;
openPicker->FileTypeFilter->Append("*");

create_task(openPicker->PickSingleFileAsync()).then([this](StorageFile^ file){
if (file){
StorageFolder^ localFolder = ApplicationData::Current->LocalFolder;
localFolder->CreateFolderAsync("profile");
create_task(localFolder->GetFolderAsync("profile")).then(
                         [file, localFolder, this](StorageFolder^ proFolder){
   if (proFolder){
      proFolder->CreateFolderAsync("pictures");
      create_task(proFolder->GetFolderAsync("pictures")).then(
                       [file, proFolder, this](StorageFolder^ picFolder){
        copyfile();
      });
   }
});
#else
	CCDirector::sharedDirector()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    exit(0);
#endif
#endif
}

the error occurs immediately at start of variable: “openPicker”.


#2

[[http://stackoverflow.com/questions/15357363/openfilepicker-not-working-on-windows-phone-8-specified-method-is-not-supported]], it seems not support FileOpenPicker in wp8.


#3

I encountered this problem when adding support my Image Picker for wp8.1. This problem is caused by the render loop in my situation, and this can be solved like this CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync

More details can be found here:
https://github.com/cocos2d/cocos2d-x/commit/a62ba927e3d1659798e68f437c92ee4c951f8b85#diff-850ae528ce5011dcb2e4a8906637990bR94