Android VideoView - Detect point of time in video - android

I am using a VideoView to display a video. I am using setOnPreparedListener and setOnCompletionListener to do stuff before and after the video starts and ends.
I was wondering how I could go about detecting some point of time in the video. For eg, say I want to write log to a file when the video has played for 10s. How can I detect the 10s mark?
Thanks
Chris

Step #1: Use postDelayed() or something to get control every second or so.
Step #2: Check getCurrentPosition() and see if it is near your desired marker point. If so, do your processing.
Step #3: Lather, rinse, repeat.
There is no mechanism for Android to call into you specifically when a certain point in time has occurred in the video, so you have to make do with a polling mechanism.

Related

How to instruct exoplayer to pause at a certain position in advance?

I am geting a HLS stream video which has to be played part by part and between the parts I should show some animations.
For example the first part has 19.2 seconds duration. What will be the best way to schedule exoplayer to pause after exact duration ?
Currently I am using a handler to pause after exact duration, which of course is not a good solution, because we may have case when video is not loaded.
One way is to use ClippingMediaSource. Google it and see if it suits you.

Stop an audio play at an exact time

This question has a background for iOS but I am also asking in general.
I am developing an app that requires to start and stop playing an audio file at specific points on the timeline. Apart from finding out the duration of play by substracting the start-time from the stop-time and use the duration to set a separate timer to stop the audio play, is there a more effective way (an exact way) to control the stop?
Currently, my app, under the influence of its "weather" that the stop could be near or far, occasionally the stop will come too late and part of the audio after the specified stop point is played.
Now, I have examined audio editing program namely Audacity, by selecting a range on the timeline and hit play, Audacity starts and stops (at least to the naked ear or the feeble mind) precisely at the specified points. What is the underlying control mechanism and how it differs to iOS API?
Could iOS employ the same or similar mechanism? How about Android?
Much appreciated.
With Android u can start and stop the playback of a audiofile
at the axactly time in milliseconds also like in audacity.
In audacity the time is formated like this 00h00m00.000s.
The Time after the "." are the milliseconds , so u have to transfer both times to milliseconds.
Than u can seek to the start time and stop after the (start-stop)-time difference with a handler.
See here Android: How to stop media (mp3) in playing when specific milliseconds come?
but why u not cut the specific segment in audacity?

Show a Toast When Video reaches its half stage in Android

Hello I want to show a simple Toast Message when a video being played in a Video View in android reaches half of its total duration.
What kind of a Listener do I have to have in place to achieve this? I am aware of get getduration and getcurrentposition methods of Video View. But these wont help unless there is a listener in place which is reading the playback. As far as I know onprepared listener is used before the video starts and oncompletion listener is used once the video finishes playing. Any pointers and snippets are welcome.
As far as I recall, there's no way to get a notification at a certain time (unless they are in newish APIs). What I would do is onPrepared, get the duration of the video, then implement polling at around the halfway mark. When getCurrentPosition() returns the point at 50%, show your Toast.

Video view and date and time in android

I have a module in my application which displays the start time and the end time of the video.
I have create a videoview and these times are shown on the video view. This is working very well.
Now, Is it possible that when I run this video on a laptop/desktop, it shows me the start time and the end time along with the video? Is it possible through any jar file or something.
This is something that I want to know for my knowledge. Is it possible?
This is exactly the link you are looking for:
Get the progress time of the video played under videoview?
It tells you how to display time on the video progress bar.

How to record audio only if it is above certain sound level?

I was trying to do a voice capturing app that only capture when there is noise.
So I used the getMaxAmplitude() method from Media Recorder class.
And here is my idea and work:
I started a service that used a MediaRecorder object to record the sound from emulator' mic, then I have a thread running to check the getMaxAmplitude() value from that object, if it goes above a particular level, I start another recording using a new object from MediaRecorder for a period of time and then save it. If there are for example "3 noises" after starting the service of my app, it should then save 4 audio files, including the main one that use to monitor the amplitude level.
BUT I notice a problem, that is the microphone of android only allows 1 media recorder at a time.
So is there any other way to do this?
You might note the timestamps for the start and end of the noises, and then pull out the needed sections from the audio file at a later time.
Of course, this may not fit exactly with what you're trying to do... tough to say at this point.

Categories

Resources