I'm trying to make a Video Player android application in which I have to display an ImageButton on the top of Video on a specific Time. This is my layout
<FrameLayout
android:id="@+id/videoSurfaceContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<SurfaceView
android:id="@+id/videoSurface"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:orientation="vertical"
android:visibility="gone" >
<ImageButton
android:id="@+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/image" />
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEST TEST"
android:textColor="#FFFFFF" />
</LinearLayout>
</FrameLayout>
and i have an ArrayList of type ThumbnailInfo where
public class ThumbnailInfo {
int time; //time in milliseconds
String body;
ThumbnailInfo(int time,String body){
this.time = time;
this.body = body;
}
}
So now I have time stored in the arraylist and i want to display the thumbnail 10 seconds before the specific time.
For e.g. Suppose time stored in arraylist is 00:40 , 01:30 , 04:50 (just to make the question clear ,time is stored in milliseconds). So when i'm playing the Video , I have to set the Visibility of thumbnail layout as VISIBLE at 00:30 , 01:20 , 04:40 and will set the visibility GONE at 00:41, 01:31 , 04:51
So my question is How can I check stored Time in ArrayList continuously and execute the above mentioned operation.
Currently what i have is the Current Position of the Video using mediaPlayer.getCurrentPosition();
Now I have to compare the current position of the video continuously with the time stored in ArrayList . Is there any observer which can make the task easy or any other approach.
P.S. : User can pause the video multiple times.
Any help is welcome. Thanx in advance !!!