此文版权属于作者所有,任何人、媒体或者网站转载、借用都必须征得作者本人同意!
android.media.MediaMetadataRetriever mmr = new android.media.MediaMetadataRetriever(); try { if (mUri != null) { HashMap<String, String> headers = mHeaders; if (headers == null) { headers = new HashMap<String, String>(); headers.put("User-Agent", "Mozilla/5.0 (Linux; U; Android 4.4.2; zh-CN; MW-KW-001 Build/JRO03C) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 UCBrowser/1.0.0.001 U4/0.8.0 Mobile Safari/533.1"); } mmr.setDataSource(mUri, headers); } else { mmr.setDataSource(mFD, mOffset, mLength); } String duration = mmr.extractMetadata(android.media.MediaMetadataRetriever.METADATA_KEY_DURATION); String width = mmr.extractMetadata(android.media.MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH); String height = mmr.extractMetadata(android.media.MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT); } catch (Exception ex) { Log.e(TAG, "MediaMetadataRetriever exception " + ex); } finally { mmr.release(); }
时间: 2024-10-26 19:43:01