Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8276537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:24:23+00:00 2026-06-08T08:24:23+00:00

Background: I’m coding a metro-styled app for Win8. I need to be able to

  • 0

Background: I’m coding a metro-styled app for Win8. I need to be able to play music-file. Because of quality and space requirements we’re using encoded audio (mp3/ogg).

I’m using XAudio2 to play sound effects (.wav files), but since I couldn’t figure out a way to play encoded audio with it, I decided to play the music files with Media Foundation (IMFMediaPlayer interface).

I downloaded metro apps sample, and found out that the Media Engine Native C++ video playback sample was closest to what I needed.

Now that my app has MediaPlayer playing musics, I ran into a problem. If the device running the app is slow enough, MediaPlayer hangs. When I’m running the release-version of the app on my device, it’s fine and I can hear the music just fine. But when I attach the debugger or run it on a slower device, it hangs when I’m setting bytestream for the MediaPlayer to play.

Here’s some code, you’ll find it pretty similiar to the sample:

StorageFolder^ installedLocation = Windows::ApplicationModel::Package::Current->InstalledLocation;  
m_pickFileTask = Concurrency::task<StorageFile^>(installedLocation->GetFileAsync(filename)), m_tcs.get_token());    
auto player = this;
m_pickFileTask.then([player](StorageFile^ fileHandle)
{
    player->SetURL(fileHandle->Path);
    Concurrency::task<IRandomAccessStream^> fOpenStreamTask = Concurrency::task<IRandomAccessStream^> (fileHandle->OpenAsync(Windows::Storage::FileAccessMode::Read));
    fOpenStreamTask.then([player](IRandomAccessStream^ streamHandle)
        {                               
            MEDIA::ThrowIfFailed(
                    player->m_spMediaEngine->Pause()
                    );
            MEDIA::GetMediaError(player->m_spMediaEngine);

            player->SetBytestream(streamHandle);                        
            if (player->m_spMediaEngine)
            {
                MEDIA::ThrowIfFailed(
                    player->m_spEngineEx->Play()
                    );
                MEDIA::GetMediaError(player->m_spMediaEngine);
            }
        }
    );      
}
);

And here’s the SetBytestream method:

SetBytestream(IRandomAccessStream^ streamHandle)
{
    if(m_spMFByteStream != nullptr)
    {
        m_spMFByteStream->Close();
        m_spMFByteStream = nullptr;
    }

    MEDIA::ThrowIfFailed(
        MFCreateMFByteStreamOnStreamEx((IUnknown*)streamHandle, &m_spMFByteStream)
        );

    MEDIA::ThrowIfFailed(
        m_spEngineEx->SetSourceFromByteStream(m_spMFByteStream.Get(), m_bstrURL)
        );
    MEDIA::GetMediaError(m_spEngineEx); 

    return;
}

The line where it hangs is:

m_spEngineEx->SetSourceFromByteStream(m_spMFByteStream.Get(), m_bstrURL)

When I’m debugging the app, I can press pause and see the stack. Well, not much of it, but atleast I can see it that it’s indefinitely at

ntdll.dll!77b7f4dc()

Any ideas why my app would hang in such a way?

(OPTIONAL: If you know a better way to play mp3/ogg in a c++ metro-styled app, let me know)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:24:25+00:00Added an answer on June 8, 2026 at 8:24 am

    Could not figure out why this is happening, but I managed to code a work-a-round:

    IMFSourceReader can be used to decode MP3s and feed bytes into XAudio2SourceVoice.

    XAudio2 audio stream effect sample contains good example how to do this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: What I need to accomplish is to remove any records in a collection
Background - I want to extract specific columns from a csv file. The csv
Background: I am developing an app which sends an SMS to users after registration
Background This is only my second PyQt4 project. Developing a Windows app that has
Background My project is urgent and requires that I iterate a large XML file
Background: I have some existing apps in the App Store and I have just
Background: I am using Eclipse to develop an Android app. I have an xml
Background I first wanted to upload a file via json and get a response
Background: I have a little video playing app with a UI inspired by the
Background: I need to reserve an amount of memory below 0xA0000 prior to my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.