locked
play audio file RRS feed

  • Question

  • Hello,

    I've read some posts regarding issues of playing audio on the Win. mobile devices but i couldn't activate the any sound file on my PPC (WM5\6)

    I've tried using the PlaySound API but it donesn't work:

    if (!PlaySound (L"\\Windows\\Rings\\Ring-Innovation.wma", NULL, SND_FILENAME | SND_ASYNC))
    {
    ...
    }

    And i always get into the "if" block, can someone help please?
    Thanks.

    Monday, October 19, 2009 2:30 PM

Answers

  • I really hate to repeat myself so I'll just link You: http://social.msdn.microsoft.com/Forums/en-US/windowsmobiledev/thread/0cb2fedc-9d75-4e6f-b7fb-d914c58e2c9f

    In that discussion I gave a simple example of how to play any WMP supported sound.
    Works on WM3+ (but <WM5 requires older WMP version).

    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."
    • Proposed as answer by Mal Loth Monday, October 19, 2009 7:33 PM
    • Marked as answer by ZHE ZHAO Saturday, October 24, 2009 5:16 AM
    Monday, October 19, 2009 7:32 PM

All replies

  • Monday, October 19, 2009 3:18 PM

  • Hi,

    I need API thta can run on both WM5 and WM6 and according to some posts this function (sndPlaySound) can run only on WM6.
    Also, if possible, i want to use C++ only.
    I already managed to play a WAV file using PlaySound but i want to play WMA\MP3 as well and i didn't manage to do so yet.
    Thanks.
    Monday, October 19, 2009 3:39 PM
  • I really hate to repeat myself so I'll just link You: http://social.msdn.microsoft.com/Forums/en-US/windowsmobiledev/thread/0cb2fedc-9d75-4e6f-b7fb-d914c58e2c9f

    In that discussion I gave a simple example of how to play any WMP supported sound.
    Works on WM3+ (but <WM5 requires older WMP version).

    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."
    • Proposed as answer by Mal Loth Monday, October 19, 2009 7:33 PM
    • Marked as answer by ZHE ZHAO Saturday, October 24, 2009 5:16 AM
    Monday, October 19, 2009 7:32 PM

  • Hello,

    I've read that i need to include a header file (wmp.h) and in order to do so i need to download WMP SDK, is there any preffered WMP SDK version
    that i should use?
    Tuesday, October 20, 2009 7:01 AM
  • WMP 10 is preferred up to WM 6.5.
    For WM3SE and older use WMP 9.

    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."
    Tuesday, October 20, 2009 7:20 AM
  • Hi,

    I've downloaded WMP 10 as you suggested and i encounter 2 problems:
    1) The function put_URL returns S_FALSE
    2) If i try to release the controls, settings and player i get an unexpected exception which i can't find its source but i've noticed
    that if i don't release these objects it doesn't occur.

    Can you please advise?
    Thanks.
    Tuesday, October 20, 2009 9:37 AM
  • put_URL will return false in two conditions:

    1) Invalid path specified -> using '\' instead of '\\' or You're referning to a relative path (path must be absolute 4ex. L"\\Program Files\\My app\\test.mp3")

    2) You have not initialized it's class/interface. Check if You're retriving a valid pointer.

    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."
    Tuesday, October 20, 2009 11:13 AM
  • Hi,

    I've checked again the code and i didn't find any problem:
    1) I used the full path including '\\' and not '\'
    2) The IWMPPLAYER pointer is valid.

    I've tried to play both wav and wma files and none of them worked.

     

    Tuesday, October 20, 2009 12:02 PM
  • You're developing for PPC WM5+ or other?

    Please show me Your code (include also header names).

    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."
    Tuesday, October 20, 2009 12:05 PM

  • Hi,

    Here is the code i'm using for PPC WM5 and WM6:

    #include

     

    <wmp.h>


    IWMPPlayer *player = NULL; IWMPControls *controls = NULL; IWMPSettings *settings = NULL; CoInitializeEx(NULL, COINIT_MULTITHREADED); if (CoCreateInstance(__uuidof(WindowsMediaPlayer), 0, CLSCTX_INPROC_SERVER, __uuidof(IWMPPlayer), (void **)&player) == S_OK) { HRESULT res = player->get_controls(&controls); res = player->get_settings(&settings); //res = settings->put_autoStart(TRUE); res = player->put_URL(L"\\TestApp\\snd.wav"); res = controls->play(); res = S_FALSE } player->close(); controls->Release(); settings->Release(); player->Release(); player = NULL; CoUninitialize();
    By the way, should ia make any difference if i'll run it on SP WM5 \ WM6?
    Thanks for the help.
    Tuesday, October 20, 2009 12:16 PM
  • He,he,he. You're trying to play wav files :D :D. Try to play mp3 or wma and it will be working.
    For wav files You need to use coredll method called - sndPlaySoundW (same as PlaySound but is found on every known WM OS (Win CE also))

    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."
    Tuesday, October 20, 2009 12:27 PM
  • Hi,

    I also tried to play wma file (which is one of the OS rinings file) and it didn't work either
    Tuesday, October 20, 2009 12:35 PM
  • Strange, because I know it works. Try on emu or other device.
    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."
    Tuesday, October 20, 2009 1:41 PM