class StartClickListener implements OnClickListener
{
@Override
public void onClick(View v)
{
if (!isPlay)
{
String mp3Path = getMp3Path(mp3Info);
// mediaPlayer = MediaPlayer.create(PlayMp3Activity.this,Uri.parse("file://" + mp3Path));
mediaPlayer = new MediaPlayer();
try{
mediaPlayer.setDataSource(PlayMp3Activity.this, Uri.parse("file://" + mp3Path));
mediaPlayer.prepare();
mediaPlayer.start();
isPlay = true;
isStop = false;
isPause = false;
}catch(Exception e){
e.printStackTrace();
}
}
}
} 1. 如果用mediaPlayer = MediaPlayer.create(PlayMp3Activity.this,Uri.parse("file://" + mp3Path))方式得到一个空的mediaPlayer对象,不知道为什么? 2. mediaPlayer = new MediaPlayer();
这种方式能播放MP3文件,但是在中途突然停止了。 log:
bufferCount (4) is too small and increased to 12
write blocked for 83 msecs, 1627 delayed writes, thread 0xb3f0
....
....
write blocked for 83 msecs, 1627 delayed writes, thread 0xb3f0
]error (1, -2147483648)
]Error (1, -2147483648)望那个兄台解读下。。
不甚感激。
{
@Override
public void onClick(View v)
{
if (!isPlay)
{
String mp3Path = getMp3Path(mp3Info);
// mediaPlayer = MediaPlayer.create(PlayMp3Activity.this,Uri.parse("file://" + mp3Path));
mediaPlayer = new MediaPlayer();
try{
mediaPlayer.setDataSource(PlayMp3Activity.this, Uri.parse("file://" + mp3Path));
mediaPlayer.prepare();
mediaPlayer.start();
isPlay = true;
isStop = false;
isPause = false;
}catch(Exception e){
e.printStackTrace();
}
}
}
} 1. 如果用mediaPlayer = MediaPlayer.create(PlayMp3Activity.this,Uri.parse("file://" + mp3Path))方式得到一个空的mediaPlayer对象,不知道为什么? 2. mediaPlayer = new MediaPlayer();
这种方式能播放MP3文件,但是在中途突然停止了。 log:
bufferCount (4) is too small and increased to 12
write blocked for 83 msecs, 1627 delayed writes, thread 0xb3f0
....
....
write blocked for 83 msecs, 1627 delayed writes, thread 0xb3f0
]error (1, -2147483648)
]Error (1, -2147483648)望那个兄台解读下。。
不甚感激。
解决方案 »
- SQLite一个数据库可以同时打开两张表吗?
- 计算器代码求解释
- 关于android点击ListView的item后变色
- 使用webview加载flash的时候,新增view会被flash覆盖
- 请教screenOrientation="nosensor"和configChanges="keyboardHidden|ori
- android源码中有hal学习的sample么?
- 安卓平板的模拟器怎么用????
- 新手提问:手机网页开发需要学什么
- 导入项目后,报错:No resource found that matches the given name
- getAssets() 返回null 是啥回事
- 怎么知道手机用户是否安装了手机软件呢
- 请问继承dialog后,最外面的padding怎样获得?
mediaPlayer.reset();
另外,新开辟一个线程来播放,防止阻塞主线程