MediaPlayer 仅在调试模式下播放音乐文件 (Android) [英] MediaPlayer plays the music files only in debug mode ( Android )
本文介绍了MediaPlayer 仅在调试模式下播放音乐文件 (Android)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我编写了一个 Android 应用程序(在 eclipse 中),它播放音乐文件如下:
I have written an Android application ( in eclipse) that plays a music file as follows:
MediaPlayer mediaPlayer = new MediaPlayer();
try
{
mediaPlayer.setDataSource(fileName);
mediaPlayer.prepare();
mediaPlayer.start();
// mediaPlayer.stop();
}
catch (Exception e)
{
Log.d("Exception---", e.getMessage());
}
当我运行它时,它不播放文件(并且不显示任何异常),但是当我切换到调试模式"并逐行跟踪它时,它会播放文件.我真的很困惑.你能帮我找出问题所在吗?
When I run it, it does not play the file ( and does not show any exception ), but when I switch to 'debug mode', and trace it line by line, it plays the file. I'm really confused. Would you please help me find out what's wrong?
谢谢.
推荐答案
在mediaPlayer.setDataSource(fileName)"之前放置一个日志,并检查您是否在发布模式下获得了有效的文件名.
Put a log before "mediaPlayer.setDataSource(fileName)" and check if you are getting a valid fileName in release mode.
这篇关于MediaPlayer 仅在调试模式下播放音乐文件 (Android)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文