如何在NanoHTTPD响应中添加文件路径

时间:2016-01-04 07:24:57

标签: android

我正在使用NanoHTTPD从我的SD卡播放音频文件,它工作正常。

如果我将http://172.16.6.75:8080放入浏览器,则会开始播放,但我想播放http://172.16.6.75:8080/test.mp3这样的确切文件。

希望有人可以帮助我。谢谢!

1 个答案:

答案 0 :(得分:5)

Well, finally I change serve method to have 2 URLS and distinguish between them:

@Override
public Response serve(String uri, Method method,
                      Map<String, String> header,
                      Map<String, String> parameters,
                      Map<String, String> files) {


 if (uri.contains("picture")){          
 //serve the picture 
      return new NanoHTTPD.Response(st, mediasend, fisPicture, f.length());

 }else if (uri.contains("song")){

 //serve the song
      return new NanoHTTPD.Response(st, mediasend, fisSong, f.length());
 }