2017년 3월 18일 토요일

Timing Events To Video Playback


I'm trying to time events to a video file. I need at least a half second accuracy. The problem is there is no currentTime result from the video player component.

I've tried using the timer event - enable/disable. I've tried using system time. Both drift up to a second and throw off the timing of the actions too far.

My closest solution was to start an audio file at the same time the video starts to play. When the audio file ends, it pauses the video and then I can do my action and then resume playing the video with a new audio file that is the correct length of time for the next event. I built in a two second pause before the trigger for the video and audio files play to give the phone a chance to settle if it's busy and this has helped improve accuracy even more. 

BUT this seems like a hard way to do this plus it generates a bunch of little audio clips which are a pain to edit. So I've started looking into activity starters and available free video players. My thought was I can just have a list of my timings and read and send data to the video player. But it seems that calling external apps with the activity starter also jumps out of my app and then my actions are running behind the video screen and I don't have control.

Any ideas on a solution? 

--
for accurate time control of players in android , you should use clock for read file , start play , is playing and real play 
in my project , read file need 50ms ,start play need 50ms , is playing about 10-20ms , real played is hard ,depend on phone , one phone use 30ms , another phone use 440ms  , so if you want control it <500ms, you should change the way provide by app inventor

--
I like the idea of letting the phone "catch up" to the command. It does make it more accurate as some phones have faster processors. I'm running an older model with the idea that if I can get the timing right on it, it shouldn't be a problem for faster phones. If app inventor only had a currentTime result for video and audio it would be an easy solution. Most of the APIs of other video player apps have this call built in. It's probably a low priority to read where the play head is at during playback, yet I can think of a few applications where it would be useful. Funny part is that when a video file plays, the data for the current frame is right there as the phone needs it to play the file. 

--

댓글 없음:

댓글 쓰기