locked
Playin MP3 files with WMP lags RRS feed

  • Question

  • Hello all!

    Playing MP3 files with WMP has a big lag. The lag is given by

    put_URL(path) - about 5 sec -

    function of IWMPPlayer interface, and by

    play() - about 1 sec -

    function of IWMPControls if a previous call of stop() was made. The solution I found for this, witch I think that is not the right one, is to keep a IWMPPlayer for each sound, with a single call of put_url(path) function, and to change the stop function of IWMPControls into pause and a seeking back to the begining of the file. Somthing like this:

    void PlayMP(path)
    {
            settings->put_mute(false);
            if (bFirstPlay)
            {
                     player->put_url(path);
                     bFirstPlay = false;
            }
            controls->play();
    }

    void StopMP3()
    {
            settings->put_mute(true);  // to hide the effect of seeking to the begining of the file
            controls->put_currentPosition(0);
            controls->pause();
    }

    Indeed, the lag dissapears (it appear only at first play), but as I said I don't think is the right solution. What could happen if I have, let say 100 sounds, 200 sounds, I keep a IWMPPlayer for each sound?

    So, my question is:
    Is there any way that I can get rid of this lag using few players as posible (using a single player for example)?


    Please advice!
    Thanks!
    Monday, October 19, 2009 8:57 PM

Answers

  • There should not be any lag in WMP. Try to do controls->stop(), player->Close() before starting a new sound.
    You don't need to use many player interfaces - just one. Even better if You code it to be a singleton.

    If You'll find my answer satisfactory or helpful - mark it as answered or vote for it! Thank You.
    "If You think You know better then me, why is Your code not working, then don't waste my time at this forum. Otherwise - do as I'm suggesting."
    • Marked as answer by bogdand84 Tuesday, October 20, 2009 11:50 AM
    Tuesday, October 20, 2009 6:15 AM
  • Probably there's a collision between WMP and DS. 

    That's why OEMs don't support DS sound players in WM - because they would have to do the module attaching / deattaching on their own :). 
    And it also affects the performance...

    If You'll find my answer satisfactory or helpful - mark it as answered or vote for it! Thank You.
    "If You think You know better then me, why is Your code not working, then don't waste my time at this forum. Otherwise - do as I'm suggesting."
    • Marked as answer by bogdand84 Tuesday, October 20, 2009 11:50 AM
    Tuesday, October 20, 2009 11:20 AM
  • Oh, and one more thing bogdand84: system WMP share the same settings for programatic WMP interface.
    So if someone will set loop = true and volume = 75% from WMP app, it will also affect Your app.

    You must store curent user settings, change to Your own and restore those after app's termination.

    Just to warn You :).

    If You'll find my answer satisfactory or helpful - mark it as answered or vote for it! Thank You.
    "If You think You know better then me, why is Your code not working, then don't waste my time at this forum. Otherwise - do as I'm suggesting."
    • Marked as answer by bogdand84 Tuesday, October 20, 2009 2:05 PM
    Tuesday, October 20, 2009 12:03 PM

All replies

  • There should not be any lag in WMP. Try to do controls->stop(), player->Close() before starting a new sound.
    You don't need to use many player interfaces - just one. Even better if You code it to be a singleton.

    If You'll find my answer satisfactory or helpful - mark it as answered or vote for it! Thank You.
    "If You think You know better then me, why is Your code not working, then don't waste my time at this forum. Otherwise - do as I'm suggesting."
    • Marked as answer by bogdand84 Tuesday, October 20, 2009 11:50 AM
    Tuesday, October 20, 2009 6:15 AM
  • It seems to be a device issue. I have tested on some devices, and just one has this lag :).

    Here is what is happenig on this device:

    player->put_url(path) make a call to player->Close() before starting new sound (the debug output looks exactly the same when I use controls->stop(), player->close(), and when I don't call these functions). Here is the output:

    The thread 0x55314ae has exited with code 0 (0x0).
    DebugMem: PD: There are 0 clients left, \Program Files\Games\Brain Exercise by Namco\Brain Exercise by Namco.exe just dettached
    Unload module: OAF_BML.dll
    Unload module: sheap.dll
    Unload module: DBAPI.dll
    The thread 0x657366de has exited with code 0 (0x0).
    The thread 0x255bc6ae has exited with code 0 (0x0).
    Unload module: omx_mp3dec.dll
    Unload module: libOMX_ResourceManagerProxy.dll
    Unload module: oaf_osal.dll
    Unload module: omx_core.dll
    The thread 0xe5624386 has exited with code 0 (0x0).
    The thread 0x65a4f746 has exited with code 0 (0x0).
    Load module: omx_core.dll
    Load module: oaf_osal.dll
    Load module: libOMX_ResourceManagerProxy.dll
    Load module: omx_mp3dec.dll
    Load module: sheap.dll
    Load module: DBAPI.dll
    Load module: OAF_BML.dll
    DebugMem: PA: There are 1 clients attached, \Program Files\Games\Brain Exercise by Namco\Brain Exercise by Namco.exe just attached.


    The problem seems to be the loading and unloading of modules.

    For the record, this device can play MP3 files with DS. Could this fact has anything to do with this, let say strange, behaviour?


    Thanks!
    Tuesday, October 20, 2009 8:27 AM
  • Probably there's a collision between WMP and DS. 

    That's why OEMs don't support DS sound players in WM - because they would have to do the module attaching / deattaching on their own :). 
    And it also affects the performance...

    If You'll find my answer satisfactory or helpful - mark it as answered or vote for it! Thank You.
    "If You think You know better then me, why is Your code not working, then don't waste my time at this forum. Otherwise - do as I'm suggesting."
    • Marked as answer by bogdand84 Tuesday, October 20, 2009 11:50 AM
    Tuesday, October 20, 2009 11:20 AM
  • Thanks a lot!
    Tuesday, October 20, 2009 11:50 AM
  • Oh, and one more thing bogdand84: system WMP share the same settings for programatic WMP interface.
    So if someone will set loop = true and volume = 75% from WMP app, it will also affect Your app.

    You must store curent user settings, change to Your own and restore those after app's termination.

    Just to warn You :).

    If You'll find my answer satisfactory or helpful - mark it as answered or vote for it! Thank You.
    "If You think You know better then me, why is Your code not working, then don't waste my time at this forum. Otherwise - do as I'm suggesting."
    • Marked as answer by bogdand84 Tuesday, October 20, 2009 2:05 PM
    Tuesday, October 20, 2009 12:03 PM
  • Thank you for this warning! It saves me from a lot of digging :) if settings of WMP will be changed.
    Tuesday, October 20, 2009 2:34 PM