java - Android MediaPlayer Error Feedback -


i using mediaplayer in code play video.

this code :

mp.setdatasource(source); mp.setoncompletionlistener(this); mp.setonerrorlistener(this); mp.prepareasync(); 

in cases video not playing(and if call mp.getduration(); fail) , instead of getting onerror feedback getting oncompletion feedback, , can't know if problem occurs.

and times onerror function called.

any idea how can check if mediaplayer fail in oncompletion function?

according docs, onerrorlistener returns:

true if method handled error, false if didn't. returning false, or not having onerrorlistener @ all, cause oncompletionlistener called.

so oncompletion being called when onerror returns false.

your implementation of onerrorlistener should return true avoid oncompletion called.


Comments

Popular posts from this blog

c# SetCompatibleTextRenderingDefault must be called before the first -

C#.NET Oracle.ManagedDataAccess ConfigSchema.xsd -

c++ - Fill runtime data at compile time with templates -