locked
[About PlayTo Function] PlayTo timeout ? RRS feed

  • Question

  • 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); }



    Tuesday, October 2, 2012 6:51 AM

All replies

  • After some research, i found that there is a deadline property "PlayToSourceRequest.Deadline" from  http://msdn.microsoft.com/en-us/library/windows/apps/windows.media.playto.playtosourcerequest.deadline.aspx . And after print it out,  it indicates the deadline time is 500ms after deferral is get. Does this mean we only have 500ms to set  PlayTo source before it timeouts?


    Friday, January 11, 2013 8:37 AM
  • Yes, that is my understanding.  I don't see the "file open" you're talking about in the code you included.  Do you finish setting the sources for _Image and _MediaElement before you get the PlayToSource from them?  I'm wondering if that's your problem?

    Andrea Mantler

    Wednesday, July 17, 2013 7:18 PM