Exemple #1
0
    void Player_::HandleEvent(UINT_PTR pEventPtr)
    {
      MediaEventType meType = MEUnknown;  

      IMFMediaEventPtr pEvent;
      //    pEvent.Attach((IMFMediaEvent*)pEventPtr);
      pEvent.Attach(reinterpret_cast<IMFMediaEvent*>(pEventPtr));

      if (!pEvent)
      {
        throw win32_error_exception(E_POINTER);
      }

      // Get the event type.
      THROW_IF_ERR(pEvent->GetType(&meType));

      // Get the event status. If the operation that triggered the event 
      // did not succeed, the status is a failure code.
      HRESULT hrStatus = S_OK;
      THROW_IF_ERR(pEvent->GetStatus(&hrStatus));
      // Check if the async operation succeeded.
      THROW_IF_ERR(hrStatus);

      switch(meType)
      {
      case MESessionTopologyStatus:
        OnTopologyStatus(pEvent);
        break;

      case MEEndOfPresentation:
        OnPresentationEnded(pEvent);
        break;

      case MENewPresentation:
        OnNewPresentation(pEvent);
        break;

      default:
        OnSessionEvent(pEvent, meType);
        break;
      }
    }
HRESULT CPlayer::HandleEvent(UINT_PTR pEventPtr)
{
	HRESULT hrStatus = S_OK;
	HRESULT hr = S_OK;
	MediaEventType meType = MEUnknown;

	IMFMediaEvent *pEvent = (IMFMediaEvent*)pEventPtr;

	if (pEvent == NULL)
	{
		return E_POINTER;
	}

	// Get the event type.
	CHECK_HR(hr = pEvent->GetType(&meType));


	// Get the event status. If the operation that triggered the event 
	// did not succeed, the status is a failure code.
	hr = pEvent->GetStatus(&hrStatus);

	// Check if the async operation succeeded.
	if (SUCCEEDED(hr) && FAILED(hrStatus))
	{
		CHECK_HR(hr = hrStatus);
	}

	switch (meType)
	{
	case MESessionTopologyStatus:
		hr = OnTopologyStatus(pEvent);
		break;
	case MEEndOfPresentation:
		hr = OnPresentationEnded(pEvent);
		ofLogVerbose("ofxWMFVideoPlayer") << "Presentation Ended";
		break;
	case MENewPresentation:
		hr = OnNewPresentation(pEvent);
		ofLogVerbose("ofxWMFVideoPlayer") << "New Presentation";
		break;
	case MESessionTopologySet:
		IMFTopology * topology;
		GetEventObject<IMFTopology>(pEvent, &topology);
		WORD nodeCount;
		topology->GetNodeCount(&nodeCount);
		ofLogVerbose("ofxWMFVideoPlayer") << "Topo set and we have " << nodeCount << " nodes" << endl;
		SafeRelease(&topology);
		break;
	case MESessionStarted:
		ofLogVerbose("ofxWMFVideoPlayer") << "Starting Session";
	case MEBufferingStarted:
		ofLogNotice("ofxWMFVideoPlayer") << "Buffering...";
		break;
	case MEBufferingStopped:
		ofLogNotice("ofxWMFVideoPlayer") << "Finished Buffering...";
		break;
	default:
		hr = OnSessionEvent(pEvent, meType);
		break;
	}

done:
	SafeRelease(&pEvent);
	return hr;
}