In Android 11 and Android 12, media
utility no longer exists. That's why you got the error since your shell could not find the utility in locations mentioned in its PATH. That utility's commands have been moved to a service name MediaSessionService
. To access those commands invoke this service using cmd
command.
adb shell cmd media_session
Example:
$ cmd media_session
usage: media_session [subcommand] [options]
media_session dispatch KEY
media_session dispatch KEY
media_session list-sessions
media_session monitor
media_session volume [options]
media_session dispatch: dispatch a media key to the system.
KEY may be: play, pause, play-pause, mute, headsethook,
stop, next, previous, rewind, record, fast-forword.
media_session list-sessions: print a list of the current sessions.
media_session monitor: monitor updates to the specified session.
Use the tag from list-sessions.
media_session volume: the options are as follows:
--stream STREAM selects the stream to control, see AudioManager.STREAM_*
controls AudioManager.STREAM_MUSIC if no stream is specified
--set INDEX sets the volume index value
--adj DIRECTION adjusts the volume, use raise|same|lower for the direction
--get outputs the current volume
--show shows the UI during the volume change
examples:
adb shell media volume --show --stream 3 --set 11
adb shell media volume --stream 0 --adj lower
adb shell media volume --stream 3 --get
The examples section above has not been updated in the source code to reflect new changes, that's why it still recommends using media
or adb shell media
.