将amr文件转化成base64字符串,用js转换成音频播放
js文件下载链接: https://pan.baidu.com/s/1kWsLOc3 密码: 2ca5
链接: https://pan.baidu.com/s/1smk2fdN 密码: qcbw
$a=file_get_contents("./a.amr");
$b=base64_encode($a);
// echo $b;
// die;
?>
<!DOCTYPE HTML>
<html>
<head>
<script src="audio.min.js"></script>
</head>
<script src="voice-2.0.js"></script>
<script>
audiojs.events.ready(function() {
var as = audiojs.createAll();
});
</script>
<body>
<input type="button" value="play" id="playId"/>
<input type="button" value="stop" id="stopId"/>
</body>
<script type="text/javascript">
RongIMLib.RongIMVoice.init();
document.getElementById("playId").onclick = function(){
RongIMLib.RongIMVoice.play("<?php echo $b;?>");
};
document.getElementById("stopId").onclick = function(){
RongIMLib.RongIMVoice.stop();
};
</script>
</html>