- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
这段代码曾经有效。然后,也许我在某个地方改变了一些东西(或者如果我对 Android 的了解是正确的,则更新在媒体播放器中引入了一个错误)。它停止在 一些 设备上运行!尤其是我的 Nexus S (2.3.6)。
应用下载了文件 test.m4a
(17775201 字节)。为了验证其完整性,我将其复制到 SD 并在我的 PC 上播放。没问题!还把它与原始文件二进制比较,它匹配了 100%。
try {
_mediaPlayer = new MediaPlayer();
_mediaPlayer.setOnCompletionListener(this);
_mediaPlayer.setOnPreparedListener(this);
_mediaPlayer.setOnSeekCompleteListener(this);
_mediaPlayer.setOnBufferingUpdateListener(this);
_mediaPlayer.setOnInfoListener(this);
_mediaPlayer.setOnErrorListener(this);
// I even tried reading the file from SD card. Same error...
File file = new File("/data/data/com.mycompany.myapp/files/MediaCache/Test.m4a");
// file.isFile() == true
// file.length() == expected value!
FileInputStream is = new FileInputStream(file);
_mediaPlayer.setDataSource(is.getFD()); // Throws!
// If I use the filename as parameter, it throws later when preparing the media player...
_mediaPlayer.prepareAsync();
}
catch (Exception e) {
// java.io.IOException: setDataSourceFD failed.: status=0x80000000
e.printStackTrace();
}
问:当文件确实有效时,什么可能导致 setDataSourceFD
出现此 IOException
?
更新:这是一个 98 kB 的音频文件,我无法在 Nexus S (2.3.6) 上播放: http://www.2shared.com/audio/wUKoRiQk/test.html
我的一个 friend 运行一些 ZTE 设备 (2.2),它似乎可以工作。没看懂!
最佳答案
我想告诉您,MediaPlayer 正在正常运行。以下是我的所有假设。不要太认真。
这是您的 test.m4a 文件以 MediaPlayer 无法解码的格式编码,因此抛出一个错误,指出它无法创建 MediaPlayer 供您使用。 好像您使用计算机上的一些 FFmpeg 编解码器对其进行了编码。如果您尝试在不使用高级编解码器(例如 FFmpeg)的情况下创建文件会更好,因为 Android 无法即时解码高级编解码器。
但是,我不知道为什么有些智能手机可以播放您的 M4A 文件,而有些则不能。我对您的建议是使用 Audacity 已经安装的简单 OGG 格式,用于您的所有 Android 项目,因为 Audacity 拥有的 OGG 编解码器足够简单,Android 可以即时解码。我并不是说许多开发人员主要使用 OGG,只是在使用简单的编解码器时 OGG 似乎对 MediaPlayer 和 SoundPool 没有太多问题。需要更多研究...
甚至我的书《开始 Android 4 游戏开发》也依赖于 OGG 文件。
下面是我的证明。这是我在您的链接中使用的文件“test.m4a”。我让它在一个无限循环中运行,使其成为 100% 的证据证明:
03-18 01:05:22.826: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:22.826: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:22.936: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:22.936: I/MediaPlayer(1289): IOException...
03-18 01:05:22.936: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:22.936: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:23.037: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:23.046: I/MediaPlayer(1289): IOException...
03-18 01:05:23.046: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:23.046: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:23.146: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:23.146: I/MediaPlayer(1289): IOException...
03-18 01:05:23.146: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:23.156: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:23.256: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:23.256: I/MediaPlayer(1289): IOException...
03-18 01:05:23.256: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:23.256: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:23.366: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:23.366: I/MediaPlayer(1289): IOException...
03-18 01:05:23.366: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:23.366: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:23.476: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:23.476: I/MediaPlayer(1289): IOException...
03-18 01:05:23.476: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:23.476: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:23.586: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:23.586: I/MediaPlayer(1289): IOException...
03-18 01:05:23.586: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:23.586: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:23.696: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:23.696: I/MediaPlayer(1289): IOException...
03-18 01:05:23.696: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:23.696: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:23.806: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:23.806: I/MediaPlayer(1289): IOException...
03-18 01:05:23.806: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:23.806: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:23.917: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:23.917: I/MediaPlayer(1289): IOException...
03-18 01:05:23.917: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:23.917: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:24.026: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:24.026: I/MediaPlayer(1289): IOException...
03-18 01:05:24.026: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:24.026: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:24.136: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:24.136: I/MediaPlayer(1289): IOException...
03-18 01:05:24.136: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:24.136: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:24.246: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:24.246: I/MediaPlayer(1289): IOException...
03-18 01:05:24.246: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:24.246: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:24.356: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:24.356: I/MediaPlayer(1289): IOException...
03-18 01:05:24.356: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:24.356: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:24.466: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:24.466: I/MediaPlayer(1289): IOException...
03-18 01:05:24.466: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:24.466: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:24.856: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:24.856: I/MediaPlayer(1289): IOException...
03-18 01:05:24.856: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:24.856: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:25.017: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:25.017: I/MediaPlayer(1289): IOException...
03-18 01:05:25.017: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:25.017: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:25.146: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:25.157: I/MediaPlayer(1289): IOException...
03-18 01:05:25.157: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:25.157: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:25.266: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:25.266: I/MediaPlayer(1289): IOException...
03-18 01:05:25.266: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:25.266: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:25.376: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:25.376: I/MediaPlayer(1289): IOException...
03-18 01:05:25.376: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:25.376: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:25.486: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:25.486: I/MediaPlayer(1289): IOException...
03-18 01:05:25.486: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:25.486: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:25.586: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:25.586: I/MediaPlayer(1289): IOException...
03-18 01:05:25.586: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:25.586: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:25.696: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:25.696: I/MediaPlayer(1289): IOException...
03-18 01:05:25.696: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:25.696: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:25.806: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:25.806: I/MediaPlayer(1289): IOException...
03-18 01:05:25.806: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:25.806: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:25.916: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:25.916: I/MediaPlayer(1289): IOException...
03-18 01:05:25.916: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:25.916: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:26.026: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:26.026: I/MediaPlayer(1289): IOException...
03-18 01:05:26.026: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:26.026: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:26.136: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:26.136: I/MediaPlayer(1289): IOException...
03-18 01:05:26.136: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:26.136: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:26.246: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:26.246: I/MediaPlayer(1289): IOException...
03-18 01:05:26.246: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:26.246: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:26.356: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:26.356: I/MediaPlayer(1289): IOException...
03-18 01:05:26.356: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:26.356: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:26.466: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:26.466: I/MediaPlayer(1289): IOException...
03-18 01:05:26.466: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:26.466: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:26.577: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:26.577: I/MediaPlayer(1289): IOException...
03-18 01:05:26.577: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:26.577: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:26.697: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:26.697: I/MediaPlayer(1289): IOException...
03-18 01:05:26.697: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:26.697: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:26.807: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:26.807: I/MediaPlayer(1289): IOException...
03-18 01:05:26.807: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:26.807: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:26.917: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:26.917: I/MediaPlayer(1289): IOException...
03-18 01:05:26.917: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:26.917: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:27.027: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:27.027: I/MediaPlayer(1289): IOException...
03-18 01:05:27.027: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:27.027: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:27.137: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:27.137: I/MediaPlayer(1289): IOException...
03-18 01:05:27.137: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:27.137: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:27.236: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:27.236: I/MediaPlayer(1289): IOException...
03-18 01:05:27.236: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:27.236: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:27.347: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:27.347: I/MediaPlayer(1289): IOException...
03-18 01:05:27.347: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:27.347: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:27.457: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:27.457: I/MediaPlayer(1289): IOException...
03-18 01:05:27.457: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:27.457: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:27.567: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:27.567: I/MediaPlayer(1289): IOException...
03-18 01:05:27.567: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:27.567: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:27.677: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:27.677: I/MediaPlayer(1289): IOException...
03-18 01:05:27.677: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:27.677: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:27.787: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:27.787: I/MediaPlayer(1289): IOException...
03-18 01:05:27.787: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:27.787: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:27.907: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:27.907: I/MediaPlayer(1289): IOException...
03-18 01:05:27.907: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:27.907: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:28.007: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:28.017: I/MediaPlayer(1289): IOException...
03-18 01:05:28.017: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:28.017: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:28.127: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:28.127: I/MediaPlayer(1289): IOException...
03-18 01:05:28.127: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:28.127: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:28.237: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:28.237: I/MediaPlayer(1289): IOException...
03-18 01:05:28.237: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:28.237: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:28.347: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:28.347: I/MediaPlayer(1289): IOException...
03-18 01:05:28.347: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:28.347: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:28.457: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:28.457: I/MediaPlayer(1289): IOException...
03-18 01:05:28.457: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:28.457: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:28.567: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:28.567: I/MediaPlayer(1289): IOException...
03-18 01:05:28.567: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:28.567: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:28.677: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:28.677: I/MediaPlayer(1289): IOException...
03-18 01:05:28.677: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:28.677: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:28.787: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:28.787: I/MediaPlayer(1289): IOException...
03-18 01:05:28.787: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:28.787: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:28.907: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:28.907: I/MediaPlayer(1289): IOException...
03-18 01:05:28.907: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:28.907: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:29.017: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:29.017: I/MediaPlayer(1289): IOException...
03-18 01:05:29.017: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:29.017: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:29.127: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:29.127: I/MediaPlayer(1289): IOException...
03-18 01:05:29.127: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:29.127: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:29.237: E/MediaPlayer(1289): Unable to to create media player
03-18 01:05:29.237: I/MediaPlayer(1289): IOException...
03-18 01:05:29.237: D/MediaPlayer(1289): Making sure it is in IDLE state...
03-18 01:05:29.237: D/MediaPlayer(1289): Setting Data Source...
03-18 01:05:29.327: D/dalvikvm(1289): Calling exit(1)
现在,这是我编写的代码,如下所示:
package nttu.edu.test;
import java.io.IOException;
import android.app.Activity;
import android.content.res.AssetFileDescriptor;
import android.content.res.AssetManager;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.TextView;
public class MediaPlayerTest extends Activity implements OnTouchListener {
MediaPlayer player = null;
TextView tv;
public final String fileName = "sounds/test.m4a";
AssetManager asset;
AssetFileDescriptor afd;
public void onCreate(Bundle b) {
super.onCreate(b);
tv = new TextView(this);
tv.setOnTouchListener(this);
tv.setText("Touch to start playing the music.");
Log.d("MediaPlayer", "Creating MediaPlayer.");
player = new MediaPlayer();
try {
asset = this.getAssets();
afd = asset.openFd(fileName);
}
catch (Exception e) {
}
while (true) {
try {
Log.d("MediaPlayer", "Making sure it is in IDLE state...");
player.reset();
Log.d("MediaPlayer", "Setting Data Source...");
player.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
Log.d("MediaPlayer", "Now initialized. Preparing it.");
player.prepare();
break;
}
catch (IllegalArgumentException e) {
Log.i("MediaPlayer", "IllegalArgumentException...");
}
catch (IllegalStateException e) {
Log.i("MediaPlayer", "IllegalStateException...");
}
catch (IOException e) {
Log.i("MediaPlayer", "IOException...");
}
}
try {
afd.close();
}
catch (IOException e) {
}
setContentView(tv);
Log.d("MediaPlayer", "Everything is prepared and ready to play the music file.");
}
public boolean onTouch(View v, MotionEvent e) {
if (e.getAction() == MotionEvent.ACTION_UP) {
Log.d("MediaPlayer", "Playing the audio.");
if (player.getAudioSessionId() != 0) {
player.start();
Log.d("MediaPlayer", "Success!");
}
}
return true;
}
protected void onResume() {
super.onResume();
}
protected void onPause() {
super.onPause();
if (player.getAudioSessionId() != 0) {
player.pause();
if (isFinishing()) {
player.stop();
player.release();
}
}
}
}
请注意代码 fragment 顶部附近的最终字符串变量。如果我用这个替换那行:
public final String fileName = "sounds/test.ogg";
并将您的“test.m4a”文件重新编码为 Ogg Vorbis 文件,并且代码中没有其他更改,我可以正常播放 OGG 文件。以下是 OGG 文件的更改日志:
03-18 01:14:21.547: D/gralloc_goldfish(1335): Emulator without GPU emulation detected.
03-18 01:14:23.467: D/dalvikvm(1335): GC_CONCURRENT freed 50K, 4% free 5952K/6151K, paused 7ms+3ms
03-18 01:14:24.647: D/MediaPlayer(1335): Creating MediaPlayer.
03-18 01:14:24.657: D/MediaPlayer(1335): Making sure it is in IDLE state...
03-18 01:14:24.657: D/MediaPlayer(1335): Setting Data Source...
03-18 01:14:24.707: D/MediaPlayer(1335): Now initialized. Preparing it.
03-18 01:14:24.927: D/MediaPlayer(1335): Everything is prepared and ready to play the music file.
03-18 01:14:26.797: D/MediaPlayer(1335): Playing the audio.
03-18 01:14:26.817: D/MediaPlayer(1335): Success!
然后它就停在这里了。没有循环。
更多证据支持我的回答:
Link 1: Android SDK Reference (Do look at the State Diagram, very important!)
还有一张图片(您的“test.m4a”图片和您的文件重新编码成 OGG 文件,并排放置。):
关于android - MediaPlayer.setDataSource 导致有效文件的 IOException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9657280/
我们有一个连接到某些网络服务的 Windows 窗体应用程序。它列出了系统中的文档,当用户双击一个文件时,我们将文件下载到本地计算机并打开文档供他们编辑。一旦用户关闭文档,我们就会将其上传回系统。 对
public class SampleCloseable implements AutoCloseable { private String name; public SampleCl
我正在尝试使用 JAVA 运行一个简单的 sqoop 导入程序。 我的程序: String driver="com.vertica.Driver"; Configuration con
我需要从 Java 执行一个外部程序(使用 libreoffice 将 fodt 文件转换为 pdf,就这样发生了)我知道该程序所需的精确命令行: /usr/bin/libreoffice --hea
AFAIK,标准try-with-resources 形式 try(InputStream is= new ...){ ... some reading from is } catch (..
我观察到这两种说法都是有效的。与第二个语句相比,第一个语句中记录的额外内容是什么? 最佳答案 第一个还记录原始异常(和堆栈跟踪),第二个仅记录消息。 因此,第一个语句中记录的“额外内容”是原始异常。这
我想执行重命名和删除功能,环境是LINUX。这是我正在使用的代码, String[] command_ary = { "/usr/bin/sh", "-c", command }; Runtime r
在使用 selenium webdriver 实现 Web 应用程序的自动化时,我遇到了一种情况,我需要上传文件并进一步继续。 我们为此使用 Java 和 Tcl 脚本语言。 下面是我的 TCL 代码
我正在尝试使用 ANT 将文件从一个目录复制到 Linux 上的另一个目录。 首先我使用了复制任务,它工作正常但文件模式没有保留。然后我改为使用 ,这就是我卡住的地方。 我的目标是这样的:
当我输入命令时: ./sqoop-import --connect jdbc:mysql://localhost/sqoop2 -table sqeep2 -m 1 -hive-import 当执行这
我正在使用 Sun 的 keytool 创建一个 Bouncy caSTLe keystore 并将证书导入其中。 keytool 确实会生成一个 Bouncy caSTLe 格式的 keystore
我正在执行下面的程序,它通过 java 调用 shell,我得到了异常请帮助我。 程序: import java.io.*; import java.util.*; public class Proc
我在我的一个项目中遇到了这个错误。 FAILURE: Build failed with an exception. What went wrong: Execution failed for tas
什么情况下read end可以死对偶PipedOutputStream和 PipedInputStream ?我没有关闭任何管道。 最佳答案 我遇到了java.io.IOException: Read
我有一段从文件中读取数据的代码。我想在此代码中强制 IOException 用于测试目的(我想检查代码在这种情况下是否抛出正确的自定义异常)。 例如,有什么方法可以创建一个防止被读取的文件?也许处理一
我为MapReduce文本排序编写了这样的代码: public static class SortMapper extends Mapper { private Text citizenshi
已关闭。此问题需要 debugging details 。目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and the
我要createNewFile有一条路径,但我得到了一个 IOException。问题是,详细的消息无法解释,我只能看到一堆问号。 我最初使用的是西类牙语的 Windows 10,但安装了中文语言包。
我认为这是基本的东西,但我不知道该怎么做。为什么我得到 IOException never throw in body of相应的 try 语句 public static void main(Str
我正在从 Java 项目中的类路径读取文件。 示例代码: public static Properties loadPropertyFile(String fileName) {
我是一名优秀的程序员,十分优秀!