Is it possible to get current playing media from VideoCastManager
before disconnecting from the cast?
I want to save the last progress of current media when the user manually disconnects from cast. I used VideoCastCosumer
method onDisconnected()
but it throws an exception. Not sure what kind of exception because my log only shows this:
System.err: at com.economist.newton.mobile.ui.activity.BaseCastActivity$1.onDisconnected (MyCastActivity.java:81)
This line contains the following line inside the onDisconnected()
method:
try {
if(castManager.getCurrentMediaPosition() > 30000){ // <-here error occurs
...
}
} catch (TransientNetworkDisconnectionException | NoConnectionException e) {
e.printStackTrace();
}
If it any help, castManager
variable is declared in onCreate()
:
castManager = VideoCastManager.getInstance();
Cast companion library: com.google.android.libraries.cast.companionlibrary:ccl:2.8.4