android - How can I get a video duration before/without playing -


videoview.setoncompletionlistener(new mediaplayer.oncompletionlistener()             {               @override               public void oncompletion(mediaplayer mp)                {                   videoview videoview = (videoview) findviewbyid(r.id.videoview1);                   long duration= videoview.getduration();                    toast.maketext(getapplicationcontext(), "video completed", toast.length_long).show();                   mshimmerdevice.stopstreaming();                      mshimmerdevice.stop();                }              });        } 

though code works after video had finished playing

you use mediametadataretriever. way can retrieve information video without loading/playing it.

mediametadataretriever retriever = new mediametadataretriever(); retriever.setdatasource(your_data_source); string time = retriever.extractmetadata(mediametadataretriever.metadata_key_duration); long timeinmillisec = long.parselong( time ); 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -