I am trying to play some audio from within a program using MCIWndPlay(m_Audio); or MCIWndPlayTo(m_Audio, duration); type calls.

The program is getting the path of the media from an RSS feed and the audio can be either an MP3 file or a streaming MP3 (either progressive download or actual streaming MP3). This code plays straight MP3 files fine, and it plays progressive download MP3s from a .m3u fine, but it doesn't seem to agree with streaming audio.

When I give it a stream (.asx) it doesn't do anything. MCIWndPlay(m_Audio); is returning a zero, so I guess it thinks it's doing it right, but it's not actually playing the audio.

Also, for MCIWndPlayTo(m_Audio, duration); , It doesn't seem to like any duration I put in for it, it tells me that it's out of range. I have another topic going asking about how to put in a duration that is greater than the length, but I'd like to be able to play some duration, X, or the entire stream, whichever is shorter.


ETA:
FWIW, it's not like the PC itself has a problem playing the .asx streams. If I plug the path into a browser it pops up with WMP and starts playing.

Dani AI

Generated

Short summary and likely cause

The MCIWnd helper is a legacy wrapper around the Media Control Interface and is not guaranteed to resolve playlist/redirect metafiles the way Windows Media Player does. An .asx is a Windows Media metafile (an XML playlist/redirector) that the Player parses and expands into real media URLs; MCI drivers often expect a direct media element and may silently return success without actually streaming the referenced content. (learn.microsoft.com)

Practical diagnostics (what to check first)

If the windowed MCI helper reports success but no audio, ask the helper what it actually opened and whether the device reported an error: query the file/device name, the current mode/time format and the MCI textual error buffer. Also remember the “play-to” macro uses the device time format (frames/samples/bytes/ms); if the device is not using milliseconds, a numeric end value can be rejected as out of range. Use the helper macros that return filename, device, mode and error text, and force/check the time format or clamp the target position to the reported length before issuing a play-to. (learn.microsoft.com)

Two reliable fixes (workflows to apply)

  • If the feed yields an .asx, parse that XML and extract the direct stream URL (REF href). Passing a direct media URL to a media API that understands HTTP streams is simpler than relying on MCI to follow playlists.
  • Host the Windows Media Player control inside the process and give it the .asx URL; the Player will parse the metafile and handle buffering/reconnects. Example (ATL-style) — create an ActiveX host, query IWMPPlayer, then set the URL property:
AtlAxWinInit();
CAxWindow w;
w.Create(parentHwnd, rc, _T("WMPlayer.OCX"), WS_CHILD|WS_VISIBLE);
CComPtr<IWMPPlayer> spPlayer;
w.QueryControl(&spPlayer);
spPlayer->put_URL(CComBSTR(L"https://server/path/stream.asx"));

The Player object exposes the URL property and playlist helpers for .asx handling. For embedding examples and the URL property reference see the Windows Media Player SDK docs. (prowaretech.com)

Short recommendation tied to the thread

For the OP (): prefer hosting the Player or parsing the .asx to the underlying media URL. The MCI approach is okay for local files and progressive downloads but is driver-dependent for streaming; for modern, robust streaming consider Media Foundation / MediaPlayer APIs instead of the legacy MCI wrappers. ’s request for code is valid — the WMP-host snippet above is a compact alternative that reliably handles .asx playlists.

Recommended Answers

All 5 Replies

anyone?

Spam? The two threads are about entirely different problems. This one is asking if I can play streams with these function calls or not. The other thread is about arguments to a function call (albeit the same function) and why it doesn't appear to act as specified in the documentation. Is every thread on here that asks a question about similar or same functions spam even if the questions are largely unrelated? :idea:


Also, how much more code do you need? As I said, my code plays fine from an an actual MP3 or an M3U file path, so I don't think that the code setup for these function calls is incorrect. My question specifically is asking about passing an ASX audio stream to this particular function call. If you have specific questions about how I'm setting up the MCI or other settings you can ask or point out what other code might be affecting this problem and I can post that code, but as far as I can tell, this is the only code I'm having a problem with.

Thanks for the helpful input though. :icon_neutral:

. . . OK . . . :S

If I'm apparently going to get warnings and threads deleted for asking unrelated questions, can someone tell me how to go about editing the thread title to contain information regarding the question about the MCIWndPlayTo function?

As far as I know, you can't edit a post after 30 minutes and editing the OP is the only way to change the topic title (?)

The other question had nothing to do with streams but was about the use of a specific function call and how to use it in the generic sense and why it wasn't working. People that don't know about streaming audio with the MCI likely won't click on this thread even though they might know about usage of that call.

It is at this point irrelevant - you still HAVE NOT POSTED A BEAN OF CODE.

You should have posted that diatribe in the feedback forum - they like that kind of stuff there - keeps them entertained for whole days at a time.

Here - it's rubbish.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.