我想制作一个音乐播放器,我有一个问题,即吐司文件名,因为它总是包含扩展名(".mp3")
有谁知道如何删除这些扩展名?
这是我的代码
try {
if (mMediaPlayer.isPlaying()) {
mMediaPlayer.reset();
}
mMediaPlayer.setDataSource(filename);
mMediaPlayer.prepare();
mMediaPlayer.start();
Toast.makeText(getApplicationContext(), nama , Toast.LENGTH_LONG).show();
} catch (Exception e) {
}
Run Code Online (Sandbox Code Playgroud)
和
music_column_index=
musiccursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DISPLAY_NAME);
musiccursor.moveToPosition(position);
nama = musiccursor.getString(music_column_index);
Run Code Online (Sandbox Code Playgroud)
我想让它干杯"xx"而不是"xx.mp3"
String name = "Jai_Ho.mp3"
String nameWithoutExtension = name.subString(0,name.lastIndexOf("."));
Run Code Online (Sandbox Code Playgroud)
也可以看看