android - play m3u8 file from internal storage using NanoHTTTPD -


i have downloaded m3u8 , .ts files in internal directory of app , when try play m3u8 file using nanohttpd shows dialog "can't play video". have added code below. possible play app storage or need store in files in storage can accessed other apps.

public class videoplayeractivity extends activity {      @bindview(r.id.video_view)     videoview videoview;     private mediacontroller mediacontroller;     string url = "";     server server;     @override     protected void oncreate(@nullable bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_video_player);         butterknife.bind(this);         mediacontroller = new mediacontroller(this);         videoview.setmediacontroller(mediacontroller);         url = getintent().getstringextra("url");         uri uri = uri.parse(url);         server = new server();         try {             server.start();         } catch (ioexception e) {             e.printstacktrace();         }         videoview.setvideouri("http://localhost:8080");         videoview.requestfocus();         videoview.start();         videoview.setzorderontop(true);      }       @override     protected void ondestroy() {         super.ondestroy();         if(server!= null) {             server.stop();         }     }      private class server extends nanohttpd {          public server() {             super(8080);         }          @override         public response serve(ihttpsession session) {             string answer = "";             fileinputstream fileinputstream = null;             try {                 // open file sd card                 filereader index = new filereader( url);//where url path of m3u8 file in app storage                 bufferedreader reader = new bufferedreader(index);                 string line = "";                 while ((line = reader.readline()) != null) {                     answer += line;                 }                 reader.close();              } catch (ioexception ioe) {                 log.w("httpd", ioe.tostring());             }              return new response(response.status.ok, "application/x-mpegurl", answer);         }     } } 


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -