Android干货分享|获取Gif的时间

【Android干货分享|获取Gif的时间】获取assets文件下的flash.gif路径,并获取gif时间。

InputStream inputStream = null; try { inputStream = getAssets().open("flash.gif"); byte[] bytes= new byte[inputStream.available()]; inputStream.read(bytes); Movie movie = Movie.decodeByteArray(bytes, 0, bytes.length); int time = movie.duration(); LogUtils.i_debug("flash_time:", "flash_time:" + time + "uiTelltime:" + 2550); } catch (IOException e) { LogUtils.i_debug("flash_time:", "error:" + e.getMessage()); } finally { if(inputStream != null){ try { inputStream.close(); inputStream = null; } catch (IOException e) {e.printStackTrace(); } } }

    推荐阅读