locked
NEED HELP!!!Question about using media engine in directx.

    Question

  • I create MediaEnginePlayer.h and MediaEnginePlayer.cpp according to this article:http://msdn.microsoft.com/library/windows/apps/jj207074(v=vs.105).aspx

    Then I create a new DirectXApp to use MediaEnginePlayer.

    In CreateDeviceDependentResources(), after createCubeTask, I add following code

    ...

    m_player = new MediaEnginePlayer(); m_player->Initialize(m_deviceResources->GetD3DDevice(), DXGI_FORMAT_B8G8R8A8_UNORM); auto localFolder = Windows::ApplicationModel::Package::Current->InstalledLocation; create_task(localFolder->GetFileAsync("test.wmv")).then([this](StorageFile^ file) {

    create_task(file->OpenAsync(FileAccessMode::Read)).then([this, file](IRandomAccessStream^ stream) { m_player->SetBytestream(stream, file->Path); m_loadingComplete = true; }); });

    Following code is all in Render()

    if (!m_loadingComplete)
    {
    return;
    }
    auto context = m_deviceResources->GetD3DDeviceContext();
    try
    {
    RECT r;
    r.top = 0.0f;
    r.left = 0.0f;
    r.bottom = 240.0f;
    r.right = 320.0f;
    MFVideoNormalizedRect rect;
    rect.top = 0.0f;
    rect.left = 0.0f;
    rect.right = 1.0f;
    rect.bottom = 1.0f;
    m_player->TransferFrame(m_texture, rect, r);
    }
    catch (Platform::Exception ^ ex)
    {
    return;
    }
    context->UpdateSubresource(m_constantBuffer.Get(), 0, NULL, &m_constantBufferData, 0, 0);
    UINT stride = sizeof(VertexPNT);
    UINT offset = 0;
    context->IASetVertexBuffers(0, 1, m_vertexBuffer.GetAddressOf(), &stride, &offset);
    context->IASetIndexBuffer(m_indexBuffer.Get(), DXGI_FORMAT_R16_UINT, 0);
    context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
    context->IASetInputLayout(m_inputLayout.Get());
    context->VSSetShader(m_vertexShader.Get(), nullptr, 0);
    context->VSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf());
    context->PSSetShader(m_pixelShader.Get(), nullptr, 0);
    context->PSSetShaderResources(0, 1, m_textureView.GetAddressOf());
    context->PSSetSamplers(0, 1, m_sampler.GetAddressOf());
    context->DrawIndexed(m_indexCount, 0, 0);

    After I run this program.

    Several frame of video show on the cube, but only several frame, then the program crashes.

    I uploaded the solution I create to onedrive, you can download this solution if you need:DirectXApp1

    Please help me. Thank you.

    Friday, December 26, 2014 3:48 AM

All replies

  • The app does not crash for me, but the picture stops changing and the music stops.  If you are crashing, I think there's probably a driver issue. Are you able to reproduce the problem on other machines?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, December 26, 2014 3:19 PM
    Moderator
  • Thank you for your response. I have tried in other machines. The program crashes when run with release mode and get many unhandled exception with debug mode.

    This problem occurd after m_player->SetBytestream(stream, file->Path) even if I draw nothing.

    Please help me, I don't know where is wrong.

    Saturday, December 27, 2014 1:24 PM