- 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/
我尝试使用 Surface View 创建媒体播放器。当我尝试为媒体播放器设置数据源时,出现了 setDataSource 失败异常。如何解决? 代码: @Override public void s
JSTL <sql:setDataSource> 标签用来在 JSP 页面中配置数据源,并将其存储在某作用域的变量中。 语法 JSP <sql:setDataSource>
我已经设法用音频文件填充我的 ListView,但是当单击 ListView 中的项目时没有任何反应,我收到异常“setDataSource failed”。 public class songsFr
我对 MediaMetadataRetriever setdatasource 方法有疑问。我创建了一个简单的项目。 main.xml 只有一个 TextView ,它应该显示 music.mp3 的
我在使用 MediaMetadataRetriever 检索 mp3 文件的艺术家和标题时收到错误(setDataSource 失败 0x8000000),但我不明白为什么。在我的模拟器上运行时,它运
我正在尝试使用 Android MediaMetadataRetriever 获取 mp4 格式的录制视频的长度 - 但出现异常: 07-13 13:54:32.686: E/AndroidRunti
阅读“Media Playback”和“MediaPlayer”android 文档后,我仍然感到困惑,需要有关 setDataSource 的有经验的建议重载方法。 我在项目的 Service 组件
假设我有一个文件的完整路径。将该文件加载到 MediaPlayer 中的更好方法是什么? String filePath = "somepath/somefile.mp3"; mediaPlayer.
我有一个 UIViewController其中包含此属性: @property (weak, nonatomic) IBOutlet UITableView *customerTableView; 在
我是 android 编程的初学者,我想编写 mp3 应用程序以从 URL 调用一些 mp3 文件,所以当我在 android 开发人员中显示“媒体播放器”时,我将 URL 放在 setDataSou
我正在开发一个使用 mediaMetadataRetriever.setDataSource 抓取视频帧的应用程序。但是,当我设置视频路径时,它给了我一个非法参数异常并崩溃。我是 java 和 And
我正在尝试使用 MediaExtract 提取 avi 文件的轨道 0(视频轨道)并使用 MediaCodec 编码为 h264 格式。这是我配置 mediaCodec 的方式 public Medi
我收到以下错误 java.lang.RuntimeException: setDataSource failed: status = 0xFFFFFFEA 我想知道这个状态是什么。我正在使用函数 Me
我正在尝试使用此类获取远程视频的大小,如果视频是远程的,我将收到 IllegalArgumentException。 视频是存储在一台服务器上的mp4... 如果我用 mediaplayer 播放视频
我正在尝试使用 NSarray 使用 NSTableView 创建一个简单的菜单。当我将数据源设置为我创建的类时,出现 EXC_BAD_ACCESS 错误。奇怪的是,它在 macruby 中有效吗?实
我在 VS 2010 sap crystalreports 中遇到问题,使用 c# 制作 Windows 应用程序。 我在使用以下代码时遇到以下错误: CrystalReport1 cr1 = ne
这段代码曾经有效。然后,也许我在某个地方改变了一些东西(或者如果我对 Android 的了解是正确的,则更新在媒体播放器中引入了一个错误)。它停止在 一些 设备上运行!尤其是我的 Nexus S (2
如果使用静态方法MediaPlayer.create(context,id),我可以播放本地mp3,但如果使用非静态方法MediaPlayer.setDataSource(String),则无法正常播
我是 Android 开发新手。我正在尝试根据位置选择歌曲时播放歌曲。它总是崩溃并且有多个错误。我真的不明白我做错了什么。可能是愚蠢的错误,请帮助。 public class BackgroundAu
这个问题很奇怪。问题是,每当我尝试使用时间戳字符串命名文件时,setDataSource 方法都会失败并给出 IOException,但如果我给出诸如包含字母表(例如“Hello.m4a”)的名称,则
我是一名优秀的程序员,十分优秀!