Maybe you are looking for the FFmpegMediaMetadataRetriever
FFmpegMediaMetadataRetriever class provides a unified interface for the retrieving frame and metadata from an input media file.
By using METADATA_KEY_DURATION constant of FFmpegMediaMetadataRetriever you can get the duration of your video.It will return the string to you then you can convert it into LONG to get TIME.
Here is the code you should use:
FFmpegMediaMetadataRetriever mFFmpegMediaMetadataRetriever = new MediaMetadataRetriever();
mFFmpegMediaMetadataRetriever .setDataSource("Your video url");
String mVideoDuration = mFFmpegMediaMetadataRetriever .extractMetadata(FFmpegMediaMetadataRetriever .METADATA_KEY_DURATION);
long mTimeInMilliseconds= Long.parseLong(mVideoDuration);
if above still not work then use
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
if (Build.VERSION.SDK_INT >= 14)
retriever.setDataSource("Your video url", new HashMap<String, String>());
else
retriever.setDataSource("Your video url");
From your code.
Hope it will help you. Best of luck.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…