I have a weird problem with an app. On startup it plays a video clip, this is done by the use of threading. What I want to do is to make the main thread wait for the worker thread to finish before it continues.
However, whatever I do with the video instance within the thread I only get values that seems to be incorrect. For example video.GetHeight returns a negative integer value. IsPlaying always returns false even if the video is actually playing and so on.
The video starts and works perfectly but all the values from the other methods I try to call on the video instance within the thread returns weird values.
Anyone knows where the problem is?
Here is the Thread class:
private class ThreadClass extends Thread {
public VideoView video;
public int ID = -1;
@Override public void run() {
if(this.ID == 1)
{
video = (VideoView)findViewById(R.id.introvideo);
video.setVideoPath("android.resource://" + getPackageName() + "/" + R.raw.intro);
video.start();
System.out.println("Input ID: " + this.ID);
}
else
System.out.println("Unexpected ID (" + this.ID + ")");
}
}
Use UI threads. Check this !