Question by
xo1988 · Aug 29, 2016 at 05:10 AM ·
buttoncoroutineandroidjavaobjectjni
JNI call block Coroutine & update thread
In Oculus VR Project play video by wifi, code below:
StartCoroutine (StartPlayCoroutine ()); IEnumerator StartPlayCoroutine () { ... mediaPlayer = StartVideoPlayerOnTextureId(textureWidth, textureHeight, mediaFullPath); }
AndroidJavaObject StartVideoPlayerOnTextureId () { IntPtr setSurfaceMethodId = AndroidJNI.GetMethodID(mediaPlayer.GetRawClass(),"setSurface",(Landroid/view/Surface;) try { Debug.Log("timestamp000"+Time.fixedTime); mediaPlayer.Call("setDataSource", mediaPath); mediaPlayer.Call("prepare"); mediaPlayer.Call("setLooping", true); mediaPlayer.Call("start"); Debug.Log("timestamp111"+Time.fixedTime); } catch (Exception e) { Debug.Log("Failed to start mediaPlayer with message " + e.Message); } return mediaPlayer; }
From the log I find that timestamp000 19.00 and timestamp111 19.00 but this takes more than 10s. and update thread also block.
It seems that but JNI takes too much times, and block the Coroutine and update thread.
The screen also blocked.
Does there have a method to solve it?
Comment
Your answer
Follow this Question
Related Questions
How can I start a Coroutine with the onClick of a button? 0 Answers
unable to share the text using share button script (for android) 0 Answers
Setting button intractability causes an error 1 Answer
Functions on GUI elements disapearing after reloading the scene 1 Answer
Unity Button Script 0 Answers