MediaMetadataRetriever setDataSource throws IllegalArgumentException

后端 未结 5 1706
一个人的身影
一个人的身影 2020-12-01 14:18

I\'m trying to get the size of a remote video using this class and i\'m getting IllegalArgumentException if the video is remote.

the video is an mp4 stored in one se

5条回答
  •  借酒劲吻你
    2020-12-01 15:08

    try {
        MediaMetadataRetriever retriever = new  MediaMetadataRetriever();
        Bitmap bmp = null;      
        retriever.setDataSource(uri.toString(), new HashMap());
        bmp = retriever.getFrameAtTime();           
        videoHeight = (int) (bmp.getHeight()*((float)getIntWidth()/bmp.getWidth()));
    } catch (Exception e) {
        e.printStackTrace();
    }   
    

提交回复
热议问题