我想写一个WCF服务,可以发送mp3文件到客户端。我需要它使用渐进式下载传输MP3文件,因为客户端是一个Android应用程序,我希望它尽快开始播放。我如何使用WCF进行渐进式下载?可能吗?wcf渐进式下载
这是我到目前为止。这似乎工作,但它不是渐进式下载。它在Android应用程序中播放,但仅在整个文件被下载后播放。
服务合同:
[OperationContract, WebGet(UriTemplate = "/GetFileStream/?filepath={virtualPath}")]
Stream GetFileStream(string virtualPath);
服务配置:
<bindings>
<webHttpBinding>
<binding name="streamedHttpBinding" transferMode="StreamedResponse"
maxReceivedMessageSize="1000000000">
</binding>
</webHttpBinding>
</bindings>
<service name="...">
<endpoint address="" behaviorConfiguration="restful" binding="webHttpBinding"
bindingConfiguration="streamedHttpBinding"
contract="..." />
</service>
<behaviors>
<endpointBehaviors>
<behavior name="restful">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
如果您可以提供链接到有关渐进式下载来源,这将是有帮助。对于渐进式下载+ wcf,我的Google搜索功能没有太大的提升。感谢你的帮助。
的Android代码:
player.reset();
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
player.setDataSource(path);
player.prepare();
player.start();
播放器是MediaPlayer对象。我将数据源设置为路径中的网址。
@nithin:你的Android应用程序如何尝试访问mp3文件?你使用什么代码? – Squonk 2011-04-18 19:53:38
@MisterSquonk我认为android客户端正常运行。查看更新后的问题中的代码。 – Nithin 2011-04-18 20:07:29
@nithin:好的,为什么你的'service'结尾是用WCF编写的吗?你想要的效果可以通过一个简单的HTTP服务来实现。 – Squonk 2011-04-18 20:29:19