I am having one android target.
I have some audio file in mnt/sdcard0.
How can I play through adb command?
Music player application is already installed in the target.
Asked
Active
Viewed 2.4k times
4

Konrad Krakowiak
- 12,285
- 11
- 58
- 45

user3664681
- 171
- 1
- 3
- 13
-
1possible duplicate of [How can I play a mp3 file via adb commnad with google play musc on android kitkat 4.4.4?](http://stackoverflow.com/questions/25083848/how-can-i-play-a-mp3-file-via-adb-commnad-with-google-play-musc-on-android-kitka) – Kushal May 25 '15 at 11:52
2 Answers
8
use the following adb shell command:
adb shell am start -a android.intent.action.VIEW -d file:///storage/sdcard0/test.wav -t audio/wav

balu b
- 282
- 2
- 7
-
That is interesting. I ssh'd into the phone and tried. The command was recognized, but I got an android permission violation: `Starting: Intent { act=android.intent.action.VIEW dat=vocalf1.mp3 } java.lang.SecurityException: Permission Denial: startActivity asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL at android.os.Parcel.readException(Parcel.java:1431) ...` – Leo Jun 20 '16 at 12:19
-
2
2
There are two other command line programs which may work via a adb shell or even remotely using an ssh connection. Neither need an installed music player app.
adb shell stagefright -a -o file.mp3
and
adb shell tinyplay file.wav
(drop adb shell
if not using an adb
connection)
Note that tinyplay
can only play stereo wav files. I found out about the stagefright
command from a3nm's blog: Android from the command-line.

MJ Walsh
- 593
- 6
- 11
-
I get Unable to open file 'file.wav' error when using tinyplay. where the file should located? – user3806649 Mar 07 '17 at 07:05
-
That was just an example. You have to find or upload a file to play yourself. – MJ Walsh Mar 08 '17 at 19:18
-
I run `adb shell tinyplay file:///storage/sdcard/download/bird.wav` but I got an error `Unable to open file 'file:///storage/sdcard/download/bird.wav'`. how I should address audio file? – user3806649 Mar 08 '17 at 20:18
-
Sorry! Now I understand. You need to use the unix path to the file, not a URL. `adb shell tinyplay /sdcard/download/bird.wav` will probably work, but it will depend on your device. – MJ Walsh Mar 18 '17 at 16:32