我正在从 Web 服务接收一个 ByteArray,并且我希望能够在 HTML5 音频标签中播放音频 ByteArray。我想知道这是否可能,因为音频标签需要一个 URL
<!DOCTYPE html>
<%@page import="yourphone.voicemail.*"%>
<%@page import="com.verscom.ws.*"%>
<%@page import="com.verscom.methods.*"%>
<body>
<button onclick="playSound()">Play Me</button>
<button onclick="pausrSound()">Pause</button>
<audio id="audio" controls="controls">
<source id="mainSrc" type="audio/mp3" onplay="playSound()"></source>
</audio>
</body>
<script type="text/javascript">
var audio = document.getElementById("audio");
function playSound(){
<%
EndUserPortalWSServiceStub.GetVoiceMailMessageVcomResponse[] getvmMsgResp = new EndUserPortalWSServiceStub.GetVoiceMailMessageVcomResponse[2];
EndUserMethods endUserMethods = new EndUserMethods();
getvmMsgResp = endUserMethods.getVoiceMailList();
%>
audio.src= <%=getvmMsgResp[0].getVmailMessageWAVFile().getDataSource().getInputStream()%>;
audio.play(); }
function pausrSound(){ audio.pause(); }
</script>
以下代码不起作用:
audio.src= <%=getvmMsgResp[0].getVmailMessageWAVFile().getDataSource().getInputStream()%>;
任何想法 ?