//mp是MediaPlayer实例对象,fd是读取raw文件夹下的文件信息类
try {
	AssetFileDescriptor fd = getResources().openRawResouceFd(R.raw.greet_1);
	mp.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
	mp.start();
	fd.close();
} catch (IllegalArgumentException e) {
// handle exception
} catch (IllegalStateException e) {
// handle exception
} catch (IOException e) {
// handle exception
}


之后,上机实践...
>>好没含金量的一篇文章喔,能够有实用价值就好吐舌头
Logo

讨论HarmonyOS开发技术,专注于API与组件、DevEco Studio、测试、元服务和应用上架分发等。

更多推荐