Commit 02cb8513 authored by Geoffrey Métais's avatar Geoffrey Métais

Check if ML is started instead of initialized

parent 5e2338e8
......@@ -8,7 +8,6 @@ import android.support.v4.app.Fragment
import android.support.v4.app.FragmentActivity
import android.support.v7.preference.PreferenceManager
import kotlinx.coroutines.experimental.Dispatchers
import kotlinx.coroutines.experimental.IO
import kotlinx.coroutines.experimental.delay
import kotlinx.coroutines.experimental.withContext
import org.videolan.libvlc.Media
......@@ -66,7 +65,7 @@ fun Long.random() = (Random().nextFloat() * this).toLong()
suspend inline fun <reified T> Context.getFromMl(crossinline block: Medialibrary.() -> T) = withContext(Dispatchers.IO) {
val ml = Medialibrary.getInstance()
if (ml.isInitiated) block.invoke(ml)
if (ml.isStarted) block.invoke(ml)
else suspendCoroutine { continuation ->
ml.addOnMedialibraryReadyListener(object : Medialibrary.OnMedialibraryReadyListener {
override fun onMedialibraryReady() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment