Windows Mobile App - Play Stream Over MMS Protocol?

社会主义新天地 提交于 2019-12-02 17:07:13

问题


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:


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.




回答2:


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.




回答3:


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)



来源:https://stackoverflow.com/questions/1120753/windows-mobile-app-play-stream-over-mms-protocol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!