I want to play a video in android,which i had saved in my assets folder. I have changed it into a byte array and it is playing successfully,using the below code
private String getDataSource() throws IOException {
InputStream stream = getAssets().open("famous.3gp");
if (stream == null)
throw new RuntimeException("stream is null");
File temp = File.createTempFile("test", "mp4");
temp.deleteOnExit();
String tempPath = temp.getAbsolutePath();
int totalRead = 0;
int bytesToRead = 1 * 1024;
FileOutputStream out = new FileOutputStream(temp);
byte buf[] = new byte[128];
int numread = 0;
do {
numread = stream.read(buf);
totalRead += numread;
if (numread <= 0)
break;
out.write(buf, 0, numread);
} while (totalRead<bytesToRead);
try {
stream.close();
} catch (IOException ex) {
Log.e("mini", "error: " + ex.getMessage(), ex);
}
return tempPath;
// }
}
and in oncreate
videoView.setVideoPath(getDataSource());
But my requirement is, i want to play like, first 100 bytes from the array, and when it is finished ,play next 100 bytes in sequence and then another 100 like this.
I got the solution
and in my xml i had only videoview