Ramesh Inampudi

Android

Building an Android Video Player That Vibrates in Sync

By Ramesh Inampudi · 2026-08-08 · 4 min read

Most video players treat the phone's vibration motor as an afterthought. Games use it well, but when you watch a film or a clip, a gunshot or an explosion reaches you only through the speaker. I wanted a player where the phone itself reacts: a light pulse for a quiet moment, a hard double-tap for an impact. The catch is that this has to work on any video, with no hand-authored vibration track. That is what iRThrum does, and this post covers how it is built and what the design taught me.

Why I built it

I build Android apps and tools as side projects, and I was curious how far automatic haptics could go if the app simply listened to what was playing and watched what was on screen. No beat-mapping, no manual sync, no preprocessing step: pick a video, press play, and the phone responds. The interesting engineering problem turned out not to be the player, which is just ExoPlayer, but getting at the decoded audio and the current frame in real time without disturbing playback.

What it does

You pick a video from your device and iRThrum plays it with Media3 ExoPlayer while a haptic engine converts what it detects into vibration. There are three kinds of trigger:

A sensitivity slider controls how easily all three trigger and how strong the pulses feel, and it can be changed live while a video plays.

How it works

Tapping the audio pipeline

ExoPlayer decodes audio into PCM buffers before handing them to the audio sink. I wanted to measure those buffers without altering them. The solution has two parts:

  1. HapticRenderersFactory is a custom DefaultRenderersFactory that overrides buildAudioSink() to insert a custom AudioProcessor into the pipeline.
  2. HapticAudioProcessor sits there as a pass-through tap. For each PCM buffer about to be played it measures the RMS (average loudness) and the peak (loudest single sample), then forwards the buffer unchanged. Audio quality and sync are unaffected.

Using the audio processor hook is the reusable lesson here. Because the measurement happens inside the pipeline that is already feeding the speaker, the haptics are aligned with what you hear, and there is no second decoder or separate analysis pass.

Why both RMS and peak

I track peak separately from average loudness because a gunshot lasts only a few milliseconds. An RMS average smooths it away, so a loud, very short sound barely moves it. Peak catches the spike. So beats come from a fast versus slow loudness average, while impacts come from a separate peak baseline.

The haptic engine

HapticEngine turns the stream of readings into VibrationEffect calls. Beats and impacts each have their own debounce timer, so rapid sequences such as a drum roll or machine-gun fire do not queue up into a long tail of vibration after the sound has ended.

Reading the picture

The visual side runs on a separate thread:

  1. PlayerView renders onto a TextureView (app:surface_type="texture_view") instead of the default SurfaceView, because only TextureView offers a synchronous way to read the current frame back as a Bitmap.
  2. VisualHapticSource samples that frame roughly ten times a second, downscaled to 16x9 pixels, and measures the mean per-pixel luminance difference against the previous sample. A big jump means a flash or a cut just happened.
  3. Both sources feed the same HapticEngine, so a flash and a bang landing together share one debounce timer instead of producing a double buzz.

Downscaling to 16x9 keeps the comparison cheap, and a luminance difference is enough to detect the kind of abrupt change I care about.

Stack

The only permission is VIBRATE. Video selection goes through the system file picker (ACTION_GET_CONTENT), so no storage permission is needed.

What I learned

Conclusion

iRThrum is a small project, but it shows how much you can do by hooking into the right place in an existing media pipeline. The source is on GitHub under ikppramesh/irthrum, and a sideloadable debug build of about 12 MB is included in the repository's release folder. There is no Play Store listing yet. To build it yourself you need JDK 17, then run ./gradlew installDebug with a device connected.