Play video from application cache

Can someone explain why downloading / playing videos from the application cache directory does not work, but loading / playing the same video from my SD card really works?

Note: this video is loading. I save memory before calling VideoView.setVideoPath(...) .

 // Works File file = new File(Environment.getExternalStorageDirectory(), "vid-test.3gp"); // Does not work File file = new File(getCacheDir(), "vid-test.3gp"); 

In each case, there is a file .

If I try to call VideoView.setVideoURI(...) and the "streaming" video on my VideoView , it will get in and skip whether it will work.

Can anyone explain this behavior?

+4
source share
1 answer

This is probably a resolution issue. Here is the cut off work:

 InputStream in = connection.getInputStream(); File file = new File(getApplicationContext().getCacheDir() ,fileName); if(!file.exists()){ file.setReadable(true); file.createNewFile(); if (file.canWrite()){ FileOutputStream out = new FileOutputStream(file); byte[] buffer = new byte[1024]; int len1 = 0; while ( (len1 = in.read(buffer)) > 0 ) { out.write(buffer,0, len1); } out.close(); } in.close(); Runtime.getRuntime().exec("chmod 755 "+getCacheDir() +"/"+ fileName); } 
+2
source

All Articles