如何添加在NanoHTTPD响应文件的路径 [英] How to add File path in NanoHTTPD response

查看:519
本文介绍了如何添加在NanoHTTPD响应文件的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用NanoHTTPD从我的SD卡播放音频文件

,它工作正常。

如果我把 http://172.16.6.75:8080 在我的浏览器开始播放,但我想喜欢玩 http://172.16.6.75:8080/test.mp3 的确切文件。

希望有人能帮助我在这里。谢谢!


解决方案

 好了,终于我换服务的方法有2个网址对其进行区分:@覆盖
市民反应发球(字符串URI,方法方法,
                      地图<字符串,字符串>头,
                      地图<字符串,字符串>参数,
                      地图<字符串,字符串>文件){
 如果(uri.contains(图片报)){
 //服务图片
      返回新NanoHTTPD.Response(ST,mediasend,fisPicture,f.length()); }否则如果(uri.contains(宋史)){ //服务首歌
      返回新NanoHTTPD.Response(ST,mediasend,fisSong,f.length());
 }

I am using NanoHTTPD to play audio file from my sdcard,It works fine.

If i put http://172.16.6.75:8080 in my browser it starts playing but i want to play the exact file like http://172.16.6.75:8080/test.mp3.

Hope someone can help me here. Thanks!

解决方案

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());
 }

这篇关于如何添加在NanoHTTPD响应文件的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆