我正在从下面的输入流中播放视频文件是我的方法:
public static String getDataSource(InputStream inputStream) throws IOException {
InputStream stream = inputStream;
if (stream == null)
throw new RuntimeException("stream is null");
File temp = File.createTempFile("mediaplayertmp", "dat");
temp.deleteOnExit();
String tempPath = temp.getAbsolutePath();
FileOutputStream out = new FileOutputStream(temp);
byte buf[] = new byte[128];
do {
int numread = stream.read(buf);
if (numread <= 0)
break;
out.write(buf, 0, numread);
} while (true);
try {
stream.close();
out.close();
} catch (IOException ex) {
// Log.e(TAG, "error: " + ex.getMessage(), ex);
}
return tempPath;
}
但是点击按钮有一个delay of 3 to 4 seconds
播放视频文件,为什么有人可以帮助我?