【发布时间】:2011-04-02 12:33:30
【问题描述】:
我想在 IE 中嵌入默认媒体播放器中播放 .wav 声音文件。声音文件位于某个 HTTP 位置。我无法在那个播放器中发出声音。
以下是代码。
URL url = new URL("http://www.concidel.com/upload/myfile.wav");
URLConnection urlc = url.openConnection();
InputStream is = (InputStream)urlc.getInputStream();
fileBytes = new byte[is.available()];
while (is.read(fileBytes,0,fileBytes.length)!=-1){}
BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
out.write(fileBytes);
这里是 HTML 的嵌入代码。
<embed src="CallStatesTreeAction.do?ivrCallId=${requestScope.vo.callId}&agentId=${requestScope.vo.agentId}" type="application/x-mplayer2" autostart="0" playcount="1" style="width: 40%; height: 45" />
- 如果我在 FileOutputStream 中写入,那么它会播放得很好
- 如果我替换从 URL 获取文件到本地硬盘的代码。那么它也可以正常工作。
我不知道为什么我无法从 HTTP 播放文件。以及为什么它在本地硬盘上播放效果很好。
请帮忙。
【问题讨论】: