简体   繁体   中英

How to use android video time stamp (java) to trigger an activity at a certain video frame

I would like to create activities at some specific timestamp while it is being played using Java on android studio.

                import android.media.MediaTimestamp;
                MediaPlayer m = new MediaPlayer();
                MediaTimestamp ts = new MediaTimestamp(0L, 0L, 1.0f);
                ts = m.getTimestamp();

Now, how can I use the timestamp variable ts. Is it a correct way of defining the time stamp? Can I create an activity at the 5.530 sec using this code?

Why not just user Java's timing interface? The moment you start your video, start a timer as well. I'm guessing you will already know the target time in question. Execute an event when that amount of time has passed which you will monitor via the timing interface. Regarding the timer setup, this might interest you: How to set a Timer in Java?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM