某些機型在拍攝視頻後通過MediaScannerConnection.scanFile()返回的uri爲null,但是path是有的

某些機型在拍攝視頻後通過MediaScannerConnection.scanFile()返回的uri爲null,但是path是有的?

解決方案:

可以通過視頻路徑獲取MediaMetadataRetriever對象來獲取時長:

String filePath = data.getStringExtra("path");
MediaMetadataRetriever media = new MediaMetadataRetriever();
media.setDataSource(filePath);

int duration =Integer.parseInt(media.extractMetadata
(MediaMetadataRetriever.METADATA_KEY_DURATION));

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章