Android SDK : Samba server streaming video to Andr

2019-01-26 02:18发布

问题:

I need play video from samba to android device streaming. I've been look for this question and someone say that :

  1. Using JCIFS to scan for and "see" the share: http://jcifs.samba.org/
  2. Implementing a simple HTTP server (NanoHttpd) to stream the content via http: https://github.com/NanoHttpd/nanohttpd
  3. Passing the http://localhost/myvideo link to the VideoView

I'm already use JCIFS to get SmbFile in my project and I also get inputstream( smbfile.getInputStream() ).
Now I import NanoHttpd and I create simple HTTP server that http address ishttp://localhost:8080

private class MyHTTPD extends NanoHTTPD {
    public MyHTTPD() throws IOException {
        super(8080);
    }

    @Override
    public Response serve(String uri, String method, Properties header, Properties parms, Properties files) {
        InputStream is = new SmbFile(filePath,auth).getInputStream();

                  //return index as response
        return new NanoHTTPD.Response(HTTP_OK, "video/mp4", is);
    }
}

server = new MyHTTPD();
server.start();

But my http address is different from http://localhost/myvideo, I don't know how to get right http address and put it in to VideoView.
I don't know how to get path like http://localhost/myvideo .
Thanks for help....

The other question : Can I use VideoView playing video from InputStream ?