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.
use the following adb shell command:
adb shell am start -a android.intent.action.VIEW -d file:///storage/sdcard0/test.wav -t audio/wav
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) ...
–
Plainsong 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.
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? –
Conure adb shell tinyplay /sdcard/download/bird.wav
will probably work, but it will depend on your device. –
Clactonian After downloading the android build kit and installing tinyplay I found it only works on rooted androids. :(
I found the command from the android itself.. how?
- Open the filemanager on the device
- Have android in developer mode
- Connect adb
adb -s 0123456789ABCDEF shell
- Play your audio file/movie whatever
- While it's playing run
dumpsys adb -s 0123456789ABCDEF dumpsys activity | vim -
- Find the activity that's playing the media
- Craft your command from the output of dumpsys
adb -s 0123456789ABCDEF shell am start -a android.intent.action.View -d file:///sdcard/Download/win.wav -t audio/x-wav -n com.android.music/.AudioPreview
I was then able to use the same technique to play a mp3 - in combination with reading the am documentation to get the -S flag (https://gist.github.com/tsohr/5711945)
adb -s $i shell am start -S -a android.intent.action.View -d file:///storage/emulated/0/Download/barry_manilow_oh_my_lady.mp3 -t audio/mpeg -n com.android.music/.AudioPreview
© 2022 - 2025 — McMap. All rights reserved.