Use Android adb to play audio and video

1. Play music

    adb shell am start -n com.android.music/com.android.music.MediaPlaybackActivity -d /sdcard/timian.mp3

 (/sdcard/timian.mp3 is the music address)

or:

adb shell am start -a "android.intent.action.VIEW" -t "audio/mp3" -d "file:///storage/sdcard0/Music/hello.mp3"

(/storage/sdcard0/Music/hello.mp3 is the music address)

  You can also operate the screen and simulate keys

adb shell input keyevent 24 #增加音量
adb shell input keyevent 25 #降低音量
adb shell input keyevent 85 #暂停/播放
adb shell input keyevent 126 #恢复播放
adb shell input keyevent 127 #停止播放

2. Play video

adb shell am start -a android.intent.action.VIEW -d   "file:///mnt/sdcard/DCIM/Camera/test.3gp" -t "video/*" 

/mnt/sdcard/DCIM/Camera/test.3gp is the video file address

or:

adb shell am start -a android.intent.action.VIEW -d "file:///mnt/sdcard/DCIM/Camera/test.3gp" -t "video/*" -n "com.alensw.PicFolder/.PlayerActivity" 

/mnt/sdcard/DCIM/Camera/test.3gp is the video file address

3. Closing can be carried out by killing the process

ps -A | grep music
#找到music的pid
kill pid

Guess you like

Origin blog.csdn.net/luyao3038/article/details/127865737