首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >视频缓存

视频缓存
EN

Stack Overflow用户
提问于 2013-01-08 18:43:38
回答 1查看 703关注 0票数 0

我正在试着用这个缓存视频

代码语言:javascript
复制
try {       
    URL oracle = new URL(url);
    URLConnection yc = oracle.openConnection();
    InputStream in = yc.getInputStream();

    File file = new File(getApplicationContext().getCacheDir() ,url);

    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() +"/"+ url);  
        videoView.setVideoPath("chmod 755 "+getCacheDir() +"/"+ url);

    }else {

        videoView.setVideoURI(Uri.parse(videoUrl));
    }
} catch (Exception e) {
    // TODO: handle exception
}
videoView.setVideoURI(Uri.parse(videoUrl));    
MediaController mc = new MediaController(VideoViewC.this);
videoView.setMediaController(mc);
videoView.requestFocus();
videoView.start();          
mc.show();

但是我发现了错误java.net.SocketException: Connection reset by peer。

如果你有任何建议,请给我。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-11-29 20:22:48

我有我的案例问题,特别是我的http服务器,如果没有正确的身份验证,它只是关闭了客户端连接,这是我的问题:

android-async-http Status code and response to onFailure

也许你也有它,由于你的httpserver的特性

你实现缓存视频文件了吗?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14213187

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档