如何为我的视频录制应用程序获取服务计时器?

时间:2022-10-19 07:28:28

Hi guys i wanted a "service" timer which enable my camera to show the elapsed(incremental) time of a timer when the video recording process has started in such a format 00:00:00? But i do not know how to code the above function in a service activity since it poses the problem of not allowing xml content to link with my mainActivity which in my case is a video recording activity to update the elapsed time on a textview, correct me if i'm wrong or is there a work around/solution?

嗨,大家好我想要一个“服务”计时器,让我的相机在视频录制过程以00:00:00这样的格式开始时显示计时器的经过(增量)时间?但我不知道如何在服务活动中编写上述函数的代码,因为它带来了不允许xml内容与我的mainActivity链接的问题,在我的情况下是一个视频录制活动来更新textview上的已用时间,纠正我如果我错了或者有解决办法吗?

And when the camera exits and returns the service should still keep track of the time since started and update the textview accordingly... Can someone help me on this matter i'm rather new to android/java programming?

当相机退出并返回服务时,应该仍然跟踪自启动以来的时间并相应地更新textview ...有人可以帮我解决这个问题我是android / java编程的新手吗?

This is what i have tried out so far for my mainActivity which performs the recording and display the updated elapsed time of the timer..

这是我迄今为止尝试过的mainActivity,它执行录制并显示计时器的更新已用时间。

1 个解决方案

#1


0  

There may be a better answer, but you could just obtain the time when the recording starts and remember it. It's not clear what owns the textview, but whatever does could update it from the current time by subtracting the start time. You can also pass the service a callback handler which it could use to send you update messages.

可能有更好的答案,但您可以获得录制开始时的时间并记住它。目前尚不清楚拥有textview的是什么,但无论如何都可以通过减去开始时间来从当前时间更新它。您还可以向服务传递一个回调处理程序,它可以用来向您发送更新消息。

#1


0  

There may be a better answer, but you could just obtain the time when the recording starts and remember it. It's not clear what owns the textview, but whatever does could update it from the current time by subtracting the start time. You can also pass the service a callback handler which it could use to send you update messages.

可能有更好的答案,但您可以获得录制开始时的时间并记住它。目前尚不清楚拥有textview的是什么,但无论如何都可以通过减去开始时间来从当前时间更新它。您还可以向服务传递一个回调处理程序,它可以用来向您发送更新消息。