I am trying to write a WCF service that can send mp3 files to a client. I need it to transfer the mp3 file using progressive download, because the client is an android application, and I want it to start playing as soon as possible. How to make progressive download using WCF? Is it possible?
Here is what I still have. This seems to work, but not progressive download. It plays in the Android application, but only after the entire file has been downloaded.
Service Agreement:
[OperationContract, WebGet(UriTemplate = "/GetFileStream/?filepath={virtualPath}")] Stream GetFileStream(string virtualPath);
Service Configuration:
<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>
If you can provide links to gradual download sources, this will also be helpful. My googling is not too much for progressive download + wcf. I appreciate your help.
Android Code:
player.reset(); player.setAudioStreamType(AudioManager.STREAM_MUSIC); player.setDataSource(path); player.prepare(); player.start();
player is a MediaPlayer object. I set the data source to the url along the way.
source share