Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android adb shell command to play sound from the command line

Tags:

android

adb

I have a set of rooted android devices I can access through adb over tcp/ip. I am trying to identify a specific one by playing a sound from the command line (one of the .ogg files from /system/media/audio).

I know I could probably build an app for this but it feels like an overkill to use an APK, and I'm hoping there is a more native way. I already know how to start intents from the command line.

Things I have tried :

  • Investigated using service call media.player but could not find any useful reference about the syntax. I can see with dumpsys media.player references about AwesomePlayer but couln't get anything going.
  • Tried to find a compiled version of "/system/bin/media" from the android source code, as it is missing from the device, but without any luck so far.
  • Tried to build a command line java app to call android.media.MediaPlayer with dalvikvm but my knowledge of Android and java is too limited (class compiled but complained about missing dependencies at runtime)

Any ideas?

like image 746
Benjamin Avatar asked Sep 19 '25 12:09

Benjamin


1 Answers

As seen in this other thread

you can do this with a single shell command if you have a file there:

am start -a android.intent.action.VIEW -d /sdcard/somthing/example.wav -t audio/wav
like image 116
yoavsnake Avatar answered Sep 21 '25 04:09

yoavsnake