views:

2348

answers:

5

NOTE: This question is being reasked because I accidentally clicked Community Wiki in the previous one, and obviously that didn't provide enough incentive in the form of reputation for people to answer it. Here is a link to the old question, please do not duplicate those answers (they weren't exactly helpful anyway):

Link to Original Question

Now here's the question...

I'm trying to write a Windows Mobile app targeting Windows Mobile 6.x that will stream an internet radio stream delivered via MMS protocol (just one feature among other things).

Does the .NET Compact Framework have built-in controls or API's that will do this? Or would I need to start looking for a third-party library?

I'm a little confused why this wouldn't be supported in the .NET Compact Framework? I mean MMS is Microsoft's proprietary Windows streaming protocol.


I'm actually not sure how to stream MP3 over http either. I have tried this, but it was unsuccessful:

Some MSDN Article about using WMPLib.dll

In fact, it is unsuccessful if I navigate to the mobile's Windows Media Player itself and give it the same URL I am trying to stream programmatically. However, this same URL does work from the Windows Media Player on my desktop computer. And yes, it is typed in correctly.

I have actually come across another idea to play an MP3 file on Windows Mobile in my custom app, but it doesn't have the ability to stream on the fly. Instead it downloads the entirety of the file before playing it on the mobile device. Here is some code:

string url = @"http://blahblah.com/blahblah.mp3";
string tempFilePath = Path.GetTempPath() + "tempFile.mp3";

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
 byte[] buffer = new byte[1024];
 int bytesRead = 0;

 using (Stream responseStream = response.GetResponseStream())
 {
  using (FileStream fs = new FileStream(tempFilePath, FileMode.Create, FileAccess.ReadWrite))
  {
   while ((bytesRead = responseStream.Read(buffer, 0, buffer.Length)) > 0)
   {
    fs.Write(buffer, 0, bytesRead);
   }
  }
 }
}

SndPlaySync(tempFilePath, 0);

And here is the DllImport:

[DllImport("aygshell.dll", SetLastError = true)]
private static extern IntPtr SndPlaySync(string Path, uint Flags);

Does anyone have any advice for how to stream the MP3 instead?

Thank you in advance.

+1  A: 

When you are using MMS there are two options to the serve your music:

  • install the Windows Media Server and add a publishing point for your music
  • if you have a IIS server, you need to get a WMS plugin that will allow you to stream mp3 over HTTP

Refer to this link.

Note that the above two are the only options currently available to serve media over MMS. If you have some other web server, it will need a plugin like that mentioned above for IIS (not so likely to find).

Once done, the windows media player that comes as part of WinMobile 6.x will be able to tune and play stuff from the server. Nothing required on the client (WinMobile) side.

Sesh
Very good answer however I suspect the OP's original question is regarding playing the stream on a Windows Mobile device and not necessarily on how to setup the streaming server.
Diago
reading again, yeah it does sound so though there is a question about streaming mp3 over http.
Sesh
Yes, this is all client-side and just telling the user to use the built-in Media Player is not an option.
mkmurray
Ok. you will need to use DirectX for this. I will get back with a proper link if I am able to find one.
Sesh
A: 

MMS support is enabled on the Windows Mobile Platform when using the built in Media Player. The first and simplest way to enable the playing of MMS would be to spawn and instance of the Media Player on Windows Mobile and pass it the URL of the stream you need to play, which you already mention doing. However the article your referring to is regarding launching the Media Player on Windows and not Windows Mobile. Theoretically you should be able to open a working MMS URL the same way you would open a HTTP link and the Mobile device will launch Windows Media Player automatically.

From a development aspect I am not aware of any .Net libraries native to the framework that allows the playing of Video Streams, with the possible exception of the Silverlight libraries which I am not up to date with. These would potentially be available for Mobile later this year or early next year. Since the compact framework is a subset of the main framework, I have not seen any references to streaming in the last 2 SDK releases.

As a side-note, when passing the URL to Windows Mobile Media Player add a /* at the end of the URL and see if this plays the stream. If this does not work the method of streaming might not be supplying a valid feed.

I will admit I have not looked at the new Windows Mobile 6.5 SDK and it is very possible it may contain this functionality, however MSDN has not revealed anything to me yet.

Diago
I appreciate the response, as I haven't gotten very many. I may have a few ideas from other avenues I am exploring. I'll post back if I found one that works, and please do the same if you come across something. Thanks.
mkmurray
A: 

As i know Microsoft do not support MMS any more! Anyway, i think it aint problem to implement MMS protocol, You can take any Windows (not mobile) application that can receive MMS stream dump sockets and do the same on windows mobile using Socket class, the main problem will be to decode received stream! There 2 ways as for me: a) DirectShow push source filter that will push samples to decoder (some times you will got situation that required decoder does not exist on device) b) You can build ffmpeg for windows mobile (CE)

alex
Hi, Alex...I'm actually the same guy that has been commenting on your blog posts about DirectShow. Are you saying that if I go with DirectShow and the right "push source filter", I may run into problems anyway because the hardware provider may not have included the correct decoder as well?As far as ffmpeg, I have contemplated this route. I temporarily stalled that path in hopes that I could do it natively with Microsoft API's. I may have to go back to this idea though. Will ffmpeg stream MMS and also stream MP3's?Thanks.
mkmurray
For mp3 there wont be problem with decoder, but video its a big question... but as i wrote you can use ffmeg as decoder (it support almost all existing formats)P.S. anyway receiving stream will have to implement by you self or to find existig library
alex
A: 

Hi,

Does Windows Mobile 6.0 support MMS, HTTP, RTSP and RTP streaming protocols?

Regards Suren

Surendra
You should better ask this as a new question, not post it as an answer. The "Ask Question" button is in the top right of the page.
sth
A: 

As you recommending a different solution or trying to figure out the one picked?

John