0

我从 webService 接收 InputStream,然后我将使用 HTML5 标签播放,所以为了播放音频,我需要将 InputStream 转换为 URL,以便标签可以读取这个流,因为它不读取 InputStream。

   <!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().toString()%>;
audio.play(); }

function pausrSound(){ audio.pause(); }

</script>
4

0 回答 0