uniapp读取本地语音文件

用uniapp打包的APP获取本地mp3文件,网上查了很多资料,总结一下

	let innerAudioContext = uni.createInnerAudioContext();
	innerAudioContext.autoplay = true;
	let absPath = plus.io.convertLocalFileSystemURL('_www');
	// Android获取的absPath以/结尾,iOS获取的absPath不是/结尾
	if (absPath[absPath.length - 1] == '/') {
		absPath = absPath.substring(0, absPath.length - 1);
	}
	let url = absPath + `/static/mp3/语音.mp3`
	innerAudioContext.src = url;

你可能感兴趣的:(uni-app)