Hi all,
I wish to set Image / MediaElement source file while charm-bar is opened.
The scenario is :
1. Open Charm-Bar
2. Click on Devices Icon
3. Set Image / MediaElement source in the PlayToManager's SourceRequested callback function.
when I try to open and set Image / MediaElement source property within the callback function , the charm-bar often shows "This app can't send to other device right now" in seconds even if the file open procedure is not completed yet.
Our expectation is the message "This app can't send to other device right now" should be showed after the callback function is returned and without setting any source to PlayToManager. However, it seems that PlayToManager has its own
timeout time regardless the callback func is completed or not .And when it timeouts , it will show the message automatically.
My question is , is there any way to wait until the file is opened ? and how much time do we have before it timeouts?
(By the way, our files will be from network location , and that 's why we need to wait until files are opened)
event m_sync;
sourceRequestedToken = _PlayToManager->SourceRequested += ref new TypedEventHandler<PlayToManager^, PlayToSourceRequestedEventArgs^>(this, &DlnaPlayToClass::playToManager_SourceRequested);
void DlnaPlayToClass::playToManager_SourceRequested(PlayToManager^ sender, PlayToSourceRequestedEventArgs^ e)
{
m_sync.reset();
//... Open file and set source in a different thread for MediaElement / Image
// When Image/MediaElement' s source is set , call m_sync.set
m_sync.wait();
auto deferral = e->SourceRequest->GetDeferral();
Windows::UI::Core::DispatchedHandler^ handler = ref new Windows::UI::Core::DispatchedHandler([=] ()
{
if(m_MediaType == MediaType::MEDIA_PHOTO)
{
e->SourceRequest->SetSource(_Image->PlayToSource);
OutputDebugString(L"DlnaPlayTo [playToManager_SourceRequested] :: Photo\n");
}
else
{
e->SourceRequest->SetSource(_MediaElement->PlayToSource);
OutputDebugString(L"DlnaPlayTo [playToManager_SourceRequested] :: Music / Video\n");
}
deferral->Complete();
}, Platform::CallbackContext::Any);
auto action = _MsgDispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, handler);
}