【问题标题】:How to play one audio file in android using adb command?如何使用 adb 命令在 android 中播放一个音频文件?
【发布时间】:2015-05-25 11:44:19
【问题描述】:

我有一个安卓目标。
我在 mnt/sdcard0 中有一些音频文件。
如何通过 adb 命令播放?
目标中已安装音乐播放器应用程序。

【问题讨论】:

标签: android adb


【解决方案1】:

使用以下 adb shell 命令:

adb shell am start -a android.intent.action.VIEW -d file:///storage/sdcard0/test.wav -t audio/wav

【讨论】:

  • 这很有趣。我 ssh 进入电话并尝试了。该命令被识别,但我得到了一个 android 权限违规: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) ...
  • 添加 --user 0 修复它!
【解决方案2】:

还有另外两个命令行程序可以通过 adb shell 甚至远程使用 ssh 连接运行。两者都不需要安装的音乐播放器应用。

adb shell stagefright -a -o file.mp3

adb shell tinyplay file.wav

(如果不使用adb 连接,则丢弃adb shell

注意tinyplay 只能播放立体声 wav 文件。我从a3nm's blog: Android from the command-line 发现了stagefright 命令。

【讨论】:

  • 使用 tinyplay 时出现无法打开文件“file.wav”错误。文件应该放在哪里?
  • 这只是一个例子。您必须自己查找或上传文件才能播放。
  • 我运行adb shell tinyplay file:///storage/sdcard/download/bird.wav,但出现错误Unable to open file 'file:///storage/sdcard/download/bird.wav'。我应该如何处理音频文件?
  • 对不起!现在我明白了。您需要使用文件的 unix 路径,而不是 URL。 adb shell tinyplay /sdcard/download/bird.wav 可能会起作用,但这取决于您的设备。
猜你喜欢
  • 2014-12-05
  • 1970-01-01
  • 2012-02-02
  • 2011-11-09
  • 1970-01-01
  • 2010-12-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多