MediaPlayer-Extended
MediaPlayer-Extended copied to clipboard
interrupt prepare()
how I can interrupt the execution of prepare() ? for example, when using http streams and a bad Internet channel, the prepare function takes a long time and I want to cancel it now so as not to waste traffic on further downloading now I can only re-create an instance of the class and use the new. and the old in this time spends resources... thread.stop () not supported in dalvik/art and is "not safe"
There's no way to "kill" a running prepare()
call. If you really wanted to forcefully kill it you have to do it the "not safe" way and call prepare()
in a thread and kill this thread.
Alternatively you can use prepareAsync()
, and a call to release()
will stop prepareAsync()
as soon as possible. You will probably still experience some downloading.
After i call release()
track loading via http does not stop. force kill thread with thread.stop()
throw UnSupportedOperationException and not working. nothing happens after calling thread.interrupt()
I realized that interrupt() is just a beacon that puts isInterrupted() = true .
is it impossible to make a method that stops an instance of a class immediately?
also I would be happy to set a timeout on prepare()
when using http
thanks for answers and great analogue of the standard mediaplayer!