Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interrupt prepare() #96

Open
IHiroXI opened this issue Mar 17, 2018 · 2 comments
Open

interrupt prepare() #96

IHiroXI opened this issue Mar 17, 2018 · 2 comments

Comments

@IHiroXI
Copy link

IHiroXI commented Mar 17, 2018

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"

@protyposis
Copy link
Owner

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.

@IHiroXI
Copy link
Author

IHiroXI commented Mar 17, 2018

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants