android - VLC: Cant Play Video from getExternalStorageDirectory() -


i have saved video file storage , tried play video app using intent .. on other players file playing fine when tried play file vlc gives me following error;

playback error vlc encountered error media. please try refreshing media library.

and

the location /storage/emulated/0/myfolder/file.mov cannot played.

saving method

private string savetodir(string downloadurl) {      try {          file dir = new file(environment                 .getexternalstoragedirectory(),                 "myfolder");         if (dir.exists() == false) {             dir.mkdirs();         }          url url = new url(downloadurl);         string filename = downloadurl.substring(downloadurl.lastindexof('/') + 1);         file file = new file(dir, filename);         if (file.exists()) {             return file.getabsolutepath();         } else {             long starttime = system.currenttimemillis();             log.d("downloadmanager", "download url:" + url);             log.d("downloadmanager", "download file name:" + filename);              urlconnection uconn = url.openconnection();             uconn.setreadtimeout(timeout_connection);             uconn.setconnecttimeout(timeout_socket);              inputstream = uconn.getinputstream();             bufferedinputstream bufferinstream = new bufferedinputstream(is);              bufferedoutputstream outstream = null;             outstream = new bufferedoutputstream(new fileoutputstream(file));             byte[] buf = new byte[5000];             int len;             while ((len = bufferinstream.read(buf)) > 0) {                 outstream.write(buf, 0, len);             }              outstream.flush();             outstream.close();             makefileavailable(file);             log.d("downloadmanager", "download ready in" + ((system.currenttimemillis() - starttime) / 1000) + "sec");             int dotindex = filename.lastindexof('.');             if (dotindex >= 0) {                 filename = filename.substring(0, dotindex);              }             return file.getabsolutepath();         }     } catch (ioexception e) {         log.d("downloadmanager", "error:" + e);         e.printstacktrace();         return "";     }  } 

intent

 string responselink = savetodir(getimgurl());  string type = fileutils.getmimetype(responselink);   intent intent = new intent(intent.action_view, uri.parse(responselink));  intent.setdataandtype(uri.parse(responselink), type);                                intent.addflags(intent.flag_grant_read_uri_permission);                                  intent.addflags(intent.flag_grant_write_uri_permission);  generalproplistener.getselfcontext().startactivity(intent); 

try prepending "file://" responselink.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -