【发布时间】:2017-02-22 15:36:48
【问题描述】:
我使用 WS 在我的应用中下载视频。 在我想打开下载的视频之后。
问题是当我想打开视频时出现这个错误:
VideoView: Unable to open content: /data/user/0/code.package/files/diapos/1.mp4
java.io.IOException: setDataSource failed.
这是下载功能:
MyRestClient.get("/diapos/1", null, new BinaryHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, byte[] binaryData) {
InputStream input = new ByteArrayInputStream(binaryData);
try {
OutputStream output = new FileOutputStream("/diapos/1.mp4");
byte data[] = new byte[4096];
int count;
while ((count = input.read(data)) != -1) {
output.write(data, 0, count);
}
} catch (IOException e) { e.printStackTrace(); }
}
这就是我播放视频的方式:
final VideoView video = (VideoView) getActivity().findViewById(R.id.video);
String path = getActivity().getFilesDir().getAbsolutePath() + "/diapos/1.mp4";
video.setVideoURI(Uri.parse(path));
video.start();
也许这不是一条好路?还是我保存视频的方式? 我指定视频必须下载到内部存储中。没有外部存储。
【问题讨论】:
标签: java android android-videoview loopj