android - HttpService - not able to play online videos -


i using httpservice send responses android devices , browsers share files. service works on android device. works fine exclude video files. listening online music works perfect. when try watch online video webservice fails error can see below:

java.net.socketexception: sendto failed: epipe (broken pipe) @ libcore.io.iobridge.maybethrowaftersendto(iobridge.java:506) @ libcore.io.iobridge.sendto(iobridge.java:475) @ java.net.plainsocketimpl.write(plainsocketimpl.java:507) @ java.net.plainsocketimpl.access$100(plainsocketimpl.java:46) @ java.net.plainsocketimpl$plainsocketoutputstream.write(plainsocketimpl.java:269) @ org.apache.http.impl.io.abstractsessionoutputbuffer.write(abstractsessionoutputbuffer.java:109) @ org.apache.http.impl.io.contentlengthoutputstream.write(contentlengthoutputstream.java:113) @ org.apache.http.entity.fileentity.writeto(fileentity.java:83) @ org.apache.http.impl.entity.entityserializer.serialize(entityserializer.java:97) @ org.apache.http.impl.abstracthttpserverconnection.sendresponseentity(abstracthttpserverconnection.java:182) @ org.apache.http.protocol.httpservice.handlerequest(httpservice.java:209) @ com.test.communication.server.webserver$1.run(webserver.java:94) @ java.lang.thread.run(thread.java:856) caused by: libcore.io.errnoexception: sendto failed: epipe (broken pipe) @ libcore.io.posix.sendtobytes(native method) @ libcore.io.posix.sendto(posix.java:146) @ libcore.io.blockguardos.sendto(blockguardos.java:177) @ libcore.io.iobridge.sendto(iobridge.java:473) 

some code snippet of server side:

webserver.java

private basichttpprocessor httpproc = null; private basichttpcontext httpcontext = null; private httpservice httpservice = null; private httprequesthandlerregistry registry = null;  public webserver(context context) {     this.setcontext(context);     httpproc = new basichttpprocessor();     httpcontext = new basichttpcontext();            httpproc.addinterceptor(new responsedate());     httpproc.addinterceptor(new responseserver());     httpproc.addinterceptor(new responsecontent());     httpproc.addinterceptor(new responseconncontrol());     httpservice = new httpservice(httpproc,         new defaultconnectionreusestrategy(), new defaulthttpresponsefactory());             registry = new httprequesthandlerregistry();      registry.register(mobile_base_pattern, new mobilefilebrowsehandler(context));      httpservice.sethandlerresolver(registry); }  public void runserver() {     new thread(new runnable() {                  public void run() {             try {                                    serversocket = new serversocket(constants.default_server_port);                      serversocket.setreuseaddress(true);                                              while (running) {                                                            try {                                                                    final socket socket = serversocket.accept();                                                                     defaulthttpserverconnection serverconnection = new defaulthttpserverconnection();                                                                                                        serverconnection.bind(socket, new basichttpparams());                                  httpservice.handlerequest(serverconnection, httpcontext); //error uccurs!!!                                      serverconnection.shutdown();                             } catch (ioexception e) {                                 e.printstacktrace();                             } catch (httpexception e) {                                 e.printstacktrace();                             }                         }                            serversocket.close();                                } catch (socketexception e) {                 e.printstacktrace();             } catch (ioexception e) {                 e.printstacktrace();             }                    running = false;         }     }).start(); } 

mobilefilebrowsehandler.java

public void handle(httprequest request, httpresponse response,         httpcontext context) throws httpexception, ioexception {     httpentity entity = null;            string uristring = request.getrequestline().geturi().substring(13);        contenttype = urlconnection.guesscontenttypefromname(file.getabsolutepath());                   httpentity entity = new fileentity(file, contenttype);                           response.setheader("content-type", contenttype);                 response.setentity(entity); } 

and use following code in client side watch video or listen music:

public static void intentplayer(context context, uri uri, int mode){     string type;     switch(mode){         case 1: type = "video/*"; break;         case 2: type = "audio/*"; break;                     default: return;     }     intent intent = new intent();        intent.setaction(android.content.intent.action_view);      intent.setflags(intent.flag_activity_new_task);                  intent.setdataandtype(uri, type);        context.startactivity(intent); } 

what doing wrong? appreciated!

httpcore did not support content-range,you can add it.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -